From ab589c3bafa3d8ac2feca3a11d4d9a5a0728e960 Mon Sep 17 00:00:00 2001 From: Joseph Kim Date: Fri, 29 Apr 2022 14:31:36 -0400 Subject: [PATCH 1/2] Add integration tests with odo v2.5.1 Signed-off-by: Joseph Kim --- .github/workflows/pytest.yaml | 52 +++++++ .github/workflows/pytest_odo.250.yaml | 12 +- .github/workflows/pytest_odo.251.yaml | 68 ++++++++++ tests/odo/test_create_cmd.py | 8 +- tests/odo/test_push_cmd.py | 2 +- tests/odo/test_url_cmd.py | 17 +-- tests/odo_300/test_delete_cmd.py | 188 ++++++++++++++++++++++++++ 7 files changed, 331 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/pytest.yaml create mode 100644 .github/workflows/pytest_odo.251.yaml create mode 100644 tests/odo_300/test_delete_cmd.py diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml new file mode 100644 index 0000000..d7a859f --- /dev/null +++ b/.github/workflows/pytest.yaml @@ -0,0 +1,52 @@ +# Copyright (c) 2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +name: Devfile integration tests (latest Odo release) + +on: +# NOTE: Currently disabled + push: +# branches: [ main ] + pull_request: +# branches: [ main ] +# schedule: +# # every day at 9am EST +# - cron: 0 1 * * * + +jobs: + test_with_minikube: + name: Run tests + strategy: + matrix: + os: [ ubuntu-latest, macos-10.15 ] + runs-on: ${{ matrix.os }} + continue-on-error: true + timeout-minutes: 20 + + steps: + - name: Check out repository code + uses: actions/checkout@v2 + + - name: Start minikube + uses: medyagh/setup-minikube@latest + + - name: Install ODO + uses: redhat-actions/openshift-tools-installer@v1 + with: + # Installs the latest release of odo + odo: "latest" + + # Setup Python + - name: Install Python, pipenv and Pipfile packages + uses: palewire/install-python-pipenv-pipfile@v2 + with: + python-version: "3.9.10" + + - name: Run test with pipenv and pytest + run: | + odo version + pipenv run pytest tests/odo -v diff --git a/.github/workflows/pytest_odo.250.yaml b/.github/workflows/pytest_odo.250.yaml index fcb9ec5..c926f23 100644 --- a/.github/workflows/pytest_odo.250.yaml +++ b/.github/workflows/pytest_odo.250.yaml @@ -8,13 +8,14 @@ name: Devfile integration tests (Odo v2.5.0 release) on: +# NOTE: Currently disabled push: - branches: [ main ] +# branches: [ main ] pull_request: - branches: [ main ] - schedule: - # every day at 9am EST - - cron: 0 1 * * * +# branches: [ main ] +# schedule: +# # every day at 9am EST +# - cron: 0 1 * * * jobs: test_with_minikube: @@ -49,4 +50,3 @@ jobs: run: | odo version pipenv run pytest tests/odo -v - diff --git a/.github/workflows/pytest_odo.251.yaml b/.github/workflows/pytest_odo.251.yaml new file mode 100644 index 0000000..477d31a --- /dev/null +++ b/.github/workflows/pytest_odo.251.yaml @@ -0,0 +1,68 @@ +# Copyright (c) 2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +name: Devfile integration tests (Odo v2.5.1 release) + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + schedule: + # every day at 9am EST + - cron: 0 1 * * * + +jobs: + test_with_minikube: + name: Run tests + strategy: + matrix: + os: [ ubuntu-latest, macos-10.15 ] + runs-on: ${{ matrix.os }} + continue-on-error: true + timeout-minutes: 20 + + steps: + - name: Check out repository code + uses: actions/checkout@v2 + + - name: Check out the latest odo repository code + uses: actions/checkout@v2 + with: + repository: redhat-developer/odo + ref: v2.5.1 + path: odo + + - name: Start minikube + uses: medyagh/setup-minikube@latest + + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '1.16.1' + - run: go version + + # Build and installs odo from source code + - name: Build and Install ODO + run: | + cd odo + make goget-tools + make bin + mv ./odo /usr/local/bin/odo + cd .. + rm -rf odo + + # Setup Python + - name: Install Python, pipenv and Pipfile packages + uses: palewire/install-python-pipenv-pipfile@v2 + with: + python-version: "3.9.10" + + - name: Run test with pipenv and pytest + run: | + odo version + pipenv run pytest tests/odo -v diff --git a/tests/odo/test_create_cmd.py b/tests/odo/test_create_cmd.py index b9194b3..4bf957d 100644 --- a/tests/odo/test_create_cmd.py +++ b/tests/odo/test_create_cmd.py @@ -1,5 +1,6 @@ import tempfile import jmespath +import time from utils.config import * from utils.util import * @@ -59,9 +60,14 @@ def test_create_component_with_project_flag(self): os.chdir(tmp_workspace) component_namespace = random_string() subprocess.run(["odo", "create", "java-openliberty", "--project", component_namespace]) + time.sleep(5) envfile_path = os.path.abspath(os.path.join(tmp_workspace, '.odo/env/env.yaml')) - assert query_yaml(envfile_path, "ComponentSettings", "Project", -1) == component_namespace + + if os.path.isfile(envfile_path): + assert query_yaml(envfile_path, "ComponentSettings", "Project", -1) == component_namespace + else: + raise ValueError("Failed: %s is not created yet." % file_path) def test_create_with_context_flag(self): diff --git a/tests/odo/test_push_cmd.py b/tests/odo/test_push_cmd.py index 99fe272..139d554 100644 --- a/tests/odo/test_push_cmd.py +++ b/tests/odo/test_push_cmd.py @@ -44,7 +44,7 @@ def test_push_with_devfile(self): # MacOS: reuse the existing kubectl inside minikube result = subprocess.run( ["minikube", "kubectl", "--", "get", "deployment", - "-o", "jsonpath='{.items[0].spec.template.spec.containers[0].ports[?(@.name=='3000-tcp')].containerPort}'"], + "-o", "jsonpath='{.items[0].spec.template.spec.containers[0].ports[?(@.name=='http-3000')].containerPort}'"], capture_output=True, text=True, check=True) assert contains(result.stdout, "3000") diff --git a/tests/odo/test_url_cmd.py b/tests/odo/test_url_cmd.py index 7d8027e..34de693 100644 --- a/tests/odo/test_url_cmd.py +++ b/tests/odo/test_url_cmd.py @@ -10,7 +10,8 @@ class TestUrlCmd: CONTAINER_NAME = "test-container" CONTEXT = "test-context" HOST = "test.host.com" - PORT_1 = "3000" + PORT = "3000" + PORT_1 = "3001" PORT_2 = "5000" ENDPOINT_1 = "url-1" ENDPOINT_2 = "url-2" @@ -50,15 +51,15 @@ def test_url_duplicate_name_port(self): "--host", self.HOST, "--secure", "--ingress"], capture_output=True, text=True, check=False) assert contains(result.stderr, - "url {} already exist in devfile endpoint entry under container runtime".format(self.ENDPOINT)) + "url {} already exists in devfile endpoint entry under container".format(self.ENDPOINT)) # should not allow to create URL with duplicate port - result = subprocess.run(["odo", "url", "create", self.ENDPOINT_1, "--port", self.PORT_1, + result = subprocess.run(["odo", "url", "create", self.ENDPOINT_1, "--port", self.PORT, "--host", self.HOST, "--secure", "--ingress"], capture_output=True, text=True, check=False) - # Todo: potential bug - it's not blocked by the odo used in the test. Need to verify if it's fixed in more recent release - # assert contains(result.stdout, "port 3000 already exists in devfile endpoint entry") + assert contains(result.stderr, "URL creation failed") + assert contains(result.stderr, "port {} already exists in devfile endpoint entry".format(self.PORT)) def test_url_invalid_container(self): print("Test case : should not allow creating under an invalid container") @@ -141,7 +142,7 @@ def test_url_create_multiple_endpoints(self): "--host", self.HOST, "--secure", "--ingress"]) list_components_after_url1 = [ - self.ENDPOINT, + "nodejs-" + self.PORT_1, self.PORT_1, "Not Pushed", "true", @@ -184,6 +185,6 @@ def test_url_create_multiple_endpoints(self): capture_output=True, text=True, check=True) result = subprocess.run(["odo", "url", "list"], - capture_output=True, text=True, check=False) + capture_output=True, text=True, check=True) - assert contains(result.stderr, "no URLs found for component nodejs") + assert contains(result.stdout, self.ENDPOINT_2) == False diff --git a/tests/odo_300/test_delete_cmd.py b/tests/odo_300/test_delete_cmd.py new file mode 100644 index 0000000..7a9b4e0 --- /dev/null +++ b/tests/odo_300/test_delete_cmd.py @@ -0,0 +1,188 @@ +import sys +import tempfile +from utils.config import * +from utils.util import * + +@pytest.mark.usefixtures("use_test_registry_v300") +class TestDeleteCmd: + + CONTEXT = "test-context" + COMPONENT = "acomponent" + PROJECT = "intg-test-project" + + tmp_project_name = None + + @classmethod + def setup_class(cls): + # Runs once per class + cls.tmp_project_name = create_test_project() + + @classmethod + def teardown_class(cls): + '''Runs at end of class''' + subprocess.run(["odo", "project", "delete", cls.tmp_project_name, "-f", "-w"]) + + def test_delete(self): + print("Test case : the component is deployed in DEV mode and it is deleted using its name and namespace") + + with tempfile.TemporaryDirectory() as tmp_workspace: + os.chdir(tmp_workspace) + + # get test devfile path + source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") + copy_example("nodejs/project", tmp_workspace, self.CONTEXT) + + os.environ['PODMAN_CMD'] = "echo" + os.chdir(self.CONTEXT) + + result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], + capture_output=True, text=True, check=True) + + assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) + + cmd_odo_dev = str('odo dev --random-ports') + + try: + # starting dev mode with random ports should work + cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) + # sleep until odo dev is started + time.sleep(3) + result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], + capture_output=True, text=True, check=True) + + list_expected = [ + self.COMPONENT + "-app", + "NAME", + "AVAILABLE", + ] + assert match_all(result.stdout, list_expected) + + result = subprocess.run(["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], + capture_output=True, text=True, check=True) + str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) + + assert contains(result.stdout, str_deleted) + cmd_proc.terminate() + + except Exception as e: + raise e + + def test_delete_from_other_directory(self): + print("Test case : the component is deployed in DEV mode and it is deleted using its name and namespace from another directory") + + with tempfile.TemporaryDirectory() as tmp_workspace: + os.chdir(tmp_workspace) + + # get test devfile path + source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") + copy_example("nodejs/project", tmp_workspace, self.CONTEXT) + + os.environ['PODMAN_CMD'] = "echo" + os.chdir(self.CONTEXT) + + # should work without --starter flag + result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], + capture_output=True, text=True, check=True) + + assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) + + cmd_odo_dev = str('odo dev --random-ports') + + try: + # starting dev mode with random ports should work + cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) + # sleep while odo dev is started + time.sleep(3) + result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], + capture_output=True, text=True, check=True) + + list_expected = [ + self.COMPONENT + "-app", + "NAME", + "AVAILABLE", + ] + assert match_all(result.stdout, list_expected) + + os.chdir(tmp_workspace) + os.mkdir("test-dir") + os.chdir("test-dir") + result = subprocess.run(["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], + capture_output=True, text=True, check=True) + str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) + + assert contains(result.stdout, str_deleted) + + result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], + capture_output=True, text=True, check=True) + + assert not contains(result.stdout, self.COMPONENT + "-app") + assert contains(result.stderr, "No resources found in " + self.PROJECT + " namespace.") + + # run delete command again after deletion + result = subprocess.run( + ["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], + capture_output=True, text=True, check=True) + str_no_resource_found = "No resource found for component \"{}\" in namespace \"{}\"".format(self.COMPONENT, self.PROJECT) + assert contains(result.stdout, str_no_resource_found) + + cmd_proc.terminate() + except Exception as e: + raise e + + def test_delete_with_devfile_present(self): + print("Test case : the component is deployed in DEV mode and it is deleted when devfile present") + + with tempfile.TemporaryDirectory() as tmp_workspace: + os.chdir(tmp_workspace) + + # get test devfile path + source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") + copy_example("nodejs/project", tmp_workspace, self.CONTEXT) + + os.environ['PODMAN_CMD'] = "echo" + os.chdir(self.CONTEXT) + + # should work without --starter flag + result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], + capture_output=True, text=True, check=True) + + assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) + + cmd_odo_dev = str('odo dev --random-ports') + + try: + # starting dev mode with random ports should work + cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) + # sleep while odo dev is started + time.sleep(3) + result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], + capture_output=True, text=True, check=True) + + list_expected = [ + self.COMPONENT + "-app", + "NAME", + "AVAILABLE", + ] + assert match_all(result.stdout, list_expected) + + str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) + result = subprocess.run(["odo", "delete", "component", "-f"], + capture_output=True, text=True, check=True) + + assert contains(result.stdout, str_deleted) + + result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], + capture_output=True, text=True, check=True) + + assert not contains(result.stdout, self.COMPONENT + "-app") + assert contains(result.stderr, "No resources found in " + self.PROJECT + " namespace.") + + # run delete command again after deletion + result = subprocess.run(["odo", "delete", "component", "-f"], + capture_output=True, text=True, check=True) + str_no_resource_found = "No resource found for component \"{}\" in namespace \"{}\"".format(self.COMPONENT, self.PROJECT) + assert contains(result.stdout, str_no_resource_found) + + cmd_proc.terminate() + except Exception as e: + raise e From 7106656637ee9bd74b74539a2af97a53156a8e81 Mon Sep 17 00:00:00 2001 From: Joseph Kim Date: Fri, 29 Apr 2022 14:49:25 -0400 Subject: [PATCH 2/2] Add integration tests with odo v2.5.1 Signed-off-by: Joseph Kim --- .../{pytest.yaml => pytest.yaml.disabled} | 11 +- ....250.yaml => pytest_odo.250.yaml.disabled} | 11 +- tests/odo_300/test_delete_cmd.py | 188 ------------------ 3 files changed, 10 insertions(+), 200 deletions(-) rename .github/workflows/{pytest.yaml => pytest.yaml.disabled} (89%) rename .github/workflows/{pytest_odo.250.yaml => pytest_odo.250.yaml.disabled} (89%) delete mode 100644 tests/odo_300/test_delete_cmd.py diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml.disabled similarity index 89% rename from .github/workflows/pytest.yaml rename to .github/workflows/pytest.yaml.disabled index d7a859f..8815cc9 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml.disabled @@ -8,14 +8,13 @@ name: Devfile integration tests (latest Odo release) on: -# NOTE: Currently disabled push: -# branches: [ main ] + branches: [ main ] pull_request: -# branches: [ main ] -# schedule: -# # every day at 9am EST -# - cron: 0 1 * * * + branches: [ main ] + schedule: + # every day at 9am EST + - cron: 0 1 * * * jobs: test_with_minikube: diff --git a/.github/workflows/pytest_odo.250.yaml b/.github/workflows/pytest_odo.250.yaml.disabled similarity index 89% rename from .github/workflows/pytest_odo.250.yaml rename to .github/workflows/pytest_odo.250.yaml.disabled index c926f23..3f770e5 100644 --- a/.github/workflows/pytest_odo.250.yaml +++ b/.github/workflows/pytest_odo.250.yaml.disabled @@ -8,14 +8,13 @@ name: Devfile integration tests (Odo v2.5.0 release) on: -# NOTE: Currently disabled push: -# branches: [ main ] + branches: [ main ] pull_request: -# branches: [ main ] -# schedule: -# # every day at 9am EST -# - cron: 0 1 * * * + branches: [ main ] + schedule: + # every day at 9am EST + - cron: 0 1 * * * jobs: test_with_minikube: diff --git a/tests/odo_300/test_delete_cmd.py b/tests/odo_300/test_delete_cmd.py deleted file mode 100644 index 7a9b4e0..0000000 --- a/tests/odo_300/test_delete_cmd.py +++ /dev/null @@ -1,188 +0,0 @@ -import sys -import tempfile -from utils.config import * -from utils.util import * - -@pytest.mark.usefixtures("use_test_registry_v300") -class TestDeleteCmd: - - CONTEXT = "test-context" - COMPONENT = "acomponent" - PROJECT = "intg-test-project" - - tmp_project_name = None - - @classmethod - def setup_class(cls): - # Runs once per class - cls.tmp_project_name = create_test_project() - - @classmethod - def teardown_class(cls): - '''Runs at end of class''' - subprocess.run(["odo", "project", "delete", cls.tmp_project_name, "-f", "-w"]) - - def test_delete(self): - print("Test case : the component is deployed in DEV mode and it is deleted using its name and namespace") - - with tempfile.TemporaryDirectory() as tmp_workspace: - os.chdir(tmp_workspace) - - # get test devfile path - source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") - copy_example("nodejs/project", tmp_workspace, self.CONTEXT) - - os.environ['PODMAN_CMD'] = "echo" - os.chdir(self.CONTEXT) - - result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], - capture_output=True, text=True, check=True) - - assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) - - cmd_odo_dev = str('odo dev --random-ports') - - try: - # starting dev mode with random ports should work - cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) - # sleep until odo dev is started - time.sleep(3) - result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], - capture_output=True, text=True, check=True) - - list_expected = [ - self.COMPONENT + "-app", - "NAME", - "AVAILABLE", - ] - assert match_all(result.stdout, list_expected) - - result = subprocess.run(["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], - capture_output=True, text=True, check=True) - str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) - - assert contains(result.stdout, str_deleted) - cmd_proc.terminate() - - except Exception as e: - raise e - - def test_delete_from_other_directory(self): - print("Test case : the component is deployed in DEV mode and it is deleted using its name and namespace from another directory") - - with tempfile.TemporaryDirectory() as tmp_workspace: - os.chdir(tmp_workspace) - - # get test devfile path - source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") - copy_example("nodejs/project", tmp_workspace, self.CONTEXT) - - os.environ['PODMAN_CMD'] = "echo" - os.chdir(self.CONTEXT) - - # should work without --starter flag - result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], - capture_output=True, text=True, check=True) - - assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) - - cmd_odo_dev = str('odo dev --random-ports') - - try: - # starting dev mode with random ports should work - cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) - # sleep while odo dev is started - time.sleep(3) - result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], - capture_output=True, text=True, check=True) - - list_expected = [ - self.COMPONENT + "-app", - "NAME", - "AVAILABLE", - ] - assert match_all(result.stdout, list_expected) - - os.chdir(tmp_workspace) - os.mkdir("test-dir") - os.chdir("test-dir") - result = subprocess.run(["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], - capture_output=True, text=True, check=True) - str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) - - assert contains(result.stdout, str_deleted) - - result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], - capture_output=True, text=True, check=True) - - assert not contains(result.stdout, self.COMPONENT + "-app") - assert contains(result.stderr, "No resources found in " + self.PROJECT + " namespace.") - - # run delete command again after deletion - result = subprocess.run( - ["odo", "delete", "component", "--name", self.COMPONENT, "--namespace", self.PROJECT, "-f"], - capture_output=True, text=True, check=True) - str_no_resource_found = "No resource found for component \"{}\" in namespace \"{}\"".format(self.COMPONENT, self.PROJECT) - assert contains(result.stdout, str_no_resource_found) - - cmd_proc.terminate() - except Exception as e: - raise e - - def test_delete_with_devfile_present(self): - print("Test case : the component is deployed in DEV mode and it is deleted when devfile present") - - with tempfile.TemporaryDirectory() as tmp_workspace: - os.chdir(tmp_workspace) - - # get test devfile path - source_devfile_path = get_source_devfile_path("nodejs/devfile-deploy-with-multiple-resources.yaml") - copy_example("nodejs/project", tmp_workspace, self.CONTEXT) - - os.environ['PODMAN_CMD'] = "echo" - os.chdir(self.CONTEXT) - - # should work without --starter flag - result = subprocess.run(["odo", "init", "--name", self.COMPONENT, "--devfile-path", source_devfile_path], - capture_output=True, text=True, check=True) - - assert contains(result.stdout, "Your new component '{}' is ready in the current directory.".format(self.COMPONENT)) - - cmd_odo_dev = str('odo dev --random-ports') - - try: - # starting dev mode with random ports should work - cmd_proc = subprocess.Popen(cmd_odo_dev, shell=True, bufsize=-1) - # sleep while odo dev is started - time.sleep(3) - result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], - capture_output=True, text=True, check=True) - - list_expected = [ - self.COMPONENT + "-app", - "NAME", - "AVAILABLE", - ] - assert match_all(result.stdout, list_expected) - - str_deleted = "The component \"{}\" is successfully deleted from namespace \"{}\"".format(self.COMPONENT, self.PROJECT) - result = subprocess.run(["odo", "delete", "component", "-f"], - capture_output=True, text=True, check=True) - - assert contains(result.stdout, str_deleted) - - result = subprocess.run(["minikube", "kubectl", "--", "get", "deployment", "-n", self.PROJECT], - capture_output=True, text=True, check=True) - - assert not contains(result.stdout, self.COMPONENT + "-app") - assert contains(result.stderr, "No resources found in " + self.PROJECT + " namespace.") - - # run delete command again after deletion - result = subprocess.run(["odo", "delete", "component", "-f"], - capture_output=True, text=True, check=True) - str_no_resource_found = "No resource found for component \"{}\" in namespace \"{}\"".format(self.COMPONENT, self.PROJECT) - assert contains(result.stdout, str_no_resource_found) - - cmd_proc.terminate() - except Exception as e: - raise e