Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize ports used by test-in-k8s #709

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test-in-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ set -euxo pipefail
kubectl get ns kubernetes-plugin-test || kubectl create ns kubernetes-plugin-test
kubectl get ns kubernetes-plugin-test-overridden-namespace || kubectl create ns kubernetes-plugin-test-overridden-namespace
kubectl config set-context --current --namespace=kubernetes-plugin-test
kubectl apply -f test-in-k8s.yaml
port_offset=$RANDOM
http_port=$((2000 + $port_offset))
tcp_port=$((2001 + $port_offset))
kubectl delete --ignore-not-found --now pod jenkins
sed "s/@HTTP_PORT@/$http_port/g; s/@TCP_PORT@/$tcp_port/g" < test-in-k8s.yaml | kubectl apply -f -
kubectl wait --for=condition=Ready --timeout=15m pod/jenkins
kubectl exec jenkins -- sh -c 'rm -rf /checkout && mkdir /checkout'
kubectl exec jenkins -- mkdir /checkout
kubectl cp pom.xml jenkins:/checkout/pom.xml
kubectl cp .mvn jenkins:/checkout/.mvn
kubectl cp src jenkins:/checkout/src
Expand All @@ -23,8 +27,8 @@ kubectl exec jenkins -- \
-s /settings-azure.xml \
-f /checkout \
-DconnectorHost=0.0.0.0 \
-Dport=8000 \
-DslaveAgentPort=50000 \
-Dport=$http_port \
-DslaveAgentPort=$tcp_port \
-Djenkins.host.address=jenkins.kubernetes-plugin-test.svc.cluster.local \
-Dmaven.test.failure.ignore \
$args
Expand Down
12 changes: 6 additions & 6 deletions test-in-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ spec:
args:
- infinity
ports:
- containerPort: 8000
- containerPort: 50000
- containerPort: @HTTP_PORT@
- containerPort: @TCP_PORT@
volumeMounts:
- name: m2repo
mountPath: /root/.m2/repository
Expand All @@ -51,12 +51,12 @@ spec:
app: jenkins
ports:
- name: http
port: 8000
targetPort: 8000
port: @HTTP_PORT@
targetPort: @HTTP_PORT@
protocol: TCP
- name: agent
port: 50000
targetPort: 50000
port: @TCP_PORT@
targetPort: @TCP_PORT@
protocol: TCP
---
kind: ClusterRole
Expand Down