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
21 // string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER')
23 // Parameters to define the specific OSM version to test
24 // --> Defaults to latest stable version of Release FOURTEEN
25 string(defaultValue: 'https://osm-download.etsi.org/ftp/osm-14.0-fourteen/install_osm.sh', description: 'URL to OSM installer', name: 'INSTALLER_URL')
26 string(defaultValue: 'testing-daily', description: 'Release for OSM binaries (REPO_BASE)', name: 'REPO_BASE')
27 string(defaultValue: 'testing-daily', description: 'OSM docker tag (DOCKER_TAG)', name: 'DOCKER_TAG')
28 string(defaultValue: 'testing', description: 'Repository name for OSM packages (REPO_NAME)', name: 'REPO_NAME')
30 // Parameters for docker run
31 string(defaultValue: 'opensourcemano/tests', description: 'Name of docker image for client-side of Robot tests', name: 'TEST_IMAGE')
32 string(defaultValue: 'testing-daily', description: 'Tag of docker image for client-side', name: 'TEST_TAG')
34 // Parameters to define SSH keys (Jenkins secret) used when creating VMs
35 string(defaultValue: '', description: 'Jenkins credential containing SSH private key used in VMs', name: 'SSH_PRIVATE_KEY')
36 string(defaultValue: '', description: 'Jenkins credential containing SSH public key used in VMs', name: 'SSH_PUBLIC_KEY')
38 // Parameter to set the target environment
39 // string(defaultValue: 'azure-etsi-environment', description: 'Defines the VIM target', name: 'VIM_TARGET_ENVIRONMENT')
40 // string(defaultValue: 'azure/azure.rc', description: 'Cloud config environment file', name: 'CLOUD_ENV_FILE')
41 // Parameter to set the name of secret in Jenkins for Azure JSON credentials
42 string(defaultValue: 'azure-credentials', description: 'Jenkins secret that contains Azure JSON credentials', name: 'AZURE_CREDENTIALS')
43 // File format (take care of brackets in clientId):
45 // "clientId": "{<client-id>}",
46 // "clientSecret": "<secret>",
47 // "subscriptionId": "<subscription-id>",
48 // "tenantId": "<tenant-id>",
49 // "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
50 // "resourceManagerEndpointUrl": "https://management.azure.com/",
51 // "activeDirectoryGraphResourceId": "https://graph.windows.net/",
52 // "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
53 // "galleryEndpointUrl": "https://gallery.azure.com/",
54 // "managementEndpointUrl": "https://management.core.windows.net/"
57 // Parameter to set the tag for selecting Robot test to be run
58 string(defaultValue: 'azure', description: 'Tag for selecting Robot test to be run', name: 'ROBOT_RUN_TAG')
60 // Configuration of thresholds for Robot tests
61 string(defaultValue: '99.0', description: '% passed Robot tests to mark the build as passed', name: 'ROBOT_PASS_THRESHOLD')
62 string(defaultValue: '80.0', description: '% passed Robot tests to mark the build as unstable (if lower, it will be failed)', name: 'ROBOT_UNSTABLE_THRESHOLD')
67 SOURCE_IMAGE_NAME = 'Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest'
68 FLAVOR_NAME = 'Standard_D4as_v4'
69 K8S_FLAVOR_NAME = 'Standard_A2_v2'
70 USE_PAAS_K8S = 'FALSE'
72 RESOURCE_GROUP = 'OSM_CICD_GROUP'
73 VNET_NAME = 'OSM-CICD-net'
74 VIM_MGMT_NET = 'OSM-CICD-subnet'
75 VIM_TARGET = 'azure-etsi'
76 AZURE_FLAVORS_PATTERN = '^Standard'
77 AZURE_REGION = 'westeurope'
78 OSM_VIM_MULTIPLIER_TIMEOUT = '4.0'
81 // Openstack environment
82 CLOUD_TYPE = 'openstack'
83 OS_CLOUD = 'etsi-vim-telefonica'
84 OS_DOMAIN_NAME = 'Default'
85 VIM_TARGET = 'etsi-vim-telefonica'
86 VIM_MGMT_NET = 'osm-ext'
87 VIM_EXT_NET = 'osm-ext'
88 OVERRIDES = '--override-epa'
89 FLAVOR_NAME = 'osm.sanity'
90 SOURCE_IMAGE_NAME = 'ubuntu22.04'
91 SSH_KEY_NAME = 'niv2020'
93 SDNC_PASSWORD = 'karaf'
94 SDNC_URL = 'http://172.21.248.11:8181'
95 SDNC_TYPE = 'onos_vpls'
97 // Google Cloud environment
99 GCP_PROJECT = 'telcocloudpocs'
100 GCP_ZONE = 'europe-west1-b'
101 GCP_MACHINE_TYPE = 'e2-standard-4'
103 GCP_IMAGE_PROJECT = 'ubuntu-os-cloud'
104 GCP_IMAGE_FAMILY = 'ubuntu-2204-lts'
106 VIM_MGMT_NET = 'default'
107 OSM_VIM_MULTIPLIER_TIMEOUT = '4.0'
114 image "${params.TEST_IMAGE}:${params.TEST_TAG}"
115 args "-u root:root --entrypoint=''"
119 stage('Set environment') {
122 if (params.SSH_PUBLIC_KEY == '') {
123 // Gererate SSH private and public keys
124 sh "mkdir -m 700 ~/.ssh"
125 sh "ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''"
128 // SSH private and public keys from Jenkins credentials
129 sh "mkdir -m 700 ~/.ssh"
130 withCredentials([file(credentialsId: "${params.SSH_PRIVATE_KEY}", variable: 'SSHPATH')]) {
131 sh "cp ${SSHPATH} ~/.ssh/id_rsa"
133 withCredentials([file(credentialsId: "${params.SSH_PUBLIC_KEY}", variable: 'SSHPATH')]) {
134 sh "cp ${SSHPATH} ~/.ssh/id_rsa.pub"
136 sh "chmod 400 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub"
138 // This file is used by some Robot test (BASIC12)
139 sh "cp ~/.ssh/id_rsa ~/osm_id_rsa"
142 withCredentials([file(credentialsId: "${params.AZURE_CREDENTIALS}", variable: 'PATH')]) {
143 sh "cp ${PATH} ~/azure-creds.json"
146 AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \
147 AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \
148 AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \
149 az login --service-principal --username \$AZURE_CLIENT_ID --password \$AZURE_SECRET --tenant \$AZURE_TENANT
151 sh "az vm list -o table"
155 stage('Create k8s cluster') {
157 sh "/robot-systest/cloud-scripts/create-k8s.sh"
158 sh "cat /robot-systest/results/k8s_environment.rc"
161 stage('Install OSM') {
163 sh "/robot-systest/cloud-scripts/create-osm-vm.sh"
164 sh "cat /robot-systest/results/osm_environment.rc"
165 sh ". /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/remote-install-osm.sh"
168 stage('Add VIM and K8s cluster to OSM') {
171 . /robot-systest/results/osm_environment.rc ; \
172 . /robot-systest/results/k8s_environment.rc ; \
175 export AZURE_CLIENT_ID=\$(cat ~/azure-creds.json | jq -r .clientId | sed s/[{}]//g) ; \
176 export AZURE_SECRET=\$(cat ~/azure-creds.json | jq -r .clientSecret) ; \
177 export AZURE_TENANT=\$(cat ~/azure-creds.json | jq -r .tenantId) ; \
178 export AZURE_SUBSCRIPTION_ID=\$(cat ~/azure-creds.json | jq -r .subscriptionId) ; \
179 /robot-systest/cloud-scripts/add-vim-and-k8scluster.sh
184 stage('Run Robot tests') {
187 . /robot-systest/results/osm_environment.rc ; \
188 . /robot-systest/results/k8s_environment.rc ; \
189 /robot-systest/run_test.sh -t ${params.ROBOT_RUN_TAG}
196 echo "Retrieve container logs"
198 . /robot-systest/results/osm_environment.rc ; \
199 /robot-systest/cloud-scripts/remote-extract-logs.sh
204 sh "cp -var /robot-systest/results /robot-systest/reports/* ."
205 archiveArtifacts artifacts: 'results/**/*', fingerprint: true
207 echo "Updates the Robot dashboard in Jenkins"
208 robot outputPath: '.', passThreshold: "${params.ROBOT_PASS_THRESHOLD}", unstableThreshold: "${params.ROBOT_UNSTABLE_THRESHOLD}"
210 echo "Destroy the K8s cluster"
211 sh '. /robot-systest/results/k8s_environment.rc ; /robot-systest/cloud-scripts/delete-k8s.sh'
213 echo "Destroy the OSM host"
214 sh '. /robot-systest/results/osm_environment.rc ; /robot-systest/cloud-scripts/delete-osm-vm.sh'
215 sh "az vm list -o table"