From f7e6d3b93739ff413f5e7dcc16e6637658a65e3c Mon Sep 17 00:00:00 2001 From: Juha Kosonen Date: Tue, 17 Sep 2019 15:29:26 +0300 Subject: [PATCH] Refactor conformance robot test - upload and use images in internal repository if the repository is defined - create sonobuoy manifest file dynamically - increase sonobuoy timeout to avoid early abort JIRA: VAL-48 Change-Id: I49c721bc8a4da90942167ecd835c8e5bb26f5364 Signed-off-by: Juha Kosonen --- .coafile | 2 +- tests/k8s/conformance/conformance.robot | 88 +++++++++++++- tests/k8s/conformance/custom_repos.yaml | 6 + tests/k8s/conformance/sonobuoy.yaml | 196 -------------------------------- tests/variables.yaml | 9 +- 5 files changed, 99 insertions(+), 202 deletions(-) create mode 100644 tests/k8s/conformance/custom_repos.yaml delete mode 100644 tests/k8s/conformance/sonobuoy.yaml diff --git a/.coafile b/.coafile index 39d09fa..bdcde25 100644 --- a/.coafile +++ b/.coafile @@ -35,7 +35,7 @@ bears = YAMLLintBear files = **.yaml, **.yml use_spaces = true max_line_length = 120 -ignore = tests/k8s/conformance/sonobuoy.yaml +ignore = tests/k8s/conformance/custom_repos.yaml [all.Python] bears = PyLintBear diff --git a/tests/k8s/conformance/conformance.robot b/tests/k8s/conformance/conformance.robot index 6f9096c..9418772 100644 --- a/tests/k8s/conformance/conformance.robot +++ b/tests/k8s/conformance/conformance.robot @@ -20,12 +20,31 @@ Documentation Run k8s conformance test using sonobuoy Library OperatingSystem Library BuiltIn -Test Setup Check that k8s cluster is reachable -Test Teardown Cleanup Sonobuoy +Library Collections +Library String +Library SSHLibrary +Library Process +Test Setup Run Keywords +... Check that k8s cluster is reachable +... Onboard Images +... Create Manifest File +Test Teardown Run Keywords +... Cleanup Sonobuoy +... Close All Connections *** Variables *** ${LOG} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log +&{SONOBUOY} path=gcr.io/heptio-images +... name=sonobuoy:v0.15.1 +&{E2E} path=akraino +... name=validation:kube-conformance-v1.15 +&{SYSTEMD_LOGS} path=akraino +... name=validation:sonobuoy-plugin-systemd-logs-latest +&{SONOBUOY_IMGS} sonobuoy=&{SONOBUOY} +... e2e=&{E2E} +... systemd_logs=&{SYSTEMD_LOGS} + *** Test Cases *** Run Sonobuoy Conformance Test # Start the test @@ -62,3 +81,68 @@ Cleanup Sonobuoy Append To File ${LOG} ${output}${\n} Sleep 3s Should Contain ${output} service "sonobuoy-master" deleted + +Open Connection And Log In + Open Connection ${HOST} + Login With Public Key ${USERNAME} ${SSH_KEYFILE} + +Upload To Internal Registry + [Arguments] ${path} ${name} + ${rc}= Execute Command + ... docker pull ${path}/${name} + ... return_stdout=False return_rc=True + Should Be Equal As Integers ${rc} 0 + ${rc}= Execute Command + ... docker tag ${path}/${name} ${INT_REG}/bluval/${name} + ... return_stdout=False return_rc=True + Should Be Equal As Integers ${rc} 0 + ${rc}= Execute Command + ... docker push ${INT_REG}/bluval/${name} + ... return_stdout=False return_rc=True + Should Be Equal As Integers ${rc} 0 + +Onboard Sonobuoy Images + FOR ${img} IN @{SONOBUOY_IMGS} + ${path}= Get From Dictionary ${SONOBUOY_IMGS['${img}']} path + ${name}= Get From Dictionary ${SONOBUOY_IMGS['${img}']} name + Upload To Internal Registry ${path} ${name} + Set To Dictionary ${SONOBUOY_IMGS['${img}']} path=${INT_REG}/bluval + END + +Onboard Kubernetes e2e Test Images + ${result}= Run Process sonobuoy images + Should Be Equal As Integers ${result.rc} 0 + @{images}= Split String ${result.stdout} + FOR ${img} IN @{images} + ${path} ${name} Split String From Right ${img} / 1 + Upload To Internal Registry ${path} ${name} + END + +Onboard Images + ${INT_REG}= Get Variable Value ${INTERNAL_REGISTRY} ${EMPTY} + Set Test Variable ${INT_REG} + Return From Keyword If $INT_REG == '${EMPTY}' + Open Connection And Log In + Onboard Sonobuoy Images + Onboard Kubernetes e2e Test Images + +Create Manifest File + @{flags}= Set Variable + ... --e2e-focus \\[Conformance\\\] + ... --e2e-skip Aggregator|Alpha|\\[(Disruptive|Feature:[^\\]]+|Flaky)\\] + ... --kube-conformance-image ${SONOBUOY_IMGS.e2e.path}/${SONOBUOY_IMGS.e2e.name} + ... --sonobuoy-image ${SONOBUOY_IMGS.sonobuoy.path}/${SONOBUOY_IMGS.sonobuoy.name} + ... --image-pull-policy Always + ... --timeout 14400 + Run Keyword If $INT_REG != '${EMPTY}' Run Keywords + ... Append To List ${flags} + ... --e2e-repo-config ${CURDIR}${/}custom_repos.yaml + ... AND + ... Run Process sed -i s|{{ registry }}|${INT_REG}/bluval|g + ... ${CURDIR}${/}custom_repos.yaml + ${result}= Run Process sonobuoy gen @{flags} + Should Be Equal As Integers ${result.rc} 0 + ${manifest}= Replace String ${result.stdout} + ... image: gcr.io/heptio-images/sonobuoy-plugin-systemd-logs:latest + ... image: ${SONOBUOY_IMGS.systemd_logs.path}/${SONOBUOY_IMGS.systemd_logs.name} + Create File ${CURDIR}${/}sonobuoy.yaml ${manifest} diff --git a/tests/k8s/conformance/custom_repos.yaml b/tests/k8s/conformance/custom_repos.yaml new file mode 100644 index 0000000..d7aae98 --- /dev/null +++ b/tests/k8s/conformance/custom_repos.yaml @@ -0,0 +1,6 @@ +dockerLibraryRegistry: {{ registry }} +e2eRegistry: {{ registry }} +gcRegistry: {{ registry }} +etcdRegistry: {{ registry }} +privateRegistry: {{ registry }} +sampleRegistry: {{ registry }} diff --git a/tests/k8s/conformance/sonobuoy.yaml b/tests/k8s/conformance/sonobuoy.yaml deleted file mode 100644 index 76f9e09..0000000 --- a/tests/k8s/conformance/sonobuoy.yaml +++ /dev/null @@ -1,196 +0,0 @@ -############################################################################## -# Copyright (c) 2019 AT&T Intellectual Property. # -# Copyright (c) 2019 Nokia. # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you maynot 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. # -############################################################################## - ---- -apiVersion: v1 -kind: Namespace -metadata: - name: heptio-sonobuoy ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - component: sonobuoy - name: sonobuoy-serviceaccount - namespace: heptio-sonobuoy ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - component: sonobuoy - name: sonobuoy-serviceaccount-heptio-sonobuoy -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: sonobuoy-serviceaccount -subjects: -- kind: ServiceAccount - name: sonobuoy-serviceaccount - namespace: heptio-sonobuoy ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - component: sonobuoy - name: sonobuoy-serviceaccount -rules: -- apiGroups: - - '*' - resources: - - '*' - verbs: - - '*' -- nonResourceURLs: - - '/metrics' - - '/logs' - - '/logs/*' - verbs: - - 'get' ---- -apiVersion: v1 -data: - config.json: | - {"Description":"DEFAULT","UUID":"376a4ddc-4498-49fc-af2e-999242c4c245","Version":"v0.15.1","ResultsDir":"/tmp/sonobuoy","Resources":["CertificateSigningRequests","ClusterRoleBindings","ClusterRoles","ComponentStatuses","CustomResourceDefinitions","Nodes","PersistentVolumes","PodSecurityPolicies","ServerGroups","ServerVersion","StorageClasses","ConfigMaps","ControllerRevisions","CronJobs","DaemonSets","Deployments","Endpoints","Ingresses","Jobs","LimitRanges","NetworkPolicies","PersistentVolumeClaims","PodDisruptionBudgets","PodTemplates","Pods","ReplicaSets","ReplicationControllers","ResourceQuotas","RoleBindings","Roles","ServiceAccounts","Services","StatefulSets"],"Filters":{"Namespaces":".*","LabelSelector":""},"Limits":{"PodLogs":{"LimitSize":"","LimitTime":""}},"Server":{"bindaddress":"0.0.0.0","bindport":8080,"advertiseaddress":"","timeoutseconds":10800},"Plugins":[{"name":"e2e"},{"name":"systemd-logs"}],"PluginSearchPath":["./plugins.d","/etc/sonobuoy/plugins.d","~/sonobuoy/plugins.d"],"Namespace":"heptio-sonobuoy","LoadedPlugins":null,"WorkerImage":"gcr.io/heptio-images/sonobuoy:latest","ImagePullPolicy":"Always"} -kind: ConfigMap -metadata: - labels: - component: sonobuoy - name: sonobuoy-config-cm - namespace: heptio-sonobuoy ---- -apiVersion: v1 -data: - e2e.yaml: | - sonobuoy-config: - driver: Job - plugin-name: e2e - result-type: e2e - spec: - env: - - name: E2E_FOCUS - value: '\[Conformance\]' - - name: E2E_SKIP - value: 'Aggregator|Alpha|\[(Disruptive|Feature:[^\]]+|Flaky)\]' - - name: E2E_PARALLEL - value: '1' - command: ["/run_e2e.sh"] - image: akraino/validation:kube-conformance-v1.15 - imagePullPolicy: Always - name: e2e - volumeMounts: - - mountPath: /tmp/results - name: results - readOnly: false - tolerations: - - operator: "Exists" - systemd-logs.yaml: | - sonobuoy-config: - driver: DaemonSet - plugin-name: systemd-logs - result-type: systemd_logs - spec: - command: ["/bin/sh", "-c", "/get_systemd_logs.sh && sleep 3600"] - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: RESULTS_DIR - value: /tmp/results - - name: CHROOT_DIR - value: /node - image: akraino/validation:sonobuoy-plugin-systemd-logs-latest - imagePullPolicy: Always - name: sonobuoy-systemd-logs-config - securityContext: - privileged: true - volumeMounts: - - mountPath: /tmp/results - name: results - readOnly: false - - mountPath: /node - name: root - readOnly: false -kind: ConfigMap -metadata: - labels: - component: sonobuoy - name: sonobuoy-plugins-cm - namespace: heptio-sonobuoy ---- -apiVersion: v1 -kind: Pod -metadata: - labels: - component: sonobuoy - run: sonobuoy-master - tier: analysis - name: sonobuoy - namespace: heptio-sonobuoy -spec: - containers: - - command: - - /bin/bash - - -c - - /sonobuoy master --no-exit=true -v 3 --logtostderr - env: - - name: SONOBUOY_ADVERTISE_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - image: gcr.io/heptio-images/sonobuoy:v0.15.1 - imagePullPolicy: Always - name: kube-sonobuoy - volumeMounts: - - mountPath: /etc/sonobuoy - name: sonobuoy-config-volume - - mountPath: /plugins.d - name: sonobuoy-plugins-volume - - mountPath: /tmp/sonobuoy - name: output-volume - restartPolicy: Never - serviceAccountName: sonobuoy-serviceaccount - volumes: - - configMap: - name: sonobuoy-config-cm - name: sonobuoy-config-volume - - configMap: - name: sonobuoy-plugins-cm - name: sonobuoy-plugins-volume - - emptyDir: {} - name: output-volume ---- -apiVersion: v1 -kind: Service -metadata: - labels: - component: sonobuoy - run: sonobuoy-master - name: sonobuoy-master - namespace: heptio-sonobuoy -spec: - ports: - - port: 8080 - protocol: TCP - targetPort: 8080 - selector: - run: sonobuoy-master - type: ClusterIP - diff --git a/tests/variables.yaml b/tests/variables.yaml index 42d6425..121eb26 100644 --- a/tests/variables.yaml +++ b/tests/variables.yaml @@ -15,12 +15,12 @@ # limitations under the License. # ############################################################################## -# This file provides variable requeired robot testcases +# This file provides variables required by robot testcases # This file can be passed to robot testcases as follows # $ robot -v varables.yaml # -# All keys are converted UPPERCASE before sumitting to robot. YAML notation is -# smallcase and Robot variables notation is UPPERCASE so industry is follwoing +# All keys are converted UPPERCASE before submitting to robot. YAML notation is +# smallcase and Robot variables notation is UPPERCASE so industry is following # this. ### Input variables cluster's master host @@ -55,3 +55,6 @@ nodename: targetnode # target node to test ceph ### Input variables for ltp rootuser: rootuser # Required root user to log in to the host rootpswd: rootpassword # Required root password to log in to the host + +### Input variables for Conformance test +internal_registry: '' # Docker internal registry -- 2.16.6