diff --git a/.ci/jenkins/Jenkinsfile.deploy b/.ci/jenkins/Jenkinsfile.deploy index 917a982b5..6e45bd6db 100644 --- a/.ci/jenkins/Jenkinsfile.deploy +++ b/.ci/jenkins/Jenkinsfile.deploy @@ -1,8 +1,6 @@ @Library('jenkins-pipeline-shared-libraries')_ helper = null -testsFailed = false - gitChanges = false pipeline { @@ -54,10 +52,6 @@ pipeline { assert helper.getBuildBranch() == util.getReleaseBranchFromVersion(helper.getProjectVersion()) } } - - // Verify we have the connectivity to Openshift - // TODO: Uncomment this line when we have the Openshift credentials - //openshift.loginOpenshift() } } post { @@ -107,7 +101,6 @@ pipeline { } } - stage('Setup Minikube') { steps { script { @@ -143,7 +136,7 @@ pipeline { stage('Build Kogito Operator') { steps { - sh "source ~/virtenvs/cekit/bin/activate && make BUILDER=${env.CONTAINER_ENGINE}" + sh "make BUILDER=${env.CONTAINER_ENGINE}" } post { unsuccessful { @@ -171,6 +164,15 @@ pipeline { } } } + + stage('Install Ansible') { + steps { + script { + installAnsible() + } + } + } + stage('Run OLM tests') { when { expression { @@ -189,55 +191,6 @@ pipeline { } } - stage('Push Operator Image to Openshift Registry') { - steps { - script { - echo 'Skipping pushing operator image to Openshift registry' - //container.loginOpenshiftRegistry() - //container.tagImage("quay.io/kiegroup/${env.OPERATOR_IMAGE_NAME}:${getOperatorVersion()}", - //helper.buildTempOpenshiftImageFullName()) - //container.pushImage(helper.buildTempOpenshiftImageFullName()) - } - } - } - - stage('Run BDD tests') { - when { - beforeOptions true - expression { - return helper.shouldLaunchTests() - } - } - stages { - stage('Run full testing') { - options { - timeout(time: 360, unit: 'MINUTES') - } - steps { - script { - // Catch and set unstable so the temp image is still pushed and we get the deployment properties, - // in case we decide to continue in the release - try { - sh "make run-tests timeout=360 load_factor=2 concurrent=2 smoke=${params.SMOKE_TESTS_ONLY} ${getBDDParameters()}" - } catch (err) { - testsFailed = true - util.archiveConsoleLog() - } - } - } - post { - always { - archiveArtifacts artifacts: 'test/logs/**/*.log', allowEmptyArchive: false - junit testResults: 'test/logs/**/junit.xml', allowEmptyResults: false - } - cleanup { - sh 'cd test && go run scripts/prune_namespaces.go' - } - } - } - } - } - stage('Push to registry') { when { expression { return !params.SKIP_DEPLOY } @@ -301,11 +254,6 @@ pipeline { script { properties.writeToFile(env.PROPERTIES_FILE_NAME) archiveArtifacts(artifacts: env.PROPERTIES_FILE_NAME) - - // Verify here if BDD tests due to test errors or build error - if (testsFailed && currentBuild.currentResult == 'SUCCESS') { - error 'There was a test execution failure' - } } } unsuccessful { @@ -328,53 +276,15 @@ void sendNotification() { } } -String getOperatorVersion() { - return sh(script: 'source ./hack/env.sh > /dev/null && echo $(getOperatorVersion)', returnStdout: true).trim() -} - -// Special method to get the Openshift API in the lock because env is not accessible yet -void getLockOpenshiftApi() { - withCredentials([string(credentialsId: 'OPENSHIFT_API', variable: 'OPENSHIFT_API')]) { - return env.OPENSHIFT_API - } -} - -//////////////////////////////////////////////////////////////////////// -// BDD parameters - -String getBDDParameters() { - Map testParamsMap = helper.getBDDCommonParameters(true) - - testParamsMap.putAll(helper.getBDDBuildImageParameters('KOGITO_IMAGES')) - testParamsMap.putAll(helper.getBDDServicesImageParameters('KOGITO_IMAGES')) - - testParamsMap['image_cache_mode'] = params.EXAMPLES_IMAGES_CACHE_MODE - testParamsMap.putAll(helper.getBDDRuntimeImageParameters('EXAMPLES_IMAGES')) - - // Add tags - def tags = [] - if (params.BDD_TEST_TAGS) { - tags.add(params.BDD_TEST_TAGS) - } - if (params.SKIP_NATIVE_TESTS) { - tags.add("~${helper.getNativeTag()}") - } - if (params.SKIP_NON_NATIVE_TESTS) { - tags.add("~${helper.getNonNativeTag()}") - } - testParamsMap['tags'] = tags.join('&&') - - String testParams = testParamsMap.findAll { entry -> entry.getValue() } - .collect { entry -> "${entry.getKey()}=\"${entry.getValue()}\"" }.join(' ') - echo "BDD parameters = ${testParams}" - return testParams -} - -void setupMinikube() { - // Start minikube - minikube.minikubeMemory = '12g' - minikube.start() - - minikube.waitForMinikubeStarted() - minikube.waitForMinikubeRegistry() +// TODO: move this to the kogito-ci-build image +void installAnsible() { + sh ''' + export TZ=America/New_York + sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime + echo $TZ | sudo tee /etc/timezone + sudo apt install -y software-properties-common + sudo add-apt-repository --yes --update ppa:ansible/ansible + sudo apt update + sudo apt install -y ansible + ''' } diff --git a/.ci/jenkins/scripts/minikube.groovy b/.ci/jenkins/scripts/minikube.groovy deleted file mode 100644 index 1b921db4e..000000000 --- a/.ci/jenkins/scripts/minikube.groovy +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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. - */ -minikubeVersion = env.MINIKUBE_VERSION ?: '1.30.1' -minikubeKubernetesVersion = env.KUBERNETES_VERSION ?: '1.26.3' -minikubeContainerEngine = env.CONTAINER_ENGINE ?: 'docker' - -minikubeCpus = 'max' -minikubeMemory = '4g' -minikubeAddons = [ 'registry', 'metrics-server' ] -minikubeRegistryMirror = env.DOCKER_REGISTRY_MIRROR ?: '' -minikubeInsecureRegistries = [] - -void start(boolean debug = false) { - preChecks() - - def minikubeOpts = [ - "--driver=${minikubeContainerEngine}", - "--kubernetes-version ${minikubeKubernetesVersion}", - "--cpus ${minikubeCpus}", - "--memory ${minikubeMemory}", - // Default insecure registries added - '--insecure-registry "192.168.0.0/16"', - '--insecure-registry "localhost:5000"', - ] - minikubeOpts.addAll(minikubeAddons.collect { "--addons ${it}" }) - minikubeOpts.addAll(minikubeInsecureRegistries.collect { "--insecure-registry '${it}'" }) - if (minikubeRegistryMirror) { - minikubeOpts.addAll([ - "--registry-mirror http://${minikubeRegistryMirror}", - "--insecure-registry ${minikubeRegistryMirror}", - ]) - } - - println "Start minikube with options ${minikubeOpts}" - sh """ - minikube delete - minikube start ${minikubeOpts.join(' ')} - minikube status - - kubectl version - kubectl get pods -A - """ - - if (debug) { - sh 'kubectl get events -n kube-system' - } -} - -void waitForMinikubeStarted() { - println 'Wait for Minikube components to be in Running state' - def minikubeStatus = sh(returnStatus: true, script: ''' - set -x - source ./hack/kube-utils.sh - MINIKUBE_COMPONENTS=(etcd kube-apiserver kube-controller-manager kube-scheduler) - for component in "${MINIKUBE_COMPONENTS[@]}" - do - echo "Check component '${component}' is in 'Running' state" - waitKubeSystemForPodReady "-l tier=control-plane -l component=${component}" - done - - echo "Check kube-dns is in 'Running' state" - waitKubeSystemForPodReady "-l k8s-app=kube-dns" - ''') - if (minikubeStatus != 0) { - error 'Error starting Minikube ...' - } -} - -void waitForMinikubeRegistry() { - println 'Wait for Minikube registry to be in Running state' - def minikubeStatus = sh(returnStatus: true, script: ''' - set -x - kubectl get pods -A - source ./hack/kube-utils.sh - waitKubeSystemForPodReady "-l kubernetes.io/minikube-addons=registry -l actual-registry=true" - ''') - if (minikubeStatus != 0) { - error 'Error waiting for Minikube registry ...' - } -} - -void preChecks() { - sh """ - ${minikubeContainerEngine} info - - if [[ ! \$(command -v minikube) ]]; then - sudo ./hack/ci/install-minikube.sh /usr/local/bin - sudo chmod +x /usr/local/bin/minikube - fi - """ -} - -void stop() { - if (sh(returnStatus: true, script: 'which minikube') == 0) { - sh ''' - minikube delete - ''' - } -} - -String getImageRegistry() { - return sh(returnStdout: true, script: 'echo "$(minikube ip):5000"').trim() -} - -return this diff --git a/hack/ci/install-minikube.sh b/hack/ci/install-minikube.sh deleted file mode 100755 index 9a1e18443..000000000 --- a/hack/ci/install-minikube.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/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 -e - -install_path=$1 -default_minikube_version=v1.31.1 - -if [[ -z ${MINIKUBE_VERSION} ]]; then - MINIKUBE_VERSION=$default_minikube_version -fi - -download_path="${HOME}/.minikube/download/" - -echo "---> Minikube version to install is ${MINIKUBE_VERSION}" - -# get the arch and os -arch=$(uname -m) -case $(uname -m) in -"x86_64") arch="amd64" ;; -"aarch64") arch="arm64" ;; -esac -os=$(uname | awk '{print tolower($0)}') - -if [ -e "${download_path}/minikube-${os}-${arch}" ]; then - echo "---> Minikube ${MINIKUBE_VERSION} (OS ${os} Architecture ${arch}) already exists in '${download_path}', skipping downloading" -else - mkdir -p "${download_path}" - cd "${download_path}" - echo "---> Downloading minikube ${MINIKUBE_VERSION} (OS ${os} Architecture ${arch}) to ${download_path}" - curl -LO "https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-${os}-${arch}" - cd - -fi - -if [ -z "${install_path}" ]; then - install_path="${HOME}/runner/bin" - [[ "${os}" == "darwin" ]]; install_path="${HOME}/runner/bin" -fi - -echo "---> Ensuring minikube installation at ${install_path}" - -mkdir -p "${install_path}" -chmod +x "${install_path}" -cp "${download_path}/minikube-${os}-${arch}" "${install_path}/minikube"