Skip to content

Add integration tests with odo v2.5.1 #66

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
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/pytest.yaml.disabled
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ jobs:
run: |
odo version
pipenv run pytest tests/odo -v

68 changes: 68 additions & 0 deletions .github/workflows/pytest_odo.251.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion tests/odo/test_create_cmd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tempfile
import jmespath
import time

from utils.config import *
from utils.util import *
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/odo/test_push_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
17 changes: 9 additions & 8 deletions tests/odo/test_url_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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