Integration tests update

Change-Id: I9b0efe3f2e6fcb82450197d6349be30e853a55b8
This commit is contained in:
Sergiy Markin 2025-04-29 22:15:03 +00:00
parent 49a938c943
commit e31b35901d
11 changed files with 136 additions and 35 deletions

View File

@ -22,6 +22,8 @@
- airship-drydock-openstack-tox-cover-jammy - airship-drydock-openstack-tox-cover-jammy
- airship-drydock-openstack-tox-pep8-jammy - airship-drydock-openstack-tox-pep8-jammy
- airship-drydock-baclient-test - airship-drydock-baclient-test
- airship-drydock-run-test
- airship-drydock-integration-test
- airship-drydock-chart-build-gate - airship-drydock-chart-build-gate
- airship-drydock-chart-build-latest-htk - airship-drydock-chart-build-latest-htk
- airship-drydock-docker-build-gate-ubuntu_jammy - airship-drydock-docker-build-gate-ubuntu_jammy
@ -32,6 +34,8 @@
- airship-drydock-openstack-tox-cover-jammy - airship-drydock-openstack-tox-cover-jammy
- airship-drydock-openstack-tox-pep8-jammy - airship-drydock-openstack-tox-pep8-jammy
- airship-drydock-baclient-test - airship-drydock-baclient-test
- airship-drydock-run-test
- airship-drydock-integration-test
- airship-drydock-chart-build-gate - airship-drydock-chart-build-gate
- airship-drydock-docker-build-gate-ubuntu_jammy - airship-drydock-docker-build-gate-ubuntu_jammy
@ -58,13 +62,16 @@
description: Runs cover job on jammy description: Runs cover job on jammy
nodeset: airship-drydock-single-node-jammy nodeset: airship-drydock-single-node-jammy
pre-run: tools/gate/playbooks/install-docker.yaml pre-run: tools/gate/playbooks/install-docker.yaml
vars:
tox_environment:
DISTRO: ubuntu_jammy
- job: - job:
name: airship-drydock-openstack-tox-pep8-jammy name: airship-drydock-openstack-tox-pep8-jammy
parent: openstack-tox-pep8 parent: openstack-tox-pep8
description: Runs pep8 job on jammy description: Runs pep8 job on jammy
nodeset: airship-drydock-single-node-jammy nodeset: airship-drydock-single-node-jammy
pre-run: tools/gate/playbooks/install-docker.yaml
- job: - job:
name: airship-drydock-baclient-test name: airship-drydock-baclient-test
@ -73,6 +80,29 @@
run: tools/gate/playbooks/baclient_test.yaml run: tools/gate/playbooks/baclient_test.yaml
timeout: 3600 timeout: 3600
nodeset: airship-drydock-single-node-jammy nodeset: airship-drydock-single-node-jammy
pre-run: tools/gate/playbooks/install-docker.yaml
- job:
name: airship-drydock-run-test
description: |
Run a bootaction drydock client test
run: tools/gate/playbooks/run_drydock.yaml
timeout: 3600
nodeset: airship-drydock-single-node-jammy
pre-run: tools/gate/playbooks/install-docker.yaml
vars:
distro: ubuntu_jammy
- job:
name: airship-drydock-integration-test
description: |
Run a bootaction drydock client test
run: tools/gate/playbooks/integration_test.yaml
timeout: 3600
nodeset: airship-drydock-single-node-jammy
pre-run: tools/gate/playbooks/install-docker.yaml
vars:
distro: ubuntu_jammy
- job: - job:
name: airship-drydock-chart-build-gate name: airship-drydock-chart-build-gate

View File

@ -48,7 +48,7 @@ coverage_test: build_drydock
# Run just unit tests # Run just unit tests
unit_tests: unit_tests:
tox -re py38 $(TESTS) tox -re py310 $(TESTS)
# Run just DB integration tests # Run just DB integration tests
db_integration_tests: db_integration_tests:

