-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Delete all containers and pods between tests #9699
Merged
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 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
This file contains 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 |
---|---|---|
|
@@ -50,23 +50,20 @@ class TestApi(unittest.TestCase): | |
def setUp(self): | ||
super().setUp() | ||
|
||
try: | ||
TestApi.podman.run("run", "alpine", "/bin/ls", check=True) | ||
except subprocess.CalledProcessError as e: | ||
if e.stdout: | ||
sys.stdout.write("\nRun Stdout:\n" + e.stdout.decode("utf-8")) | ||
if e.stderr: | ||
sys.stderr.write("\nRun Stderr:\n" + e.stderr.decode("utf-8")) | ||
raise | ||
TestApi.podman.run("run", "alpine", "/bin/ls", check=True) | ||
|
||
def tearDown(self) -> None: | ||
super().tearDown() | ||
|
||
TestApi.podman.run("pod", "rm", "--all", "--force", check=True) | ||
TestApi.podman.run("rm", "--all", "--force", check=True) | ||
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. Yeah, this is totally fine. Crap can get left behind for any number of reasons, not all should cause test failures. The time spent doing this will more than outweigh the aggravation and time of re-running the test b/c of flakes. |
||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
TestApi.podman = Podman() | ||
TestApi.service = TestApi.podman.open( | ||
"system", "service", "tcp:localhost:8080", "--time=0" | ||
) | ||
TestApi.service = TestApi.podman.open("system", "service", "tcp:localhost:8080", "--time=0") | ||
# give the service some time to be ready... | ||
time.sleep(2) | ||
|
||
|
@@ -243,9 +240,7 @@ def test_post_create_compat_connect(self): | |
|
||
def test_post_create_compat(self): | ||
"""Create network and connect container during create""" | ||
net = requests.post( | ||
PODMAN_URL + "/v1.40/networks/create", json={"Name": "TestNetwork"} | ||
) | ||
net = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": "TestNetwork"}) | ||
self.assertEqual(net.status_code, 201, net.text) | ||
|
||
create = requests.post( | ||
|
@@ -454,15 +449,11 @@ def test_history_compat(self): | |
self.assertIn(k, o) | ||
|
||
def test_network_compat(self): | ||
name = "Network_" + "".join( | ||
random.choice(string.ascii_letters) for i in range(10) | ||
) | ||
name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) | ||
|
||
# Cannot test for 0 existing networks because default "podman" network always exists | ||
|
||
create = requests.post( | ||
PODMAN_URL + "/v1.40/networks/create", json={"Name": name} | ||
) | ||
create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": name}) | ||
self.assertEqual(create.status_code, 201, create.content) | ||
obj = json.loads(create.content) | ||
self.assertIn(type(obj), (dict,)) | ||
|
@@ -492,9 +483,7 @@ def test_network_compat(self): | |
self.assertEqual(inspect.status_code, 404, inspect.content) | ||
|
||
# network prune | ||
prune_name = "Network_" + "".join( | ||
random.choice(string.ascii_letters) for i in range(10) | ||
) | ||
prune_name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) | ||
prune_create = requests.post( | ||
PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name} | ||
) | ||
|
@@ -506,9 +495,7 @@ def test_network_compat(self): | |
self.assertTrue(prune_name in obj["NetworksDeleted"]) | ||
|
||
def test_volumes_compat(self): | ||
name = "Volume_" + "".join( | ||
random.choice(string.ascii_letters) for i in range(10) | ||
) | ||
name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10)) | ||
|
||
ls = requests.get(PODMAN_URL + "/v1.40/volumes") | ||
self.assertEqual(ls.status_code, 200, ls.content) | ||
|
@@ -524,9 +511,7 @@ def test_volumes_compat(self): | |
for k in required_keys: | ||
self.assertIn(k, obj) | ||
|
||
create = requests.post( | ||
PODMAN_URL + "/v1.40/volumes/create", json={"Name": name} | ||
) | ||
create = requests.post(PODMAN_URL + "/v1.40/volumes/create", json={"Name": name}) | ||
self.assertEqual(create.status_code, 201, create.content) | ||
|
||
# See https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate | ||
|
@@ -703,21 +688,15 @@ def test_pod_start_conflict(self): | |
"""Verify issue #8865""" | ||
|
||
pod_name = list() | ||
pod_name.append( | ||
"Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)) | ||
) | ||
pod_name.append( | ||
"Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)) | ||
) | ||
pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10))) | ||
pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10))) | ||
|
||
r = requests.post( | ||
_url("/pods/create"), | ||
json={ | ||
"name": pod_name[0], | ||
"no_infra": False, | ||
"portmappings": [ | ||
{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89} | ||
], | ||
"portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}], | ||
}, | ||
) | ||
self.assertEqual(r.status_code, 201, r.text) | ||
|
@@ -736,9 +715,7 @@ def test_pod_start_conflict(self): | |
json={ | ||
"name": pod_name[1], | ||
"no_infra": False, | ||
"portmappings": [ | ||
{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89} | ||
], | ||
"portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}], | ||
}, | ||
) | ||
self.assertEqual(r.status_code, 201, r.text) | ||
|
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.
Oh yeah that will be helpful, thanks!