WIP: k8s driver CI tests

Add functional job for cluster tests
Remove test that creates cluster with zero nodes,
it was failing for long time

Depends-On: https://review.opendev.org/c/openstack/heat/+/885725

Change-Id: I6bc2fbb78241765ac5f1c67675e152d0691b8d23
This commit is contained in:
Michal Nasiadka 2023-08-30 09:00:25 +02:00
parent 1d1dfe8c8b
commit cc2fe78333
3 changed files with 74 additions and 31 deletions

View File

@ -5,11 +5,7 @@
- tempest-plugin-jobs
check:
jobs:
- magnum-tempest-plugin-tests-api
- magnum-tempest-plugin-tests-api-2023-1
- magnum-tempest-plugin-tests-api-zed
- magnum-tempest-plugin-tests-api-yoga
- magnum-tempest-plugin-tests-api-xena
- magnum-tempest-plugin-tests-functional-k8s-fcos
gate:
jobs:
- magnum-tempest-plugin-tests-api
@ -49,7 +45,7 @@
test-config:
$TEMPEST_CONFIG:
magnum:
image_id: fedora-coreos-31.20200323.3.2-openstack.x86_64
image_id: fedora-coreos-38.20230806.3.0-openstack.x86_64
nic_id: public
keypair_id: default
flavor_id: ds2G
@ -58,6 +54,31 @@
devstack_localrc:
# NOTE: extend default glance limit from 1GB
GLANCE_LIMIT_IMAGE_SIZE_TOTAL: 5000
- job:
name: magnum-tempest-plugin-tests-functional-k8s-fcos
parent: magnum-tempest-plugin-base
nodeset: magnum-nested-virt-ubuntu-jammy
vars:
configure_swap_size: 8192
tox_envlist: all
tempest_test_regex: ^magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
magnum:
image_id: fedora-coreos-38.20230806.3.0-openstack.x86_64
nic_id: public
keypair_id: default
flavor_id: ds2G
master_flavor_id: ds2G
copy_logs: true
devstack_localrc:
# NOTE: extend default glance limit from 1GB
GLANCE_LIMIT_IMAGE_SIZE_TOTAL: 5000
LIBVIRT_TYPE: kvm
LIBVIRT_CPU_MODE: host-passthrough
zuul_copy_output:
/opt/stack/logs/cluster-nodes: logs
- job:
name: magnum-tempest-plugin-base
@ -75,8 +96,8 @@
- magnum-tempest-plugin
devstack_localrc:
USE_PYTHON3: true
MAGNUM_GUEST_IMAGE_URL: https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200323.3.2/x86_64/fedora-coreos-31.20200323.3.2-openstack.x86_64.qcow2.xz
MAGNUM_IMAGE_NAME: fedora-coreos-31.20200323.3.2-openstack.x86_64
MAGNUM_GUEST_IMAGE_URL: https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/38.20230806.3.0/x86_64/fedora-coreos-38.20230806.3.0-openstack.x86_64.qcow2.xz
MAGNUM_IMAGE_NAME: fedora-coreos-38.20230806.3.0-openstack.x86_64
devstack_plugins:
magnum: https://opendev.org/openstack/magnum
heat: https://opendev.org/openstack/heat
@ -96,3 +117,14 @@
- ^install-guide/.*$
- ^releasenotes/.*$
- ^dockerfiles/.*$
- nodeset:
name: magnum-nested-virt-ubuntu-jammy
nodes:
- name: controller
label: nested-virt-ubuntu-jammy
groups:
- name: tempest
nodes:
- controller

View File

