1 /* Copyright ETSI Contributors and Others
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
20 // string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER')
22 // Parameters to define the specific OSM version to test
23 // --> Defaults to latest stable version of Release FOURTEEN
24 string(defaultValue: 'https://osm-download.etsi.org/ftp/osm-14.0-fourteen/install_osm.sh', description: 'URL to OSM installer', name: 'INSTALLER_URL')
25 string(defaultValue: 'testing-daily', description: 'Release for OSM binaries (REPO_BASE)', name: 'REPO_BASE')
26 string(defaultValue: 'testing-daily', description: 'OSM docker tag (DOCKER_TAG)', name: 'DOCKER_TAG')
27 string(defaultValue: 'testing', description: 'Repository name for OSM packages (REPO_NAME)', name: 'REPO_NAME')
29 // Parameters for docker run
30 string(defaultValue: 'opensourcemano/tests', description: 'Name of docker image for client-side of Robot tests', name: 'TEST_IMAGE')
31 string(defaultValue: 'testing-daily', description: 'Tag of docker image for client-side', name: 'TEST_TAG')
33 // Parameters to define SSH keys (Jenkins secret) used when creating VMs
34 string(defaultValue: '', description: 'Jenkins credential containing SSH private key used in VMs', name: 'SSH_PRIVATE_KEY')
35 string(defaultValue: '', description: 'Jenkins credential containing SSH public key used in VMs', name: 'SSH_PUBLIC_KEY')
37 // Parameter to set the target environment
38 // Parameter to set the name of secret in Jenkins for Azure JSON credentials
39 string(defaultValue: 'azure-credentials', description: 'Jenkins secret that contains Azure JSON credentials', name: 'AZURE_CREDENTIALS')
40 // File format (take care of brackets in clientId):
42 // "clientId": "{<client-id>}",
43 // "clientSecret": "<secret>",
44 // "subscriptionId": "<subscription-id>",
45 // "tenantId": "<tenant-id>",
46 // "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
47 // "resourceManagerEndpointUrl": "https://management.azure.com/",
48 // "activeDirectoryGraphResourceId": "https://graph.windows.net/",
49 // "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
50 // "galleryEndpointUrl": "https://gallery.azure.com/",
51 // "managementEndpointUrl": "https://management.core.windows.net/"
54 // Parameter to set the tag for selecting Robot test to be run
55 string(defaultValue: 'azure', description: 'Tag for selecting Robot test to be run', name: 'ROBOT_RUN_TAG')
57 // Configuration of thresholds for Robot tests
58 string(defaultValue: '99.0', description: '% passed Robot tests to mark the build as passed', name: 'ROBOT_PASS_THRESHOLD')
59 string(defaultValue: '80.0', description: '% passed Robot tests to mark the build as unstable (if lower, it will be failed)', name: 'ROBOT_UNSTABLE_THRESHOLD')
64 SOURCE_IMAGE_NAME = 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest'
65 FLAVOR_NAME = 'Standard_D4as_v4'
66 K8S_FLAVOR_NAME = 'Standard_A2_v2'
67 USE_PAAS_K8S = 'FALSE'
69 RESOURCE_GROUP = 'OSM_CICD_GROUP'
70 VNET_NAME = 'OSM-CICD-net'
71 VIM_MGMT_NET = 'OSM-CICD-subnet'
72 VIM_TARGET = 'azure-etsi'
73 AZURE_FLAVORS_PATTERN = '^Standard'
74 AZURE_REGION = 'westeurope'
75 OSM_VIM_MULTIPLIER_TIMEOUT = '4.0'
78 // Openstack environment
79 CLOUD_TYPE = 'openstack'
80 OS_CLOUD = 'etsi-vim-telefonica'
81 OS_DOMAIN_NAME = 'Default'
82 VIM_TARGET = 'etsi-vim-telefonica'
83 VIM_MGMT_NET = 'osm-ext'
84 VIM_EXT_NET = 'osm-ext'
85 OVERRIDES = '--override-epa'
86 FLAVOR_NAME = 'osm.sanity'
87 SOURCE_IMAGE_NAME = 'ubuntu22.04'
88 SSH_KEY_NAME = 'niv2020'
90 SDNC_PASSWORD = 'karaf'
91 SDNC_URL = 'http://172.21.248.11:8181'
92 SDNC_TYPE = 'onos_vpls'
94 // Google Cloud environment
96 GCP_PROJECT = 'telcocloudpocs'
97 GCP_ZONE = 'europe-west1-b'
98 GCP_MACHINE_TYPE = 'e2-standard-4'
100 GCP_IMAGE_PROJECT = 'ubuntu-os-cloud'
101 GCP_IMAGE_FAMILY = 'ubuntu-2204-lts'
103 VIM_MGMT_NET = 'default'
104 OSM_VIM_MULTIPLIER_TIMEOUT = '4.0'
110 image "${params.TEST_IMAGE}:${params.TEST_TAG}"
111 args "-u root:root --entrypoint=''"
115 stage('Set environment') {
118 if (params.SSH_PUBLIC_KEY == '') {
119 // Gererate SSH private and public keys
120 sh "mkdir -m 700 ~/.ssh"
121 sh "ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''"
124 // SSH private and public keys from Jenkins credentials
125 sh "mkdir -m 700 ~/.ssh"
126 withCredentials([file(credentialsId: "${params.SSH_PRIVATE_KEY}", variable: 'SSHPATH')]) {
127 sh "cp ${SSHPATH} ~/.ssh/id_rsa"
129 withCredentials([file(credentialsId: "${params.SSH_PUBLIC_KEY}", variable: 'SSHPATH')]) {
130 sh "cp ${SSHPATH} ~/.ssh/id_rsa.pub"
132 sh "chmod 400 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub"
134 // This file is used by some Robot test (BASIC12)
135 sh "cp ~/.ssh/id_rsa ~/osm_id_rsa"
136 sh "echo Reading credential ${params.AZURE_CREDENTIALS}"
139 withCredentials([file(credentialsId: "${params.AZURE_CREDENTIALS}", variable: 'FILE')]) {
140 sh "cp ${FILE} ~/azure-creds.json"
143 AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \
144 AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \
145 AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \
146 az login --service-principal --username \$AZURE_CLIENT_ID --password \$AZURE_SECRET --tenant \$AZURE_TENANT
148 sh "az vm list -o table"
152 stage('Create k8s cluster') {
154 sh "/robot-systest/cloud-scripts/create-k8s.sh"
155 sh "cat /robot-systest/results/k8s_environment.rc"
158 stage('Install OSM') {
160 sh "/robot-systest/cloud-scripts/create-osm-vm.sh"
161 sh "cat /robot-systest/results/osm_environment.rc"
162 sh ". /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/remote-install-osm.sh"
165 stage('Add VIM and K8s cluster to OSM') {
168 . /robot-systest/results/osm_environment.rc ; \
169 . /robot-systest/results/k8s_environment.rc ; \
172 export AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \
173 export AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \
174 export AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \
175 export AZURE_SUBSCRIPTION_ID=\$(cat ~/azure-creds.json | jq -r .subscriptionId) ; \
176 /robot-systest/cloud-scripts/add-vim-and-k8scluster.sh
181 stage('Run Robot tests') {
184 . /robot-systest/results/osm_environment.rc ; \
185 . /robot-systest/results/k8s_environment.rc ; \
186 /robot-systest/run_test.sh -t ${params.ROBOT_RUN_TAG}
193 echo "Retrieve container logs"
195 . /robot-systest/results/osm_environment.rc ; \
196 /robot-systest/cloud-scripts/remote-extract-logs.sh
201 sh "cp -var /robot-systest/results /robot-systest/reports/* ."
202 archiveArtifacts artifacts: 'results/**/*', fingerprint: true
204 echo "Updates the Robot dashboard in Jenkins"
205 robot outputPath: '.', passThreshold: "${params.ROBOT_PASS_THRESHOLD}", unstableThreshold: "${params.ROBOT_UNSTABLE_THRESHOLD}"
207 echo "Destroy the K8s cluster"
208 sh '. /robot-systest/results/k8s_environment.rc ; /robot-systest/cloud-scripts/delete-k8s.sh'
210 echo "Destroy the OSM host"
211 sh '. /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/delete-osm-vm.sh'
212 sh "az vm list -o table"