From e40b5ffec575f55724934542a92316ec5162fd0b Mon Sep 17 00:00:00 2001 From: Vamsi Savaram Date: Sun, 19 Apr 2020 21:32:10 +0000 Subject: [PATCH] Add initinfra gating tests Relates-To: #180 Change-Id: Ie7a8daa532596f2d1d0fb2059ef4630607511711 --- .../ephemeral/initinfra/kustomization.yaml | 4 ++ playbooks/airship-airshipctl-test-runner.yaml | 1 + .../defaults/main.yaml | 14 ++++++ .../tasks/main.yaml | 43 +++++++++++++++++++ tools/gate/27_cluster_initinfra.sh | 29 +++++++++++++ tools/gate/config_cluster_initinfra.yaml | 15 +++++++ zuul.d/jobs.yaml | 2 + 7 files changed, 108 insertions(+) create mode 100644 manifests/site/test-bootstrap/ephemeral/initinfra/kustomization.yaml create mode 100644 roles/airshipctl-cluster-initinfra/defaults/main.yaml create mode 100644 roles/airshipctl-cluster-initinfra/tasks/main.yaml create mode 100755 tools/gate/27_cluster_initinfra.sh create mode 100644 tools/gate/config_cluster_initinfra.yaml diff --git a/manifests/site/test-bootstrap/ephemeral/initinfra/kustomization.yaml b/manifests/site/test-bootstrap/ephemeral/initinfra/kustomization.yaml new file mode 100644 index 000000000..5566fa80d --- /dev/null +++ b/manifests/site/test-bootstrap/ephemeral/initinfra/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - ../../../../function/baremetal-operator +commonLabels: + airshipit.org/stage: initinfra diff --git a/playbooks/airship-airshipctl-test-runner.yaml b/playbooks/airship-airshipctl-test-runner.yaml index 3504a90a0..9a9e37714 100644 --- a/playbooks/airship-airshipctl-test-runner.yaml +++ b/playbooks/airship-airshipctl-test-runner.yaml @@ -22,6 +22,7 @@ - airshipctl-build-ephemeral-iso - install-kubectl - airshipctl-deploy-ephemeral-node + - airshipctl-cluster-initinfra var_files_default: - local-dev.yaml - airship-ipam.yaml diff --git a/roles/airshipctl-cluster-initinfra/defaults/main.yaml b/roles/airshipctl-cluster-initinfra/defaults/main.yaml new file mode 100644 index 000000000..934d6fde5 --- /dev/null +++ b/roles/airshipctl-cluster-initinfra/defaults/main.yaml @@ -0,0 +1,14 @@ +# 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. + +# TODO: Remove this as soon as issue #127 is complete +infra_namespace: metal3 diff --git a/roles/airshipctl-cluster-initinfra/tasks/main.yaml b/roles/airshipctl-cluster-initinfra/tasks/main.yaml new file mode 100644 index 000000000..a477b4281 --- /dev/null +++ b/roles/airshipctl-cluster-initinfra/tasks/main.yaml @@ -0,0 +1,43 @@ +# 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. + +- name: deploy infra to cluster + command: >- + airshipctl cluster initinfra + +# TODO: As soon as issue #127 is complete, this check for pods should +# be removed and initinfra command should check for resource status. +- name: verify initinfra metal3-baremetal-operator is created + command: >- + timeout 20 kubectl \ + --kubeconfig {{ airshipctl_config_dir_default | default(ansible_env.HOME) }}/.airship/kubeconfig \ + --namespace {{ infra_namespace }} \ + get deploy {{ item }} + register: deploy_status + until: item in deploy_status.stdout + with_items: + - metal3-baremetal-operator + retries: 50 + delay: 20 + +- name: verify initinfra metal3-baremetal-operator comes up + command: >- + timeout 20 kubectl \ + --kubeconfig {{ airshipctl_config_dir_default | default(ansible_env.HOME) }}/.airship/kubeconfig \ + --namespace {{ infra_namespace }} \ + wait --for=condition=ready pods --selector name={{ item }} + register: deploy_status + until: item in deploy_status.stdout + with_items: + - metal3-baremetal-operator + retries: 50 + delay: 20 diff --git a/tools/gate/27_cluster_initinfra.sh b/tools/gate/27_cluster_initinfra.sh new file mode 100755 index 000000000..d0d1f4c78 --- /dev/null +++ b/tools/gate/27_cluster_initinfra.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -xe + +TMP_DIR=${TMP_DIR:-"$(dirname $(mktemp -u))"} +ANSIBLE_HOSTS=${ANSIBLE_HOSTS:-"${TMP_DIR}/ansible_hosts"} +PLAYBOOK_CONFIG=${PLAYBOOK_CONFIG:-"${TMP_DIR}/config.yaml"} + +sudo ansible-playbook -i "$ANSIBLE_HOSTS" \ + playbooks/airship-airshipctl-test-runner.yaml \ + -e @tools/gate/config_cluster_initinfra.yaml \ + -e @"$PLAYBOOK_CONFIG" diff --git a/tools/gate/config_cluster_initinfra.yaml b/tools/gate/config_cluster_initinfra.yaml new file mode 100644 index 000000000..0b917d1f8 --- /dev/null +++ b/tools/gate/config_cluster_initinfra.yaml @@ -0,0 +1,15 @@ +# 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. + +--- +test_roles: + - airshipctl-cluster-initinfra diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index d20a6c185..eec1fe094 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -86,6 +86,7 @@ - airshipctl-build-ephemeral-iso - install-kubectl - airshipctl-deploy-ephemeral-node + - airshipctl-cluster-initinfra serve_dir: /srv/iso serve_port: 8099 @@ -109,6 +110,7 @@ - airshipctl-build-ephemeral-iso - install-kubectl - airshipctl-deploy-ephemeral-node + - airshipctl-cluster-initinfra serve_dir: /srv/iso serve_port: 8099 voting: false