Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for add new client #888

Merged
merged 12 commits into from May 15, 2019
Merged

Add test for add new client #888

merged 12 commits into from May 15, 2019

Conversation

@beckmani
Copy link
Contributor

@beckmani beckmani commented May 12, 2019

Added new fixture: add_client
Added new test: Test that new client finishes bootstrap

@beckmani beckmani requested a review from antonlerner May 12, 2019
def add_client(request, setup_oracle, setup_poet, setup_bootstrap):

def _add_single_client():
bs_info = setup_bootstrap.pods[0]
Copy link
Member

@antonlerner antonlerner May 13, 2019

if no bootstrap this will fail, add a message for that

Copy link
Contributor Author

@beckmani beckmani May 14, 2019

Done. Added check before.

tests/test_bs.py Outdated
cimage=testconfig['client']['image'],
centry=[testconfig['client']['command']])

cspec.append_args(bootnodes="{0}:{1}/{2}".format(bs_info['pod_ip'], '7513', bs_info['key']),
Copy link
Member

@antonlerner antonlerner May 13, 2019

move port to constant variable

tests/test_bs.py Outdated

cspec.append_args(bootnodes="{0}:{1}/{2}".format(bs_info['pod_ip'], '7513', bs_info['key']),
oracle_server='http://{0}:3030'.format(setup_oracle),
poet_server='{0}:50002'.format(setup_poet),
Copy link
Member

@antonlerner antonlerner May 13, 2019

same here

tests/test_bs.py Show resolved Hide resolved
tests/test_bs.py Outdated

k8s_api = client.CoreV1Api()
resp = k8s_api.create_namespaced_pod(namespace=name_space, body=dep)
wait_for_pod_to_be_ready(resp.metadata._name, name_space, time_out=testconfig['deployment_ready_time_out'])
Copy link
Member

@antonlerner antonlerner May 13, 2019

maybe we should have a different timeout for a single node than of a larger deployment

- name: client
image: spacemeshos/go-spacemesh:develop
imagePullPolicy: Always
args: ['--randcon', '3', '--bootstrap', '--test-mode', '--oracle_server', 'http://10.12.3.14:3030', '--grpc-server', '--json-server', '--bootnodes', '10.36.1.12:7513/26hRBJqMJPUnKgJ9VR6g3kH6aCQhZ9shBvhn3bEHDvRyv']
Copy link
Member

@antonlerner antonlerner May 13, 2019

shouldn't this be parameterised?

Copy link
Contributor Author

@beckmani beckmani May 14, 2019

It is. we override it later

body=client.V1DeleteOptions(propagation_policy='Foreground',
grace_period_seconds=5))
except ApiException as e:
if e.status == 404:
Copy link
Member

@antonlerner antonlerner May 15, 2019

what about other errors?

Copy link
Contributor Author

@beckmani beckmani May 15, 2019

This error may result from timing. (The pod may be delete before we get here)
Other error should not be ignored

try:
resp = client.CoreV1Api().read_namespaced_pod(name=pod_name, namespace=name_space)
except ApiException as e:
if e.status == 404:
Copy link
Member

@antonlerner antonlerner May 15, 2019

what about other errors



@pytest.fixture()
def add_client(request, setup_oracle, setup_poet, setup_bootstrap, setup_clients):
Copy link
Member

@antonlerner antonlerner May 15, 2019

add comment about this not being a functional fixture and shouldn't be used in our tests

Copy link
Contributor Author

@beckmani beckmani May 15, 2019

ok

dep = container_specs.update_deployment(dep)

k8s_api = client.CoreV1Api()
resp = k8s_api.create_namespaced_pod(namespace=name_space, body=dep)
Copy link
Member

@antonlerner antonlerner May 15, 2019

if resp is error should we wait for pod to be ready?

def wait_for_pod_to_be_ready(pod_name, name_space, time_out=None):
total_sleep_time = 0
while True:
resp = client.CoreV1Api().read_namespaced_pod(name=pod_name, namespace=name_space)
Copy link
Member

@antonlerner antonlerner May 15, 2019

can this return error? what should happen if so?

Copy link
Contributor Author

@beckmani beckmani May 15, 2019

I don't know. I havn't met an error here.
If we see that there are errors here we will handle them in the future

total_sleep_time = 0
while True:
try:
resp = client.CoreV1Api().read_namespaced_pod(name=pod_name, namespace=name_space)
Copy link
Member

@antonlerner antonlerner May 15, 2019

can this return error? what should happen if so?

@beckmani beckmani merged commit c34887e into develop May 15, 2019
1 check passed
@y0sher y0sher deleted the add-pod-to-setup branch Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Accounts
Awaiting triage
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants