Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
e2e: Use new host status constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarnes authored and ashcrow committed Mar 17, 2017
1 parent 993bb41 commit 92b4735
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

from urllib.parse import urlparse

from commissaire.constants import DEFAULT_CLUSTER_NETWORK_JSON
from commissaire import constants as C

# Fill in with context.ETCD after start_etcd().
STORAGE_CONF_TEMPLATE = """
Expand Down Expand Up @@ -335,7 +335,7 @@ def before_all(context):
except etcd.EtcdNotFile:
pass
context.etcd.write(
'/commissaire/networks/default', DEFAULT_CLUSTER_NETWORK_JSON)
'/commissaire/networks/default', C.DEFAULT_CLUSTER_NETWORK_JSON)

context.etcd.write('/commissaire/config/kubetoken', 'test')

Expand Down Expand Up @@ -391,7 +391,7 @@ def before_scenario(context, scenario):
context.HOST_DATA = {
'address': '',
'remote_user': 'vagrant',
'status': 'active',
'status': C.HOST_STATUS_ACTIVE,
'os': 'fedora',
'cpus': 1,
'memory': 1234,
Expand Down Expand Up @@ -433,7 +433,9 @@ def after_scenario(context, scenario):
Runs after every scenario.
"""
# Wait for investigator processes to finish.
busy_states = ('investigating', 'bootstrapping')
busy_states = (
C.HOST_STATUS_INVESTIGATING,
C.HOST_STATUS_BOOTSTRAPPING)
try:
etcd_resp = context.etcd.read('/commissaire/hosts', recursive=True)
for child in etcd_resp._children:
Expand Down
9 changes: 7 additions & 2 deletions features/steps/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from behave import *

from commissaire import constants as C

from steps import (
assert_status_code,
VALID_USERNAME, VALID_PASSWORD)
Expand Down Expand Up @@ -56,7 +58,9 @@ def impl(context, host):
# Poll until the host is finished bootstrapping.
# We can't watch an etcd key because the host record
# is only written to etcd after a successful bootstrap.
busy_states = ('investigating', 'bootstrapping')
busy_states = (
C.HOST_STATUS_INVESTIGATING,
C.HOST_STATUS_BOOTSTRAPPING)
status_is_busy = True
while status_is_busy:
time.sleep(1)
Expand All @@ -67,7 +71,8 @@ def impl(context, host):
data = request.json()
status_is_busy = data['status'] in busy_states

assert data['status'] in ('active', 'disassociated'), \
assert data['status'] in (
C.HOST_STATUS_ACTIVE, C.HOST_STATUS_DISASSOCIATED), \
'Host failed to bootstrap (status: {})'.format(data['status'])


Expand Down

0 comments on commit 92b4735

Please sign in to comment.