View File

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
set -x set -x
env
echo "DISTRO is set to: $DISTRO"
DOCKER_REGISTRY=${DOCKER_REGISTRY:-"quay.io"} DOCKER_REGISTRY=${DOCKER_REGISTRY:-"quay.io"}
IMAGE_PREFIX=${IMAGE_PREFIX:-"airshipit"} IMAGE_PREFIX=${IMAGE_PREFIX:-"airshipit"}
IMAGE_NAME=${IMAGE_NAME:-"drydock"} IMAGE_NAME=${IMAGE_NAME:-"drydock"}
IMAGE_TAG=${IMAGE_TAG:-"latest"} IMAGE_TAG=${IMAGE_TAG:-"latest"}
DISTRO=${DISTRO:-"ubuntu_focal"} DISTRO=${DISTRO:-"ubuntu_jammy"}
IMAGE="${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO}" IMAGE="${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO}"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Install golang-go package, and build the baclient library # Install golang-go package, and build the baclient library
set -x set -ex
if $(uname -a | grep -q Ubuntu); then if $(uname -a | grep -q Ubuntu); then
GOPATH=$1 GOPATH=$1

View File

@ -10,6 +10,11 @@ function start_db {
then then
sudo docker stop "${PSQL_CONTAINER_NAME}" sudo docker stop "${PSQL_CONTAINER_NAME}"
fi fi
if [[ ! -z $(docker ps | grep "${DRYDOCK_CONTAINER_NAME}" ) ]]
then
sudo docker stop "${DRYDOCK_CONTAINER_NAME}"
fi
docker run --rm -dp 5432:5432 --name "${PSQL_CONTAINER_NAME}" -e POSTGRES_HOST_AUTH_METHOD=trust quay.io/airshipit/postgres:14.8 docker run --rm -dp 5432:5432 --name "${PSQL_CONTAINER_NAME}" -e POSTGRES_HOST_AUTH_METHOD=trust quay.io/airshipit/postgres:14.8
sleep 15 sleep 15
@ -49,6 +54,7 @@ function init_db {
function test_drydock { function test_drydock {
TMPETC=$1 TMPETC=$1
docker run \ docker run \
--rm \
-d --name "${DRYDOCK_CONTAINER_NAME}" --net host \ -d --name "${DRYDOCK_CONTAINER_NAME}" --net host \
-v ${TMPETC}:/etc/drydock \ -v ${TMPETC}:/etc/drydock \
${IMAGE} ${IMAGE}
@ -78,7 +84,6 @@ function cleanup {
TMPDIR=$1 TMPDIR=$1
docker stop "${PSQL_CONTAINER_NAME}" docker stop "${PSQL_CONTAINER_NAME}"
docker stop "${DRYDOCK_CONTAINER_NAME}" docker stop "${DRYDOCK_CONTAINER_NAME}"
docker rm "${DRYDOCK_CONTAINER_NAME}"
rm -rf $TMPDIR rm -rf $TMPDIR
} }

View File

@ -14,22 +14,10 @@
# to minimize Zuul node consumption # to minimize Zuul node consumption
- hosts: primary - hosts: primary
roles:
- bindep
- ensure-docker
- ensure-python
- ensure-pip
- ensure-tox
tasks: tasks:
- name: Execute Go tests for baclient - name: Execute Go tests for baclient
make: shell: |
make test_baclient
args:
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
target: test_baclient
become: true
register: result

View File

@ -61,15 +61,6 @@
executable: pip3 executable: pip3
become: True become: True
- name: Run images
shell: |
make run_images
args:
chdir: "{{ zuul.project.src_dir }}"
executable: /bin/bash
become: True
- name: Make images - name: Make images
when: not publish when: not publish
block: block:

View File

@ -18,11 +18,22 @@
- bindep - bindep
- clear-firewall - clear-firewall
- ensure-docker - ensure-docker
- ensure-python
- ensure-pip
- ensure-tox
tasks: tasks:
- name: Install tox python module
block:
- pip:
name: tox
executable: pip3
become: True
- name: Build images - name: Build images
shell: | shell: |
make images make images
args: args:
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
executable: /bin/bash executable: /bin/bash
become: True

View File

@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# Combine several test tasks into a single playbook
# to minimize Zuul node consumption
- hosts: primary
tasks:
- name: Execute the make target for running the Drydock Docker image
shell: |
#/bin/bash
set -ex
make db_integration_tests
args:
chdir: "{{ zuul.project.src_dir }}"
become: true

View File

@ -0,0 +1,26 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# Combine several test tasks into a single playbook
# to minimize Zuul node consumption
- hosts: primary
tasks:
- name: Execute the make target for running the Drydock Docker image
shell: |
#/bin/bash
set -ex
make run_drydock
args:
chdir: "{{ zuul.project.src_dir }}"
become: true

33
tox.ini
View File

@ -5,7 +5,18 @@ minversion = 3.28.0
[testenv] [testenv]
setenv = YAMLDIR = {toxinidir}/python/tests/yaml_samples/ setenv = YAMLDIR = {toxinidir}/python/tests/yaml_samples/
passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY passenv =
http_proxy
HTTP_PROXY
https_proxy
HTTPS_PROXY
no_proxy
NO_PROXY
DOCKER_REGISTRY
IMAGE_NAME
IMAGE_PREFIX
IMAGE_TAG
DISTRO
deps= deps=
-r{toxinidir}/python/requirements-frozen.txt -r{toxinidir}/python/requirements-frozen.txt
-r{toxinidir}/python/test-requirements.txt -r{toxinidir}/python/test-requirements.txt
@ -47,7 +58,12 @@ commands=
{toxinidir}/python/tests/unit/{posargs} {toxinidir}/python/tests/unit/{posargs}
[testenv:integration] [testenv:integration]
passenv=DOCKER_REGISTRY,IMAGE_NAME,IMAGE_PREFIX,IMAGE_TAG,DISTRO passenv =
DOCKER_REGISTRY
IMAGE_NAME
IMAGE_PREFIX
IMAGE_TAG
DISTRO
setenv= setenv=
PYTHONWARNING=all PYTHONWARNING=all
YAMLDIR={toxinidir}/python/tests/yaml_samples/ YAMLDIR={toxinidir}/python/tests/yaml_samples/
@ -63,12 +79,19 @@ commands=
[testenv:cover] [testenv:cover]
usedevelop=True usedevelop=True
passenv=DOCKER_REGISTRY,IMAGE_NAME,IMAGE_PREFIX,IMAGE_TAG,DISTRO passenv =
DOCKER_REGISTRY
IMAGE_NAME
IMAGE_PREFIX
IMAGE_TAG
DISTRO
setenv= setenv=
YAMLDIR={toxinidir}/python/tests/yaml_samples/ YAMLDIR={toxinidir}/python/tests/yaml_samples/
allowlist_externals= allowlist_externals=
sh sh
env
commands= commands=
env
sh -c {toxinidir}/python/tests/postgres/start_postgres.sh sh -c {toxinidir}/python/tests/postgres/start_postgres.sh
py.test \ py.test \
--cov=drydock_provisioner \ --cov=drydock_provisioner \
@ -99,10 +122,10 @@ commands =
[testenv:pep8] [testenv:pep8]
commands = commands =
flake8 {posargs} flake8 {posargs}
bandit -r drydock_provisioner -n 5 bandit -r ./python/drydock_provisioner -n 5 --skip B303
[testenv:bandit] [testenv:bandit]
commands = bandit -r drydock_provisioner -n 5 commands = bandit -r ./python/drydock_provisioner -n 5 --skip B303
[flake8] [flake8]
ignore=E302,H306,H304,W503,E251,E126 ignore=E302,H306,H304,W503,E251,E126