1
- // Copyright (c) 2023, Oracle and/or its affiliates.
1
+ // Copyright (c) 2023, 2024, Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
//
4
4
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
+
5
8
pipeline {
6
9
agent { label 'large' }
7
10
options {
8
11
timeout(time: 1800, unit: 'MINUTES')
9
- disableConcurrentBuilds()
12
+ // disableConcurrentBuilds()
10
13
}
11
14
12
15
tools {
@@ -49,12 +52,9 @@ pipeline {
49
52
50
53
start_time = sh(script: 'date +"%Y-%m-%d %H:%M:%S"', returnStdout: true).trim()
51
54
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'}"
54
55
kubeconfig_file = "${WORKSPACE}/terraform/${CLUSTER_NAME}_kubeconfig"
55
- MAVEN_PROFILE_NAME = "${env.JOB_NAME == 'wko-oke-nightly-parallel' ? 'oke-gate' : 'oke-gate'}"
56
56
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
+
58
58
}
59
59
60
60
parameters {
@@ -64,6 +64,11 @@ pipeline {
64
64
defaultValue: ''
65
65
)
66
66
67
+ booleanParam(name: 'PARALLEL_RUN',
68
+ description: 'Runs tests in parallel. Default is false.',
69
+ defaultValue: false
70
+ )
71
+
67
72
string(name: 'OKE_KUBE_VERSION',
68
73
description: 'kube version for oke cluster',
69
74
defaultValue: '1.28.2'
@@ -95,7 +100,22 @@ pipeline {
95
100
'1.9.9'
96
101
]
97
102
)
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
+ )
99
119
string(name: 'NUMBER_OF_THREADS',
100
120
description: 'Number of threads to run the classes in parallel, default is 3.',
101
121
defaultValue: "3"
391
411
sh ${WORKSPACE}/terraform/oke.create.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
392
412
393
413
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == '\"$CLUSTER_NAME}\"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
414
+
394
415
echo "clusterIp : $clusterIP"
395
416
clusterPublicIP=${clusterIP:1:-6}
396
417
echo " clusterPublicIP : ${clusterPublicIP}"
@@ -455,12 +476,13 @@ EOF
455
476
environment {
456
477
runtime_path = "${WORKSPACE}/bin:${PATH}"
457
478
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"
459
480
460
481
}
461
482
steps {
462
483
script {
463
484
def res = 0
485
+ currentBuild.description = "${GIT_BRANCH} ${MAVEN_PROFILE_NAME}"
464
486
res = sh(script: '''
465
487
if [ -z "${IT_TEST}" ] && [ "${MAVEN_PROFILE_NAME}" = "integration-tests" ]; then
466
488
echo 'ERROR: All tests cannot be run with integration-tests profile'
@@ -505,17 +527,25 @@ EOF
505
527
fi
506
528
507
529
export K8S_NODEPORT_HOST=${NODE_IP}
530
+ export AVAILABILITY_DOMAIN=${availability_domain}
508
531
NODE_IP=`kubectl get nodes -o wide| awk '{print $7}'| head -n2 | tail -n1`
509
532
echo "second node external IP ${NODE_IP}"
510
533
export NODE_IP=${NODE_IP}
511
534
512
535
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
+
513
544
514
- mt_private_ip=`oci network private-ip get --private-ip-id "${mt_privateip_id}" | jq -r '.data | ."ip-address"'`
515
545
516
546
if [ -z "${mt_private_ip}" ]; then
517
547
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}
519
549
exit -1
520
550
fi
521
551
export NFS_SERVER=$mt_private_ip
554
584
echo "-Dwko.it.grafana.chart.version=\"${GRAFANA_CHART_VERSION}\"" >> ${WORKSPACE}/.mvn/maven.config
555
585
echo "-Dwko.it.collect.logs.on.success=\"${COLLECT_LOGS_ON_SUCCESS}\"" >> ${WORKSPACE}/.mvn/maven.config
556
586
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
558
588
559
589
echo "${WORKSPACE}/.mvn/maven.config contents:"
560
590
cat "${WORKSPACE}/.mvn/maven.config"
@@ -592,11 +622,12 @@ EOF
592
622
export PATH="${WORKSPACE}/bin:${PATH}"
593
623
export KUBECONFIG=${kubeconfig_file}
594
624
export OCI_CLI_CONFIG_FILE=${WORKSPACE}/oci/config
625
+ export AVAILABILITY_DOMAIN=${availability_domain}
595
626
export OCI_CLI_PROFILE=${oci_profile}
596
627
mkdir -m777 -p ${result_root}/kubelogs
597
628
mkdir -m777 -p "${WORKSPACE}/logdir/${BUILD_TAG}/wl_k8s_test_results"
598
629
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}
600
631
601
632
'''
602
633
@@ -612,11 +643,19 @@ EOF
612
643
sh '''
613
644
export PATH="${WORKSPACE}/bin:${PATH}"
614
645
export KUBECONFIG=${kubeconfig_file}
646
+ export AVAILABILITY_DOMAIN=${availability_domain}
615
647
616
648
echo 'Remove old OKE cluster (if any)...'
617
649
618
650
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
620
659
fi
621
660
rm -f ${jenkins_home_directory}/.oci/config
622
661
rm -f ${jenkins_home_directory}/.oci/oci-signing-key.pem
0 commit comments