1- // Copyright (c) 2023, Oracle and/or its affiliates.
1+ // Copyright (c) 2023, 2024, Oracle and/or its affiliates.
22// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33//
44
5+ CRON_SETTINGS = '''H 3 * * * % MAVEN_PROFILE_NAME=oke-gate;CLUSTER_NAME=seqone;PARALLEL_RUN=false
6+ H 1 * * * % MAVEN_PROFILE_NAME=oke-sequential1;CLUSTER_NAME=seqtwo;PARALLEL_RUN=false'''
7+
58pipeline {
69 agent { label 'large' }
710 options {
811 timeout(time: 1800, unit: 'MINUTES')
9- disableConcurrentBuilds()
12+ // disableConcurrentBuilds()
1013 }
1114
1215 tools {
@@ -49,12 +52,9 @@ pipeline {
4952
5053 start_time = sh(script: 'date +"%Y-%m-%d %H:%M:%S"', returnStdout: true).trim()
5154 wle_download_url="https://github.com/oracle/weblogic-logging-exporter/releases/latest"
52-
53- CLUSTER_NAME = "${env.JOB_NAME == 'wko-oke-nightly-parallel' ? 'parcluster' : 'seqcluster'}"
5455 kubeconfig_file = "${WORKSPACE}/terraform/${CLUSTER_NAME}_kubeconfig"
55- MAVEN_PROFILE_NAME = "${env.JOB_NAME == 'wko-oke-nightly-parallel' ? 'oke-gate' : 'oke-gate'}"
5656 availability_domain = "${env.JOB_NAME == 'wko-oke-nightly-parallel' ? 'mFEn:PHX-AD-1' : 'mFEn:PHX-AD-1'}"
57- PARALLEL_RUN = "${env.JOB_NAME == 'wko-oke-nightly-parallel' ? true : false}"
57+
5858 }
5959
6060 parameters {
@@ -64,6 +64,11 @@ pipeline {
6464 defaultValue: ''
6565 )
6666
67+ booleanParam(name: 'PARALLEL_RUN',
68+ description: 'Runs tests in parallel. Default is false.',
69+ defaultValue: false
70+ )
71+
6772 string(name: 'OKE_KUBE_VERSION',
6873 description: 'kube version for oke cluster',
6974 defaultValue: '1.28.2'
@@ -95,7 +100,22 @@ pipeline {
95100 '1.9.9'
96101 ]
97102 )
98-
103+ choice(name: 'CLUSTER_NAME',
104+ description: 'Oke cluster name.',
105+ choices: [
106+ 'parone',
107+ 'seqone',
108+ 'seqtwo'
109+ ]
110+ )
111+ choice(name: 'MAVEN_PROFILE_NAME',
112+ description: 'Profile to use in mvn command to run the tests. Possible values are oke-gate, oke-sequential1,oke-parallelnew. Refer to weblogic-kubernetes-operator/integration-tests/pom.xml on the branch.',
113+ choices: [
114+ 'oke-gate',
115+ 'oke-sequential1',
116+ 'oke-parallelnew'
117+ ]
118+ )
99119 string(name: 'NUMBER_OF_THREADS',
100120 description: 'Number of threads to run the classes in parallel, default is 3.',
101121 defaultValue: "3"
391411 sh ${WORKSPACE}/terraform/oke.create.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
392412
393413 clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == '\"$CLUSTER_NAME}\"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
414+
394415 echo "clusterIp : $clusterIP"
395416 clusterPublicIP=${clusterIP:1:-6}
396417 echo " clusterPublicIP : ${clusterPublicIP}"
@@ -455,12 +476,13 @@ EOF
455476 environment {
456477 runtime_path = "${WORKSPACE}/bin:${PATH}"
457478 clusterName = "${CLUSTER_NAME}"
458- FSS_DIR = "/oketest1,/oketest2,/oketest3,/oketest4,/oketest5,/oketest6,/oketest7,/oketest8,/oketest9,/oketest10,/oketest11,/oketest12,/oketest13,/oketest14,/oketest15 "
479+ FSS_DIR = "/oketest1,/oketest2,/oketest3"
459480
460481 }
461482 steps {
462483 script {
463484 def res = 0
485+ currentBuild.description = "${GIT_BRANCH} ${MAVEN_PROFILE_NAME}"
464486 res = sh(script: '''
465487 if [ -z "${IT_TEST}" ] && [ "${MAVEN_PROFILE_NAME}" = "integration-tests" ]; then
466488 echo 'ERROR: All tests cannot be run with integration-tests profile'
@@ -505,17 +527,25 @@ EOF
505527 fi
506528
507529 export K8S_NODEPORT_HOST=${NODE_IP}
530+ export AVAILABILITY_DOMAIN=${availability_domain}
508531 NODE_IP=`kubectl get nodes -o wide| awk '{print $7}'| head -n2 | tail -n1`
509532 echo "second node external IP ${NODE_IP}"
510533 export NODE_IP=${NODE_IP}
511534
512535 mt_privateip_id=`oci fs mount-target list --compartment-id=${compartment_ocid} --display-name=${clusterName}-mt --availability-domain=${availability_domain} | jq -r '.data[] | ."private-ip-ids"[]'`
536+ # Check if the mt_privateip_id is an array
537+ if [ "$(declare -p mt_privateip_id 2>/dev/null | grep -o 'declare -a')" == "declare -a" ]; then
538+ # Select first
539+ mt_private_ip=`oci network private-ip get --private-ip-id "${mt_privateip_id[0]}" | jq -r '.data | ."ip-address"'`
540+ else
541+ mt_private_ip=`oci network private-ip get --private-ip-id "${mt_privateip_id}" | jq -r '.data | ."ip-address"'`
542+ fi
543+
513544
514- mt_private_ip=`oci network private-ip get --private-ip-id "${mt_privateip_id}" | jq -r '.data | ."ip-address"'`
515545
516546 if [ -z "${mt_private_ip}" ]; then
517547 echo "Mount Target was not setup properly , clean up Kubernetes cluster"
518- sh ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
548+ sh ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform ${AVAILABILITY_DOMAIN}
519549 exit -1
520550 fi
521551 export NFS_SERVER=$mt_private_ip
554584 echo "-Dwko.it.grafana.chart.version=\"${GRAFANA_CHART_VERSION}\"" >> ${WORKSPACE}/.mvn/maven.config
555585 echo "-Dwko.it.collect.logs.on.success=\"${COLLECT_LOGS_ON_SUCCESS}\"" >> ${WORKSPACE}/.mvn/maven.config
556586 echo "-Dwko.it.remoteconsole.version=\"${REMOTECONSOLE_VERSION}\"" >> ${WORKSPACE}/.mvn/maven.config
557- echo "-Djdk.httpclient.allowRestrictedHeaders=\"host\"" >> ${WORKSPACE}/.mvn/maven.config
587+ echo "-Djdk.httpclient.allowRestrictedHeaders=\"host\"" >> ${WORKSPACE}/.mvn/maven.config
558588
559589 echo "${WORKSPACE}/.mvn/maven.config contents:"
560590 cat "${WORKSPACE}/.mvn/maven.config"
@@ -592,11 +622,12 @@ EOF
592622 export PATH="${WORKSPACE}/bin:${PATH}"
593623 export KUBECONFIG=${kubeconfig_file}
594624 export OCI_CLI_CONFIG_FILE=${WORKSPACE}/oci/config
625+ export AVAILABILITY_DOMAIN=${availability_domain}
595626 export OCI_CLI_PROFILE=${oci_profile}
596627 mkdir -m777 -p ${result_root}/kubelogs
597628 mkdir -m777 -p "${WORKSPACE}/logdir/${BUILD_TAG}/wl_k8s_test_results"
598629 sudo mv -f ${result_root}/* "${WORKSPACE}/logdir/${BUILD_TAG}/wl_k8s_test_results"
599- ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
630+ ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform ${AVAILABILITY_DOMAIN}
600631
601632 '''
602633
@@ -612,11 +643,19 @@ EOF
612643 sh '''
613644 export PATH="${WORKSPACE}/bin:${PATH}"
614645 export KUBECONFIG=${kubeconfig_file}
646+ export AVAILABILITY_DOMAIN=${availability_domain}
615647
616648 echo 'Remove old OKE cluster (if any)...'
617649
618650 if [ -f "$OCI_PROP_FILE" ] && [ -f "${WORKSPACE}/terraform/oke.delete.sh" ]; then
619- ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
651+ ${WORKSPACE}/terraform/oke.delete.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform ${AVAILABILITY_DOMAIN}
652+ fi
653+
654+ if [ "${MAVEN_PROFILE_NAME}" = "oke-gate" ]; then
655+ compname="wkt"
656+ wkt_compartment_ocid=$(oci iam compartment list --compartment-id-in-subtree true --all | jq --arg compname "$compname" '.data[] | select(."name"==$compname)' | jq -r ."id")
657+ sec_list_id=$(oci network security-list list --compartment-id="$wkt_compartment_ocid" --display-name=Security-List-wktiso1 | jq -r '.data[] | ."id"')
658+ oci network security-list update --security-list-id="$sec_list_id" --ingress-security-rules='[{"description": "east west","icmp-options": null,"is-stateless": false,"protocol": "all","source": "10.196.0.0/16","source-type": "CIDR_BLOCK","tcp-options": null,"udp-options": null},{"description": null,"icmp-options": {"code": null,"type": 3},"is-stateless": false,"protocol": "1", "source": "10.196.0.0/16", "source-type": "CIDR_BLOCK","tcp-options": null, "udp-options": null}, {"description": null, "icmp-options": {"code": 4, "type": 3},"is-stateless": false, "protocol": "1", "source": "0.0.0.0/0","source-type": "CIDR_BLOCK", "tcp-options": null, "udp-options": null}, {"description": null, "icmp-options": null, "is-stateless": false, "protocol": "6","source": "0.0.0.0/0", "source-type": "CIDR_BLOCK", "tcp-options": null, "udp-options": null}, {"description": null, "icmp-options": null, "is-stateless": false,"protocol": "6", "source": "0.0.0.0/0", "source-type": "CIDR_BLOCK", "tcp-options": {"destination-port-range": {"max": 22, "min": 22}, "source-port-range": null}, "udp-options": null}]' --egress-security-rules='[{"description": null, "destination": "0.0.0.0/0", "destinationType": "CIDR_BLOCK", "icmpOptions": null, "isStateless": false, "protocol": "all", "tcpOptions": null, "udpOptions": null}, {"description": null, "destination": "oci-phx-objectstorage", "destinationType": "SERVICE_CIDR_BLOCK", "icmpOptions": null, "isStateless": false, "protocol": "6", "tcpOptions": null, "udpOptions": null}]' --force
620659 fi
621660 rm -f ${jenkins_home_directory}/.oci/config
622661 rm -f ${jenkins_home_directory}/.oci/oci-signing-key.pem
0 commit comments