-
Notifications
You must be signed in to change notification settings - Fork 3.3k
e2e: use labels for configmap api; wait for default service account creation #1348
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
Merged
k8s-ci-robot
merged 3 commits into
kubernetes-client:master
from
roycaihw:configmap-e2e/labels
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,15 +19,22 @@ | |
import time | ||
import unittest | ||
import uuid | ||
import six | ||
|
||
from kubernetes.client import api_client | ||
from kubernetes.client.api import core_v1_api | ||
from kubernetes.e2e_test import base | ||
from kubernetes.stream import stream, portforward | ||
from kubernetes.stream.ws_client import ERROR_CHANNEL | ||
from kubernetes.client.rest import ApiException | ||
|
||
import six.moves.urllib.request as urllib_request | ||
|
||
if six.PY3: | ||
from http import HTTPStatus | ||
else: | ||
import httplib | ||
|
||
def short_uuid(): | ||
id = str(uuid.uuid4()) | ||
return id[-12:] | ||
|
@@ -65,6 +72,27 @@ def test_pod_apis(self): | |
|
||
name = 'busybox-test-' + short_uuid() | ||
pod_manifest = manifest_with_command(name, "while true;do date;sleep 5; done") | ||
|
||
# wait for the default service account to be created | ||
timeout = time.time() + 30 | ||
while True: | ||
if time.time() > timeout: | ||
print('timeout waiting for default service account creation') | ||
break | ||
try: | ||
resp = api.read_namespaced_service_account(name='default', | ||
namespace='default') | ||
except ApiException as e: | ||
if (six.PY3 and e.status != HTTPStatus.NOT_FOUND) or ( | ||
six.PY3 is False and e.status != httplib.NOT_FOUND): | ||
print('error: %s' % e) | ||
self.fail(msg="unexpected error getting default service account") | ||
print('default service not found yet: %s' % e) | ||
time.sleep(1) | ||
continue | ||
self.assertEqual('default', resp.metadata.name) | ||
break | ||
|
||
resp = api.create_namespaced_pod(body=pod_manifest, | ||
namespace='default') | ||
self.assertEqual(name, resp.metadata.name) | ||
|
@@ -130,6 +158,28 @@ def test_exit_code(self): | |
|
||
name = 'busybox-test-' + short_uuid() | ||
pod_manifest = manifest_with_command(name, "while true;do date;sleep 5; done") | ||
|
||
# wait for the default service account to be created | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
timeout = time.time() + 30 | ||
while True: | ||
if time.time() > timeout: | ||
print('timeout waiting for default service account creation') | ||
break | ||
|
||
try: | ||
resp = api.read_namespaced_service_account(name='default', | ||
namespace='default') | ||
except ApiException as e: | ||
if (six.PY3 and e.status != HTTPStatus.NOT_FOUND) or ( | ||
six.PY3 is False and e.status != httplib.NOT_FOUND): | ||
print('error: %s' % e) | ||
self.fail(msg="unexpected error getting default service account") | ||
print('default service not found yet: %s' % e) | ||
time.sleep(1) | ||
continue | ||
self.assertEqual('default', resp.metadata.name) | ||
break | ||
|
||
resp = api.create_namespaced_pod(body=pod_manifest, | ||
namespace='default') | ||
self.assertEqual(name, resp.metadata.name) | ||
|
@@ -443,6 +493,7 @@ def test_configmap_apis(self): | |
"apiVersion": "v1", | ||
"metadata": { | ||
"name": name, | ||
"labels": {"e2e-tests": "true"}, | ||
}, | ||
"data": { | ||
"config.json": "{\"command\":\"/usr/bin/mysqld_safe\"}", | ||
|
@@ -466,7 +517,7 @@ def test_configmap_apis(self): | |
resp = api.delete_namespaced_config_map( | ||
name=name, body={}, namespace='default') | ||
|
||
resp = api.list_namespaced_config_map('default', pretty=True) | ||
resp = api.list_namespaced_config_map('default', pretty=True, label_selector="e2e-tests=true") | ||
self.assertEqual([], resp.items) | ||
|
||
def test_node_apis(self): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to give a timeout than wait forever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/hold
wait for test results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold cancel
The test is green