diff --git a/.github/workflows/pytest.yaml.disabled b/.github/workflows/pytest.yaml.disabled new file mode 100644 index 0000000..8815cc9 --- /dev/null +++ b/.github/workflows/pytest.yaml.disabled @@ -0,0 +1,51 @@ +# 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: + 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.disabled similarity index 99% rename from .github/workflows/pytest_odo.250.yaml rename to .github/workflows/pytest_odo.250.yaml.disabled index fcb9ec5..3f770e5 100644 --- a/.github/workflows/pytest_odo.250.yaml +++ b/.github/workflows/pytest_odo.250.yaml.disabled @@ -49,4 +49,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