Skip to content

Commit

Permalink
Merge pull request #30 from validatedpatterns/run_tests
Browse files Browse the repository at this point in the history
Updates to include vp-qe-test-common code and non-pipeline CI runner
  • Loading branch information
mlabonte-rh authored Aug 15, 2024
2 parents efafd84 + d31596c commit 224e2c6
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 732 deletions.
19 changes: 19 additions & 0 deletions tests/interop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Running tests

## Steps

* install oc client at ~/oc_client/oc
* create python3 venv, clone patterns repository
* export KUBECONFIG=\<path to hub kubeconfig file>
* export KUBECONFIG_EDGE=\<path to edge kubeconfig file>
* export INFRA_PROVIDER=\<infra platform description>
* (optional) export WORKSPACE=\<dir to save test results to> (defaults to /tmp)
* cd \<pattern dir>/tests/interop
* pip install -r requirements.txt
* ./run_tests.sh

## Results

* results .xml files will be placed at $WORKSPACE
* test logs will be placed at $WORKSPACE/.results/test_execution_logs/
* CI badge file will be placed at $WORKSPACE
53 changes: 2 additions & 51 deletions tests/interop/conftest.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,2 @@
import os

import pytest
from kubernetes import config
from kubernetes.client import Configuration
from openshift.dynamic import DynamicClient

from . import __loggername__
from .css_logger import CSS_Logger


def pytest_addoption(parser):
parser.addoption(
"--kubeconfig",
action="store",
default=None,
help="The full path to the kubeconfig file to be used",
)


@pytest.fixture(scope="session")
def get_kubeconfig(request):
if request.config.getoption("--kubeconfig"):
k8config = request.config.getoption("--kubeconfig")
elif "KUBECONFIG" in os.environ.keys() and os.environ["KUBECONFIG"]:
k8config = os.environ["KUBECONFIG"]
else:
raise ValueError(
"A kubeconfig file was not provided. Please provide one either "
"via the --kubeconfig command option or by setting a KUBECONFIG "
"environment variable"
)
return k8config


@pytest.fixture(scope="session")
def kube_config(get_kubeconfig):
kc = Configuration
config.load_kube_config(config_file=get_kubeconfig, client_configuration=kc)
return kc


@pytest.fixture(scope="session")
def openshift_dyn_client(get_kubeconfig):
return DynamicClient(client=config.new_client_from_config(get_kubeconfig))


@pytest.fixture(scope="session", autouse=True)
def setup_logger():
logger = CSS_Logger(__loggername__)
return logger
from validatedpatterns_tests.interop.conftest_logger import * # noqa: F401, F403
from validatedpatterns_tests.interop.conftest_openshift import * # noqa: F401, F403
55 changes: 0 additions & 55 deletions tests/interop/crd.py

This file was deleted.

52 changes: 0 additions & 52 deletions tests/interop/css_logger.py

This file was deleted.

146 changes: 0 additions & 146 deletions tests/interop/edge_util.py

This file was deleted.

5 changes: 5 additions & 0 deletions tests/interop/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest
kubernetes
openshift
openshift-python-wrapper
git+https://github.com/validatedpatterns/vp-qe-test-common.git@development#egg=vp-qe-test-common
27 changes: 27 additions & 0 deletions tests/interop/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/bash

export EXTERNAL_TEST="true"

if [ -z "${KUBECONFIG}" ]; then
echo "No kubeconfig file set for hub cluster"
exit 1
fi

if [ -z "${KUBECONFIG_EDGE}" ]; then
echo "No kubeconfig file set for edge cluster"
exit 1
fi

if [ -z "${WORKSPACE}" ]; then
export WORKSPACE=/tmp
fi

pytest -lv --disable-warnings test_subscription_status_hub.py --kubeconfig $KUBECONFIG --junit-xml $WORKSPACE/test_subscription_status_hub.xml

pytest -lv --disable-warnings test_subscription_status_edge.py --kubeconfig $KUBECONFIG_EDGE --junit-xml $WORKSPACE/test_subscription_status_edge.xml

pytest -lv --disable-warnings test_validate_hub_site_components.py --kubeconfig $KUBECONFIG --junit-xml $WORKSPACE/test_validate_hub_site_components.xml

KUBECONFIG=$KUBECONFIG_EDGE pytest -lv --disable-warnings test_validate_edge_site_components.py --kubeconfig $KUBECONFIG_EDGE --junit-xml $WORKSPACE/test_validate_edge_site_components.xml

pytest -lv --disable-warnings test_validate_pipelineruns.py --kubeconfig $KUBECONFIG --junit-xml $WORKSPACE/test_validate_pipelineruns.xml
Loading

0 comments on commit 224e2c6

Please sign in to comment.