Skip to content

Commit 623a314

Browse files
authored
Merge pull request #102 from oracle/integration-test-update
Integration test update
2 parents 03831e7 + a76e68a commit 623a314

File tree

2 files changed

+147
-159
lines changed

2 files changed

+147
-159
lines changed

src/integration-tests/kubernetes/command-job-template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ metadata:
44
name: weblogic-command-job
55
namespace: default
66
spec:
7-
backoffLimit: 0
87
template:
98
metadata:
109
spec:

wercker.yml

Lines changed: 147 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
#
1111
# Werkcer workflow looks like this:
1212
#
13-
# build -> integration-tests -> promote-image
14-
# if branch == master
13+
# build -> integration-tests (1.7.9)
14+
# -> integration-tests (1.8.5)
15+
# -> quality
1516
#
1617

1718
box:
@@ -23,165 +24,153 @@ box:
2324
# This is the main build pipeline that builds the codebase and runs unit tests.
2425
build:
2526
steps:
26-
- script:
27-
name: Hello
28-
code: |
29-
echo "Building Oracle WebLogic Server Kubernetes Operator..."
30-
echo "The commit id is $WERCKER_GIT_COMMIT"
31-
- script:
32-
name: Install pre-reqs
33-
code: |
34-
yum -y install tar gzip
35-
- java/maven:
36-
goals: clean install
37-
version: 3.5.2
38-
cache_repo: true
39-
- script:
40-
name: Copy built-artifacts into the image
41-
code: |
42-
mkdir /operator
43-
cp -R src/main/scripts/* /operator/
44-
cp target/weblogic-kubernetes-operator-0.1.0-alpha-SNAPSHOT.jar /operator/weblogic-kubernetes-operator.jar
45-
- script:
46-
name: Remove things we do not want in the Docker image in order to reduce size of image
47-
code: |
48-
# remove wercker directory
49-
# rm -rf /pipeline
50-
# remove unneeded RPMs and clean up the YUM cache
51-
yum -y remove tar gzip
52-
yum clean all
53-
54-
# push the image to quay.io using the GIT commit id (first 8 chars) as the tag
55-
# this image needs to be available to the integration-test pipeline for testing
56-
- internal/docker-push:
57-
username: $QUAY_USERNAME
58-
password: $QUAY_PASSWORD
59-
email: $QUAY_EMAIL
60-
repository: quay.io/markxnelson/weblogic-kubernetes-operator
61-
tag: $WERCKER_GIT_COMMIT
62-
working-dir: "/operator"
63-
cmd: "operator.sh"
64-
env: "PATH=$PATH:/operator"
65-
66-
67-
# This pipeline runs the integration tests against a real k8s cluster.
68-
integration-test: # run in weblogic container so that wlst is available
27+
- script:
28+
name: Hello
29+
code: |
30+
echo "Building Oracle WebLogic Server Kubernetes Operator..."
31+
echo "The branch and commit id are $WERCKER_GIT_BRANCH, $WERCKER_GIT_COMMIT"
32+
- script:
33+
name: Install pre-reqs
34+
code: |
35+
yum -y install tar gzip
36+
- java/maven:
37+
goals: clean install
38+
version: 3.5.2
39+
cache_repo: true
40+
- script:
41+
name: Copy built-artifacts into the image
42+
code: |
43+
mkdir /operator
44+
cp -R src/main/scripts/* /operator/
45+
cp target/weblogic-kubernetes-operator-0.1.0-alpha-SNAPSHOT.jar /operator/weblogic-kubernetes-operator.jar
46+
- script:
47+
name: Remove things we do not want in the Docker image in order to reduce size of image
48+
code: |
49+
yum -y remove tar gzip
50+
yum clean all
51+
# push the image to quay.io using the GIT branch as the tag
52+
# this image needs to be available to the integration-test pipeline for testing
53+
- internal/docker-push:
54+
username: $QUAY_USERNAME
55+
password: $QUAY_PASSWORD
56+
email: $QUAY_EMAIL
57+
repository: quay.io/markxnelson/weblogic-kubernetes-operator
58+
tag: ${WERCKER_GIT_BRANCH//[_/]/-}
59+
working-dir: "/operator"
60+
cmd: "operator.sh"
61+
env: "PATH=$PATH:/operator"
62+
63+
# This pipeline runs the integration tests against a k8s cluster on OCI.
64+
integration-test:
6965
steps:
70-
- script:
71-
name: Run integration tests
72-
code: |
73-
# Current plan is that we will use the bastion machine in our OCI tenancy, that has access to our
74-
# clusters, one 1.7 and one 1.8, and it will run the tests.
75-
# It should clone the repo, checkout the desired commit, grab the desired docker image (tagged with the
76-
# commit id) and then run the src/integration-tests/bash/run.sh (etc.) and report back results.
77-
# This approach means we do not need to expose any NodePorts on the cluster through the OCI
78-
# firewall to the public internet, just within our OCI compartment.
79-
80-
# On the bastion:
81-
# set up kubeconfig is set up to point to the cluster in OCI
82-
# create a job yaml that mounts the PV's and empties them
83-
# kubectl create job ....
84-
# /pipeline/source/weblogic-kubernetes-operator/src/integration-tests/bash/clean.sh
85-
# /pipeline/weblogic-kubernetes-operator/src/integration-tests/bash/run.sh
86-
87-
cp /etc/hosts /pipeline/hosts
88-
sed -i "$ a ${K8S_17_WORKER_IP} ${K8S_17_WORKER_HOSTNAME}" /pipeline/hosts
89-
cp /pipeline/hosts /etc/hosts
90-
91-
# Update KUBECONFIG for K8S 1.7 cluster
92-
export K8S_NODEPORT_HOST="${K8S_17_WORKER_HOSTNAME}"
93-
sed -i -e "s,%ADDRESS%,https://$K8S_17_MASTER_IP:443,g" /pipeline/source/build/kube.config
94-
sed -i -e "s,%CLIENT_CERT_DATA%,$K8S_17_CLIENT_CERT_DATA,g" /pipeline/source/build/kube.config
95-
sed -i -e "s,%CLIENT_KEY_DATA%,$K8S_17_CLIENT_KEY_DATA,g" /pipeline/source/build/kube.config
96-
export KUBECONFIG="/pipeline/source/build/kube.config"
97-
98-
# running on Wercker
99-
export WERCKER="true"
100-
101-
# install kubectl
102-
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
103-
chmod +x ./kubectl
104-
mv ./kubectl /usr/local/bin/kubectl
105-
106-
# install maven, includes java as dependency
107-
curl -LO http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo
108-
mv epel-apache-maven.repo /etc/yum.repos.d/
109-
yum install -y apache-maven
110-
export M2_HOME="/usr/share/apache-maven"
111-
export PATH=$M2_HOME/bin:$PATH
112-
113-
# install opensll
114-
yum install -y openssl
115-
116-
export HOST_PATH="/scratch"
117-
export PV_ROOT=$HOST_PATH
118-
export RESULT_ROOT="/pipeline/output/k8s_dir"
119-
mkdir -m 777 -p $RESULT_ROOT
120-
export PROJECT_ROOT="/pipeline/source"
121-
/pipeline/source/src/integration-tests/bash/cleanup.sh
122-
123-
# create pull secrets
124-
kubectl delete secret docker-store --ignore-not-found=true
125-
kubectl create secret docker-registry docker-store --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
126-
127-
kubectl delete ns test1 --ignore-not-found=true
128-
kubectl create ns test1
129-
kubectl create secret docker-registry docker-store -n test1 --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
130-
131-
kubectl delete ns test2 --ignore-not-found=true
132-
kubectl create ns test2
133-
kubectl create secret docker-registry docker-store -n test2 --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
134-
135-
kubectl delete ns weblogic-operator-1 --ignore-not-found=true
136-
kubectl create ns weblogic-operator-1
137-
kubectl create secret docker-registry quay-io -n weblogic-operator-1 --docker-server=quay.io --docker-username=$QUAY_USERNAME --docker-password=$QUAY_PASSWORD --docker-email=$QUAY_EMAIL
138-
139-
kubectl delete ns weblogic-operator-2 --ignore-not-found=true
140-
kubectl create ns weblogic-operator-2
141-
kubectl create secret docker-registry quay-io -n weblogic-operator-2 --docker-server=quay.io --docker-username=$QUAY_USERNAME --docker-password=$QUAY_PASSWORD --docker-email=$QUAY_EMAIL
142-
143-
export IMAGE_NAME_OPERATOR="quay.io/markxnelson/weblogic-kubernetes-operator"
144-
export IMAGE_TAG_OPERATOR="$WERCKER_GIT_COMMIT"
145-
export IMAGE_PULL_POLICY_OPERATOR="IfNotPresent"
146-
export IMAGE_PULL_SECRET_OPERATOR="quay-io"
147-
148-
export IMAGE_PULL_SECRET_WEBLOGIC="docker-store"
149-
150-
echo "Integration test suite against the test image which is:"
151-
echo "$IMAGE_NAME:$IMAGE_TAG"
152-
153-
# integration tests
154-
/pipeline/source/src/integration-tests/bash/run.sh
155-
156-
# clean up
157-
yum clean all
158-
159-
# This pipeline promotes the docker image after tests have passed
160-
promote-image:
161-
steps:
162-
- script:
163-
name: echo
164-
code: |
165-
echo "Passed integration-tests, so pushing the image as 'latest'"
166-
# push the image to quay.io and tag it as "latest"
167-
# in reality, the image will already be there, so it is just updating the tag
168-
169-
# use the quay.io REST API to change the tab "latest" to point to the image we just pushed and tested
170-
171-
# This pipeline runs quqlity checks
66+
- script:
67+
name: Run integration tests
68+
code: |
69+
# Copy Docker file to OCI host and load into local Docker registry
70+
# yum install -y openssh-clients
71+
# echo -e $OCI_K8S_SSHKEY > /tmp/ssh_key
72+
# chmod 600 /tmp/ssh_key
73+
# scp -o StrictHostKeyChecking=no -i /tmp/ssh_key $WERCKER_OUTPUT_DIR/build.tar opc@$OCI_K8S_WORKER0_IP:/scratch/build.tar
74+
# ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key opc@$OCI_K8S_WORKER0_IP "tar -xvf /scratch/operator.tar”
75+
# ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key opc@$OCI_K8S_WORKER0_IP "sudo docker build -t weblogic-kubernetes-operator:$WERCKER_GIT_BRANCH --no-cache=true /scratch/”
76+
# ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key opc@$OCI_K8S_WORKER0_IP "sudo docker save weblogic-kubernetes-operator:$WERCKER_GIT_BRANCH > /scratch/operator.tar”
77+
# ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key opc@$OCI_K8S_WORKER1_IP "sudo docker load < /scratch/operator.tar”
78+
79+
cp /etc/hosts $WERCKER_PIPELINE_DIR/hosts
80+
sed -i "$ a ${OCI_K8S_WORKER0_IP} ${OCI_K8S_WORKER0_HOSTNAME}" $WERCKER_PIPELINE_DIR/hosts
81+
cp $WERCKER_PIPELINE_DIR/hosts /etc/hosts
82+
83+
# Update KUBECONFIG for K8S cluster
84+
export K8S_NODEPORT_HOST="${OCI_K8S_WORKER0_HOSTNAME}"
85+
sed -i -e "s,%ADDRESS%,https://$OCI_K8S_MASTER_IP:443,g" $WERCKER_SOURCE_DIR/build/kube.config
86+
sed -i -e "s,%CLIENT_CERT_DATA%,$OCI_K8S_CLIENT_CERT_DATA,g" $WERCKER_SOURCE_DIR/build/kube.config
87+
sed -i -e "s,%CLIENT_KEY_DATA%,$OCI_K8S_CLIENT_KEY_DATA,g" $WERCKER_SOURCE_DIR/build/kube.config
88+
export KUBECONFIG="$WERCKER_SOURCE_DIR/build/kube.config"
89+
90+
# running on Wercker
91+
export WERCKER="true"
92+
93+
# install kubectl
94+
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
95+
chmod +x ./kubectl
96+
mv ./kubectl /usr/local/bin/kubectl
97+
98+
# install maven, includes java as dependency
99+
curl -LO http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo
100+
mv epel-apache-maven.repo /etc/yum.repos.d/
101+
yum install -y apache-maven
102+
export M2_HOME="/usr/share/apache-maven"
103+
export PATH=$M2_HOME/bin:$PATH
104+
105+
# install opensll
106+
yum install -y openssl
107+
108+
echo @@ "Calling 'kubectl version'"
109+
kubectl version
110+
111+
# create pull secrets
112+
echo @@ "Creating pull secrets"
113+
kubectl delete secret docker-store --ignore-not-found=true
114+
kubectl create secret docker-registry docker-store --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
115+
116+
export HOST_PATH="/scratch"
117+
export PV_ROOT=$HOST_PATH
118+
export RESULT_ROOT="$WERCKER_OUTPUT_DIR/k8s_dir"
119+
mkdir -m 777 -p $RESULT_ROOT
120+
export PROJECT_ROOT="${WERCKER_SOURCE_DIR}"
121+
$WERCKER_SOURCE_DIR/src/integration-tests/bash/cleanup.sh
122+
123+
# create pull secrets
124+
echo @@ "Creating pull secrets"
125+
kubectl delete secret docker-store --ignore-not-found=true
126+
kubectl create secret docker-registry docker-store --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
127+
128+
kubectl delete ns test1 --ignore-not-found=true
129+
kubectl create ns test1
130+
kubectl create secret docker-registry docker-store -n test1 --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
131+
132+
kubectl delete ns test2 --ignore-not-found=true
133+
kubectl create ns test2
134+
kubectl create secret docker-registry docker-store -n test2 --docker-server=index.docker.io/v1/ --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
135+
136+
kubectl delete ns weblogic-operator-1 --ignore-not-found=true
137+
kubectl create ns weblogic-operator-1
138+
kubectl create secret docker-registry quay-io -n weblogic-operator-1 --docker-server=quay.io --docker-username=$QUAY_USERNAME --docker-password=$QUAY_PASSWORD --docker-email=$QUAY_EMAIL
139+
140+
kubectl delete ns weblogic-operator-2 --ignore-not-found=true
141+
kubectl create ns weblogic-operator-2
142+
kubectl create secret docker-registry quay-io -n weblogic-operator-2 --docker-server=quay.io --docker-username=$QUAY_USERNAME --docker-password=$QUAY_PASSWORD --docker-email=$QUAY_EMAIL
143+
144+
export IMAGE_NAME_OPERATOR="quay.io/markxnelson/weblogic-kubernetes-operator"
145+
export IMAGE_TAG_OPERATOR="${WERCKER_GIT_BRANCH//[_/]/-}"
146+
export IMAGE_PULL_POLICY_OPERATOR="IfNotPresent"
147+
export IMAGE_PULL_SECRET_OPERATOR="quay-io"
148+
export IMAGE_PULL_SECRET_WEBLOGIC="docker-store"
149+
150+
echo "Integration test suite against the test image which is:"
151+
echo "$IMAGE_NAME:$IMAGE_TAG"
152+
153+
# integration tests
154+
$WERCKER_SOURCE_DIR/src/integration-tests/bash/run.sh
155+
156+
# clean up
157+
yum clean all
158+
159+
# This pipeline runs quality checks
172160
quality:
173161
steps:
174-
- script:
175-
name: Install pre-reqs
176-
code: |
177-
yum -y install tar gzip
178-
- java/maven:
179-
profiles: build-sonar
180-
maven_opts: -Dsonar.login=${SONAR_LOGIN} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.host.url=${SONAR_HOST}
181-
goals: clean install sonar:sonar
182-
cache_repo: true
183-
version: 3.5.2
162+
- script:
163+
name: Install pre-reqs
164+
code: |
165+
yum -y install tar gzip
166+
- java/maven:
167+
profiles: build-sonar
168+
maven_opts: -Dsonar.login=${SONAR_LOGIN} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.host.url=${SONAR_HOST}
169+
goals: clean install sonar:sonar
170+
cache_repo: true
171+
version: 3.5.2
172+
184173

185174
dev:
186175
steps:
187-
- internal/shell
176+
- internal/shell

0 commit comments

Comments
 (0)