diff --git a/devstack/lib/magnum b/devstack/lib/magnum index 3e690de3f2..afa59e22cb 100644 --- a/devstack/lib/magnum +++ b/devstack/lib/magnum @@ -67,9 +67,7 @@ else MAGNUM_BIN_DIR=$(get_python_exec_prefix) fi -if is_service_enabled ir-api; then - MAGNUM_CONFIGURE_IPTABLES=${MAGNUM_CONFIGURE_IPTABLES:-False} -fi +MAGNUM_CONFIGURE_IPTABLES=${MAGNUM_CONFIGURE_IPTABLES:-True} # Functions # --------- @@ -270,8 +268,28 @@ function magnum_register_image { if [ ! -z "$coreos" ]; then magnum_image_property=$magnum_image_property"coreos" fi + # os_distro property for fedora ironic image + local fedora_ironic="$(echo $MAGNUM_GUEST_IMAGE_URL | grep -i "ironic" \ + | grep -io "fedora" || true;)" + if [ ! -z "$fedora_ironic" ]; then + magnum_image_property=$magnum_image_property"fedora" + fi - openstack --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT --os-image-api-version 1 image set $(basename "$MAGNUM_GUEST_IMAGE_URL" ".qcow2") $magnum_image_property + # get the image name + local image_filename=$(basename "$MAGNUM_GUEST_IMAGE_URL") + local image_name="" + for extension in "tgz" "img" "qcow2" "iso" "vhd" "vhdx" "tar.gz" "img.gz" "img.bz2" "vhd.gz" "vhdx.gz" + do + if [ $(expr match "${image_filename}" ".*\.${extension}$") -ne 0 ]; then + image_name=$(basename "$image_filename" ".${extension}") + break + fi + done + if [ -z ${image_name} ]; then + echo "Unknown image extension in $image_filename, supported extensions: tgz, img, qcow2, iso, vhd, vhdx, tar.gz, img.gz, img.bz2, vhd.gz, vhdx.gz"; false + fi + + openstack --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT --os-image-api-version 1 image set $image_name $magnum_image_property } # install_magnumclient() - Collect source and prepare diff --git a/magnum/tests/contrib/gate_hook.sh b/magnum/tests/contrib/gate_hook.sh index 2e2698fcc8..33013bdf5e 100755 --- a/magnum/tests/contrib/gate_hook.sh +++ b/magnum/tests/contrib/gate_hook.sh @@ -16,6 +16,7 @@ coe=$1 +special=$2 export PROJECTS="openstack/barbican $PROJECTS" export DEVSTACK_LOCAL_CONFIG="enable_plugin magnum git://git.openstack.org/openstack/magnum" @@ -25,6 +26,43 @@ if [ "$coe" = "mesos" ]; then echo "MAGNUM_GUEST_IMAGE_URL=https://fedorapeople.org/groups/magnum/ubuntu-14.04.3-mesos-0.25.0.qcow2" >> $BASE/new/devstack/localrc elif [ "$coe" = "k8s-coreos" ]; then echo "MAGNUM_GUEST_IMAGE_URL=http://beta.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2" >> $BASE/new/devstack/localrc +elif [ "${coe}${special}" = "k8s-ironic" ]; then + export DEVSTACK_LOCAL_CONFIG+=$'\n'"MAGNUM_GUEST_IMAGE_URL='https://fedorapeople.org/groups/magnum/fedora-23-kubernetes-ironic.tar.gz'" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"MAGNUM_IMAGE_NAME='fedora-23-kubernetes-ironic'" + + export DEVSTACK_GATE_VIRT_DRIVER="ironic" + # NOTE(yuanying): Current implementation requires only 1 subnet under network + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IP_VERSION=4" + # NOTE(strigazi) keep cinder + # export DEVSTACK_LOCAL_CONFIG+=$'\n'"disable_service cinder c-sch c-api c-vol" + + export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin ironic git://git.openstack.org/openstack/ironic" + + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_DEPLOY_DRIVER=pxe_ssh" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_BAREMETAL_BASIC_OPS=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_LOG_DIR=/opt/stack/new/ironic-bm-logs" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"DEFAULT_INSTANCE_TYPE=baremetal" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"BUILD_TIMEOUT=600" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_CALLBACK_TIMEOUT=600" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_AGENT=openvswitch" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_TENANT_NETWORK_TYPE=vxlan" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_BUILD_DEPLOY_RAMDISK=False" + + export DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_ENABLE_TEMPURLS=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_TEMPURL_KEY=password" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_HASH=password" + + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_ENABLED_DRIVERS=fake,agent_ssh,agent_ipmitool,pxe_ssh,pxe_ipmitool" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"VOLUME_BACKING_FILE_SIZE=24G" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"FORCE_CONFIG_DRIVE=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_DEPLOY_DRIVER_ISCSI_WITH_IPA=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_RAMDISK_TYPE=tinyipa" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_IPXE_ENABLED=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_COUNT=2" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_SSH_PORT=22" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_SPECS_RAM=1024" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_SPECS_DISK=10" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"IRONIC_VM_EPHEMERAL_DISK=5" else export DEVSTACK_LOCAL_CONFIG+=$'\n'"MAGNUM_GUEST_IMAGE_URL='http://tarballs.openstack.org/magnum/images/fedora-atomic-f23-dib.qcow2'" export DEVSTACK_LOCAL_CONFIG+=$'\n'"MAGNUM_IMAGE_NAME='fedora-atomic-f23-dib'" diff --git a/magnum/tests/contrib/post_test_hook.sh b/magnum/tests/contrib/post_test_hook.sh index beb7dd442c..ad6077ce54 100755 --- a/magnum/tests/contrib/post_test_hook.sh +++ b/magnum/tests/contrib/post_test_hook.sh @@ -28,12 +28,27 @@ function create_test_data { # a baymodel, bay and a pod coe=$1 + special=$2 if [ $coe == 'mesos' ]; then local image_name="ubuntu-14.04" + local container_format="bare" elif [ $coe == 'k8s-coreos' ]; then local image_name="coreos" + local container_format="bare" + elif [ "${coe}${special}" == 'k8s-ironic' ]; then + local bm_flavor_id=$(openstack flavor show baremetal -f value -c id) + die_if_not_set $LINENO bm_flavor_id "Failed to get id of baremetal flavor" + + # NOTE(yuanying): Workaround fix for ironic issue + # cf. https://bugs.launchpad.net/ironic/+bug/1596421 + echo "alter table ironic.nodes modify instance_info LONGTEXT;" | mysql -uroot -p${MYSQL_PASSWORD} ironic + # NOTE(yuanying): Ironic instances need to connect to Internet + neutron subnet-update private-subnet --dns-nameserver 8.8.8.8 + + local container_format="ami" else local image_name="atomic" + local container_format="bare" fi # if we have the MAGNUM_IMAGE_NAME setting, use it instead @@ -42,7 +57,12 @@ function create_test_data { image_name=${MAGNUM_IMAGE_NAME:-$image_name} export NIC_ID=$(neutron net-show public | awk '/ id /{print $4}') - export IMAGE_ID=$(glance --os-image-api-version 1 image-list | grep -i $image_name | awk '{print $2}') + + # We need to filter by container_format to get the appropriate + # image. Specifically, when we provide kernel and ramdisk images + # we need to select the 'ami' image. Otherwise, when we have + # qcow2 images, the format is 'bare'. + export IMAGE_ID=$(glance --os-image-api-version 1 image-list | grep $container_format | grep -i $image_name | awk '{print $2}') # pass the appropriate variables via a config file CREDS_FILE=$MAGNUM_DIR/functional_creds.conf @@ -65,8 +85,8 @@ region_name = $OS_REGION_NAME image_id = $IMAGE_ID nic_id = $NIC_ID keypair_id = default -flavor_id = s1.magnum -master_flavor_id = m1.magnum +flavor_id = ${bm_flavor_id:-s1.magnum} +master_flavor_id = ${bm_flavor_id:-m1.magnum} copy_logs = true csr_location = $MAGNUM_DIR/default.csr dns_nameserver = 8.8.8.8 @@ -175,6 +195,7 @@ echo "Running magnum functional test suite for $1" # For api, we will run tempest tests coe=$1 +special=$2 if [[ "api" == "$coe" ]]; then # Import devstack functions 'iniset', 'iniget' and 'trueorfalse' @@ -224,9 +245,10 @@ else add_flavor - create_test_data $coe + create_test_data $coe $special - sudo -E -H -u jenkins tox -e functional-"$coe" -- --concurrency=1 + target="${coe}${special}" + sudo -E -H -u jenkins tox -e functional-"$target" -- --concurrency=1 fi EXIT_CODE=$? diff --git a/magnum/tests/functional/k8s_ironic/__init__.py b/magnum/tests/functional/k8s_ironic/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/magnum/tests/functional/k8s_ironic/test_k8s_python_client.py b/magnum/tests/functional/k8s_ironic/test_k8s_python_client.py new file mode 100644 index 0000000000..a5a3e6fd6f --- /dev/null +++ b/magnum/tests/functional/k8s_ironic/test_k8s_python_client.py @@ -0,0 +1,24 @@ +# 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. + +from magnum.tests.functional import python_client_base as base + + +class TestFedoraKubernetesIronicAPIs(base.BaseK8sTest): + bay_complete_timeout = 3200 + baymodel_kwargs = { + "tls_disabled": True, + "network_driver": 'flannel', + "volume_driver": None, + "fixed_subnet": 'private-subnet', + "server_type": 'bm', + } diff --git a/magnum/tests/functional/python_client_base.py b/magnum/tests/functional/python_client_base.py index 6fc747b82e..05c3d20fb6 100644 --- a/magnum/tests/functional/python_client_base.py +++ b/magnum/tests/functional/python_client_base.py @@ -138,6 +138,8 @@ class BaseMagnumClient(base.BaseMagnumTest): volume_driver = kwargs.pop('volume_driver', 'cinder') labels = kwargs.pop('labels', {"K1": "V1", "K2": "V2"}) tls_disabled = kwargs.pop('tls_disabled', False) + fixed_subnet = kwargs.pop('fixed_subnet', None) + server_type = kwargs.pop('server_type', 'vm') baymodel = cls.cs.baymodels.create( name=name, @@ -153,6 +155,8 @@ class BaseMagnumClient(base.BaseMagnumTest): coe=coe, labels=labels, tls_disabled=tls_disabled, + fixed_subnet=fixed_subnet, + server_type=server_type, **kwargs) return baymodel @@ -200,7 +204,7 @@ class BaseMagnumClient(base.BaseMagnumTest): bay, [None, "CREATE_IN_PROGRESS"], ["CREATE_FAILED", "CREATE_COMPLETE"], - timeout=1800 + timeout=self.bay_complete_timeout ) if self.cs.bays.get(bay.uuid).status == 'CREATE_FAILED': @@ -231,6 +235,8 @@ extendedKeyUsage = clientAuth cert_file = None ca_file = None + bay_complete_timeout = 1800 + @classmethod def setUpClass(cls): super(BayTest, cls).setUpClass() diff --git a/tox.ini b/tox.ini index 673f914b01..43d0a825c9 100644 --- a/tox.ini +++ b/tox.ini @@ -46,6 +46,16 @@ commands = find . -type f -name "*.pyc" -delete bash tools/pretty_tox.sh '{posargs}' +[testenv:functional-k8s-ironic] +sitepackages = True +setenv = OS_TEST_PATH=./magnum/tests/functional/k8s_ironic + OS_TEST_TIMEOUT=7200 +deps = + {[testenv]deps} +commands = + find . -type f -name "*.pyc" -delete + bash tools/pretty_tox.sh '{posargs}' + [testenv:functional-k8s-coreos] sitepackages = True setenv = OS_TEST_PATH=./magnum/tests/functional/k8s_coreos