From 4fb91cc109a9e636abb309e614341f25bf26c7b8 Mon Sep 17 00:00:00 2001 From: Spyros Trigazis Date: Thu, 10 Aug 2017 08:24:42 +0200 Subject: [PATCH] tests: Use swarm-mode for api tests * Swarm-mode is the fastest cluster to deploy since it doesn't require to pull anything from outside. * Add the output nodes for swarm-mode too. * Disable copy logs (I think a better practice is to copy logs on demand). * Don't run test_create_list_sign_delete_clusters, because it is very unstable on the CI. Partially-Implements: blueprint swarm-mode-support 2nd commit message: Update to Fedora Atomic 26 This patch moves the current master to test against Fedora Atomic 26, in addition, it switches to downloading from Fedora mirrors. 2nd-Change-Id: I9a97c0eb78b2c9d10e8be1501babb19e73ee70c1 3rd commit message: Set default iptables FORWARD policy to ACCEPT With the release of Docker 1.13 which is available in Fedora Atomic 26, it no longer sets the policy of the FORWARD chain to ACCEPT[1]. Therefore, CNI networking such as Flannel will cease to work. This patch sets the policy to ACCEPT so that traffic can work once again for deployments which are based on Docker versions which are newer than 1.13 [1]: https://github.com/moby/moby/pull/28257 3rd-Change-Id: I1457602748619f38f87542fc01a2996ee80e58b7 Closes-Bug: #1708454 Co-Authored-By: Mohammed Naser Change-Id: I86d4dcc94fff622be4ee2acc8dd60ed81bc5d433 --- devstack/plugin.sh | 2 +- doc/source/user/index.rst | 6 +- install-guide/source/launch-instance.rst | 4 +- .../kubernetes/fragments/network-service.sh | 4 ++ .../swarm/fragments/network-service.sh | 4 ++ .../templates/kubecluster.yaml | 2 +- magnum/tests/contrib/gate_hook.sh | 9 ++- magnum/tests/contrib/post_test_hook.sh | 64 ++++++++++--------- magnum/tests/functional/api/v1/test_bay.py | 2 +- .../tests/functional/api/v1/test_baymodel.py | 2 +- .../functional/api/v1/test_baymodel_admin.py | 2 +- .../tests/functional/api/v1/test_cluster.py | 2 +- .../api/v1/test_cluster_template.py | 2 +- .../api/v1/test_cluster_template_admin.py | 2 +- magnum/tests/functional/common/datagen.py | 18 +++--- magnum/tests/functional/python_client_base.py | 4 ++ 16 files changed, 75 insertions(+), 54 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 81342bfd8f..1d5ed616d0 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -13,7 +13,7 @@ if is_service_enabled magnum-api magnum-cond; then echo_summary "Installing magnum" install_magnum - MAGNUM_GUEST_IMAGE_URL=${MAGNUM_GUEST_IMAGE_URL:-"https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2"} + MAGNUM_GUEST_IMAGE_URL=${MAGNUM_GUEST_IMAGE_URL:-"https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-Atomic-26-20170723.0/CloudImages/x86_64/images/Fedora-Atomic-26-20170723.0.x86_64.qcow2"} IMAGE_URLS+=",${MAGNUM_GUEST_IMAGE_URL}" LIBS_FROM_GIT="${LIBS_FROM_GIT},python-magnumclient" diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst index f27eabf88c..7de69337fd 100644 --- a/doc/source/user/index.rst +++ b/doc/source/user/index.rst @@ -2490,11 +2490,11 @@ The image currently has the following OS/software: +-------------+-----------+ | OS/software | version | +=============+===========+ -| Fedora | 25 | +| Fedora | 26 | +-------------+-----------+ -| Docker | 1.12.6 | +| Docker | 1.13.1 | +-------------+-----------+ -| Kubernetes | 1.5.3 | +| Kubernetes | 1.6.7 | +-------------+-----------+ | etcd | 3.1.3 | +-------------+-----------+ diff --git a/install-guide/source/launch-instance.rst b/install-guide/source/launch-instance.rst index 18f3cfe152..abba321116 100644 --- a/install-guide/source/launch-instance.rst +++ b/install-guide/source/launch-instance.rst @@ -116,7 +116,7 @@ and tested by the Magnum team. .. code-block:: console - $ wget https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2 + $ wget https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-Atomic-26-20170723.0/CloudImages/x86_64/images/Fedora-Atomic-26-20170723.0.x86_64.qcow2 #. Register the image to the Image service setting the ``os_distro`` property to ``fedora-atomic``: @@ -390,7 +390,7 @@ will create a deployment. | status_reason | Stack CREATE completed successfully | | created_at | 2017-05-16T09:58:02+00:00 | | updated_at | 2017-05-16T10:00:02+00:00 | - | coe_version | v1.5.3 | + | coe_version | v1.6.7 | | keypair | default | | api_address | https://172.24.4.13:6443 | | master_addresses | ['172.24.4.13'] | diff --git a/magnum/drivers/common/templates/kubernetes/fragments/network-service.sh b/magnum/drivers/common/templates/kubernetes/fragments/network-service.sh index 290615d429..3b88393f3e 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/network-service.sh +++ b/magnum/drivers/common/templates/kubernetes/fragments/network-service.sh @@ -22,6 +22,10 @@ if ! [ "\$FLANNEL_SUBNET" ] && [ "\$FLANNEL_MTU" ] ; then exit 1 fi +# NOTE(mnaser): Since Docker 1.13, it does not set the default forwarding +# policy to ACCEPT which will cause CNI networking to fail. +iptables -P FORWARD ACCEPT + mkdir -p /run/flannel/ cat > /run/flannel/docker < /run/flannel/docker <> $localrc_path - pushd $BASE/new/tempest sudo chown -R jenkins:stack $BASE/new/tempest - # Set demo credentials - source $BASE/new/devstack/accrc/demo/demo - - create_test_data $coe + export TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf # Set up tempest config with magnum goodness - iniset $BASE/new/tempest/etc/tempest.conf magnum image_id $IMAGE_ID - iniset $BASE/new/tempest/etc/tempest.conf magnum nic_id $NIC_ID - iniset $BASE/new/tempest/etc/tempest.conf magnum keypair_id default - iniset $BASE/new/tempest/etc/tempest.conf magnum flavor_id s1.magnum - iniset $BASE/new/tempest/etc/tempest.conf magnum master_flavor_id m1.magnum - iniset $BASE/new/tempest/etc/tempest.conf magnum copy_logs True + iniset $TEMPEST_CONFIG magnum image_id $IMAGE_ID + iniset $TEMPEST_CONFIG magnum nic_id $NIC_ID + iniset $TEMPEST_CONFIG magnum keypair_id default + iniset $TEMPEST_CONFIG magnum flavor_id s1.magnum + iniset $TEMPEST_CONFIG magnum master_flavor_id m1.magnum + iniset $TEMPEST_CONFIG magnum copy_logs True # show tempest config with magnum - cat etc/tempest.conf + cat $TEMPEST_CONFIG - # Set up concurrency and test regex - export MAGNUM_TEMPEST_CONCURRENCY=${MAGNUM_TEMPEST_CONCURRENCY:-1} - export MAGNUM_TESTS=${MAGNUM_TESTS:-'magnum.tests.functional.api.v1'} - - echo "Running tempest magnum test suites" - sudo -H -u jenkins tox -eall-plugin -- $MAGNUM_TESTS --concurrency=$MAGNUM_TEMPEST_CONCURRENCY -else - # Get admin credentials - pushd ../devstack - source openrc admin admin - popd - - create_test_data $coe $special - - target="${coe}${special}" - sudo -E -H -u jenkins tox -e functional-"$target" -- --concurrency=1 + # strigazi: don't run test_create_list_sign_delete_clusters because + # it is very unstable in the CI + _magnum_tests="magnum.tests.functional.api.v1.test_bay" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_baymodel" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster_template" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster_template_admin" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_magnum_service" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_for_nonexisting_cluster_template" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_node_count_0" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_nonexisting_flavor" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_zero_masters" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_delete_cluster_for_nonexisting_cluster" + _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_update_cluster_for_nonexisting_cluster" fi + +target="${coe}${special}" +sudo -E -H -u jenkins tox -e functional-"$target" $_magnum_tests -- --concurrency=1 + EXIT_CODE=$? # Delete the keypair used in the functional test. diff --git a/magnum/tests/functional/api/v1/test_bay.py b/magnum/tests/functional/api/v1/test_bay.py index c8f558657f..77415acf5f 100755 --- a/magnum/tests/functional/api/v1/test_bay.py +++ b/magnum/tests/functional/api/v1/test_bay.py @@ -58,7 +58,7 @@ class BayTest(base.BaseTempestTest): creds=self.creds, type_of_creds='default', request_type='cert') - model = datagen.valid_swarm_baymodel() + model = datagen.valid_swarm_mode_baymodel() _, self.baymodel = self._create_baymodel(model) # NOTE (dimtruck) by default tempest sets timeout to 20 mins. diff --git a/magnum/tests/functional/api/v1/test_baymodel.py b/magnum/tests/functional/api/v1/test_baymodel.py index c95d38b164..0bdce36a7a 100644 --- a/magnum/tests/functional/api/v1/test_baymodel.py +++ b/magnum/tests/functional/api/v1/test_baymodel.py @@ -74,7 +74,7 @@ class BayModelTest(base.BaseTempestTest): @testtools.testcase.attr('positive') def test_create_get_public_baymodel(self): - gen_model = datagen.valid_swarm_baymodel(is_public=True) + gen_model = datagen.valid_swarm_mode_baymodel(is_public=True) self.assertRaises( exceptions.Forbidden, self.baymodel_client.post_baymodel, gen_model) diff --git a/magnum/tests/functional/api/v1/test_baymodel_admin.py b/magnum/tests/functional/api/v1/test_baymodel_admin.py index 9f8642ee95..67f5b15981 100644 --- a/magnum/tests/functional/api/v1/test_baymodel_admin.py +++ b/magnum/tests/functional/api/v1/test_baymodel_admin.py @@ -57,7 +57,7 @@ class BayModelAdminTest(base.BaseTempestTest): @testtools.testcase.attr('positive') def test_create_get_public_baymodel(self): - gen_model = datagen.valid_swarm_baymodel(is_public=True) + gen_model = datagen.valid_swarm_mode_baymodel(is_public=True) resp, model = self._create_baymodel(gen_model) resp, model = self.baymodel_client.get_baymodel(model.uuid) diff --git a/magnum/tests/functional/api/v1/test_cluster.py b/magnum/tests/functional/api/v1/test_cluster.py index fc2a148111..59b700459b 100755 --- a/magnum/tests/functional/api/v1/test_cluster.py +++ b/magnum/tests/functional/api/v1/test_cluster.py @@ -63,7 +63,7 @@ class ClusterTest(base.BaseTempestTest): creds=self.creds, type_of_creds='default', request_type='cert') - model = datagen.valid_swarm_cluster_template() + model = datagen.valid_swarm_mode_cluster_template() _, self.cluster_template = self._create_cluster_template(model) # NOTE (dimtruck) by default tempest sets timeout to 20 mins. diff --git a/magnum/tests/functional/api/v1/test_cluster_template.py b/magnum/tests/functional/api/v1/test_cluster_template.py index b005373400..8713248d80 100644 --- a/magnum/tests/functional/api/v1/test_cluster_template.py +++ b/magnum/tests/functional/api/v1/test_cluster_template.py @@ -79,7 +79,7 @@ class ClusterTemplateTest(base.BaseTempestTest): @testtools.testcase.attr('positive') def test_create_get_public_cluster_template(self): - gen_model = datagen.valid_swarm_cluster_template(is_public=True) + gen_model = datagen.valid_swarm_mode_cluster_template(is_public=True) self.assertRaises( exceptions.Forbidden, self.cluster_template_client.post_cluster_template, gen_model) diff --git a/magnum/tests/functional/api/v1/test_cluster_template_admin.py b/magnum/tests/functional/api/v1/test_cluster_template_admin.py index 22f4ee9efc..b8a2e83b34 100644 --- a/magnum/tests/functional/api/v1/test_cluster_template_admin.py +++ b/magnum/tests/functional/api/v1/test_cluster_template_admin.py @@ -59,7 +59,7 @@ class ClusterTemplateAdminTest(base.BaseTempestTest): @testtools.testcase.attr('positive') def test_create_get_public_cluster_template(self): - gen_model = datagen.valid_swarm_cluster_template(is_public=True) + gen_model = datagen.valid_swarm_mode_cluster_template(is_public=True) resp, model = self._create_cluster_template(gen_model) resp, model = \ diff --git a/magnum/tests/functional/common/datagen.py b/magnum/tests/functional/common/datagen.py index 2fa3fc4aae..b9a31f2efa 100644 --- a/magnum/tests/functional/common/datagen.py +++ b/magnum/tests/functional/common/datagen.py @@ -37,6 +37,7 @@ def gen_coe_dep_network_driver(coe): allowed_driver_types = { 'kubernetes': ['flannel', None], 'swarm': ['docker', 'flannel', None], + 'swarm-mode': ['docker', None], 'mesos': ['docker', None], } driver_types = allowed_driver_types[coe] @@ -47,6 +48,7 @@ def gen_coe_dep_volume_driver(coe): allowed_driver_types = { 'kubernetes': ['cinder', None], 'swarm': ['rexray', None], + 'swarm-mode': ['rexray', None], 'mesos': ['rexray', None], } driver_types = allowed_driver_types[coe] @@ -103,7 +105,7 @@ def baymodel_data(**kwargs): data = { "name": data_utils.rand_name('bay'), - "coe": "swarm", + "coe": "swarm-mode", "tls_disabled": False, "network_driver": None, "volume_driver": None, @@ -208,8 +210,8 @@ def baymodel_valid_data_with_specific_coe(coe): image_id=config.Config.image_id, coe=coe) -def valid_swarm_baymodel(is_public=False): - """Generates a valid swarm baymodel with valid data +def valid_swarm_mode_baymodel(is_public=False): + """Generates a valid swarm mode baymodel with valid data :returns: BayModelEntity with generated data """ @@ -218,7 +220,7 @@ def valid_swarm_baymodel(is_public=False): flavor_id=config.Config.flavor_id, public=is_public, dns_nameserver=config.Config.dns_nameserver, master_flavor_id=config.Config.master_flavor_id, - keypair_id=config.Config.keypair_id, coe="swarm", + keypair_id=config.Config.keypair_id, coe="swarm-mode", cluster_distro=None, external_network_id=config.Config.nic_id, http_proxy=None, https_proxy=None, no_proxy=None, @@ -343,7 +345,7 @@ def cluster_template_data(**kwargs): data = { "name": data_utils.rand_name('cluster'), - "coe": "swarm", + "coe": "swarm-mode", "tls_disabled": False, "network_driver": None, "volume_driver": None, @@ -485,8 +487,8 @@ def cluster_template_valid_data_with_specific_coe(coe): image_id=config.Config.image_id, coe=coe) -def valid_swarm_cluster_template(is_public=False): - """Generates a valid swarm cluster_template with valid data +def valid_swarm_mode_cluster_template(is_public=False): + """Generates a valid swarm-mode cluster_template with valid data :returns: ClusterTemplateEntity with generated data """ @@ -496,7 +498,7 @@ def valid_swarm_cluster_template(is_public=False): public=is_public, dns_nameserver=config.Config.dns_nameserver, master_flavor_id=master_flavor_id, - coe="swarm", + coe="swarm-mode", cluster_distro=None, external_network_id=config.Config.nic_id, http_proxy=None, https_proxy=None, diff --git a/magnum/tests/functional/python_client_base.py b/magnum/tests/functional/python_client_base.py index aed5a9c124..89df0e27f8 100755 --- a/magnum/tests/functional/python_client_base.py +++ b/magnum/tests/functional/python_client_base.py @@ -341,6 +341,10 @@ extendedKeyUsage = clientAuth output_keys = ["kube_masters", "kube_minions"] elif self.cluster_template.coe == "swarm": output_keys = ["swarm_masters", "swarm_nodes"] + elif self.cluster_template.coe == "swarm-mode": + output_keys = ["swarm_primary_master", + "swarm_secondary_masters", + "swarm_nodes"] elif self.cluster_template.coe == "mesos": output_keys = ["mesos_master", "mesos_slaves"]