@ -14,9 +14,11 @@ import fixtures
from oslo_log import log as logging
from oslo_utils import uuidutils
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions
import testtools
from magnum_tempest_plugin.common import config
@ -29,11 +31,12 @@ HEADERS = {'OpenStack-API-Version': 'container-infra latest',
'Content-Type': 'application/json'}
class ClusterTest(base.BaseTempestTest):
class ClusterTest(base.BaseMagnumTest):
"""Tests for cluster CRUD."""
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)
delete_template = False
def __init__(self, *args, **kwargs):
@ -42,23 +45,26 @@ class ClusterTest(base.BaseTempestTest):
@classmethod
def setUpClass(cls):
super(ClusterTest, cls).setUpClass()
super(ClusterTest, cls).setUp()
try:
(cls.creds, cls.keypair) = cls.get_credentials_with_keypair(
type_of_creds='default'
)
(cls.cluster_template_client,
cls.keypairs_client) = cls.get_clients_with_existing_creds(
creds=cls.creds,
type_of_creds='default',
request_type='cluster_template'
)
(cls.cluster_client, _) = cls.get_clients_with_existing_creds(
creds=cls.creds,
type_of_creds='default',
request_type='cluster'
)
(cls.cert_client, _) = cls.get_clients_with_existing_creds(
creds=cls.creds,
type_of_creds='default',
@ -132,7 +138,6 @@ class ClusterTest(base.BaseTempestTest):
self._get_cluster_by_id(model.uuid)[1].node_addresses]),
self.cluster_template.coe,
self.keypair))
timeout = config.Config.cluster_creation_timeout * 60
self.cluster_client.wait_for_created_cluster(model.uuid,
delete_on_error=False,
@ -154,8 +159,6 @@ class ClusterTest(base.BaseTempestTest):
resp, model = self.cluster_client.get_cluster(cluster_id)
return resp, model
# (dimtruck) Combining all these tests in one because
# they time out on the gate (2 hours not enough)
@testtools.testcase.attr('positive')
@testtools.testcase.attr('slow')
@decorators.idempotent_id('44158a8c-a856-11e9-9382-00224d6b7bc1')
@ -164,10 +167,12 @@ class ClusterTest(base.BaseTempestTest):
cluster_template_id=self.cluster_template.uuid, node_count=1)
# test cluster create
self.LOG.debug("Testing cluster create")
_, cluster_model = self._create_cluster(gen_model)
self.assertNotIn('status', cluster_model)
# test cluster list
self.LOG.debug("Testing cluster list")
resp, cluster_list_model = self.cluster_client.list_clusters()
self.assertEqual(200, resp.status)
self.assertGreater(len(cluster_list_model.clusters), 0)
@ -176,6 +181,7 @@ class ClusterTest(base.BaseTempestTest):
for x in cluster_list_model.clusters]))
# test ca show
self.LOG.debug("Testing CA show")
resp, cert_model = self.cert_client.get_cert(
cluster_model.uuid, headers=HEADERS)
self.LOG.debug("cert resp: %s", resp)
@ -186,6 +192,7 @@ class ClusterTest(base.BaseTempestTest):
self.assertIn('-----END CERTIFICATE-----', cert_model.pem)
# test ca sign
self.LOG.debug("Testing CA sign")
csr_sample = """-----BEGIN CERTIFICATE REQUEST-----
MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w
@ -211,7 +218,22 @@ Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
self.assertIn('-----END CERTIFICATE-----', cert_model.pem)
self.LOG.debug("Successful run")
# gather logs before deleting cluster
if config.Config.copy_logs:
self.LOG.debug("Copying logs after successful run")
cluster = self._get_cluster_by_id(cluster_model.uuid)[1]
self.LOG.debug("Master addresses: %s", cluster.master_addresses)
self.LOG.debug("Node addresses: %s", cluster.node_addresses)
self.copy_logs_handler(
lambda: list(
[cluster.master_addresses,
cluster.node_addresses]),
self.cluster_template.coe,
self.keypair)
# test cluster delete
self.LOG.debug("Testing delete cluster")
self._delete_cluster(cluster_model.uuid)
self.clusters.remove(cluster_model.uuid)
@ -224,21 +246,6 @@ Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
exceptions.BadRequest,
self.cluster_client.post_cluster, gen_model)
@testtools.testcase.attr('positive')
@testtools.testcase.attr('slow')
@decorators.idempotent_id('262eb132-a857-11e9-9382-00224d6b7bc1')
def test_create_cluster_with_zero_nodes(self):
gen_model = datagen.valid_cluster_data(
cluster_template_id=self.cluster_template.uuid, node_count=0)
# test cluster create
_, cluster_model = self._create_cluster(gen_model)
self.assertNotIn('status', cluster_model)
# test cluster delete
self._delete_cluster(cluster_model.uuid)
self.clusters.remove(cluster_model.uuid)
@testtools.testcase.attr('negative')
@decorators.idempotent_id('29c6c5f0-a857-11e9-9382-00224d6b7bc1')
def test_create_cluster_with_zero_masters(self):

View File

@ -21,7 +21,8 @@ echo "Magnum's copy_instance_logs.sh was called..."
SSH_IP=$1
COE=${2-kubernetes}
NODE_TYPE=${3-master}
LOG_PATH=/opt/stack/logs/cluster-nodes/${NODE_TYPE}-${SSH_IP}
LOG_PATH_BASE=/opt/stack/logs/cluster-nodes
LOG_PATH={$LOG_PATH_BASE}/${NODE_TYPE}-${SSH_IP}
KEYPAIR=${4-default}
PRIVATE_KEY=
@ -40,9 +41,12 @@ function remote_exec {
ssh -i $PRIVATE_KEY -o StrictHostKeyChecking=no ${ssh_user}@${SSH_IP} "${cmd}" > ${logfile} 2>&1
}
mkdir -p $LOG_PATH
if [ ! -d $LOG_PATH_BASE ]; then
sudo mkdir -p $LOG_PATH_BASE
sudo chown -R stack:stack $LOG_PATH_BASE
fi
cat /proc/cpuinfo > /opt/stack/logs/cpuinfo.log
mkdir -p $LOG_PATH
if [[ "$COE" == "kubernetes" ]]; then
SSH_USER=fedora