Skip to content

Commit

Permalink
reverting to previous implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
maknop committed Oct 23, 2023
1 parent 111205a commit 3cbc3fb
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 123 deletions.
123 changes: 0 additions & 123 deletions ci/minikube_e2e_tests.sh
Original file line number Diff line number Diff line change
@@ -1,128 +1,5 @@
#!/bin/bash

cat << EOF > minikube_e2e_tests_inner.sh
CLOWDER_VERSION=`git describe --tags`
IMG=$IMAGE_NAME:$IMAGE_TAG BASE_IMG=$BASE_IMG make docker-build
IMG=$IMAGE_NAME:$IMAGE_TAG make docker-push
# copy the workspace from the Jenkins job off the ro volume into this container
mkdir /container_workspace
cp -r /workspace/. /container_workspace
cd /container_workspace
mkdir -p /container_workspace/bin
cp /opt/app-root/src/go/bin/* /container_workspace/bin
export KUBEBUILDER_ASSETS=/container_workspace/testbin/bin
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
source build/template_check.sh
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export PATH="/bins:$PATH"
ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube delete"
ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube start --cpus 6 --disk-size 10GB --memory 16000MB --kubernetes-version=1.23.5 --addons=metrics-server --disable-optimizations"
export MINIKUBE_IP=`ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube ip"`
scp -o StrictHostKeyChecking=no -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/profiles/minikube/client.key ./
scp -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/profiles/minikube/client.crt ./
scp -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/ca.crt ./
ssh -o ExitOnForwardFailure=yes -f -N -L 127.0.0.1:8444:$MINIKUBE_IP:8443 -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST
cat > kube-config <<- EOM
apiVersion: v1
clusters:
- cluster:
certificate-authority: $PWD/ca.crt
server: https://127.0.0.1:8444
name: 127-0-0-1:8444
contexts:
- context:
cluster: 127-0-0-1:8444
user: remote-minikube
name: remote-minikube
users:
- name: remote-minikube
user:
client-certificate: $PWD/client.crt
client-key: $PWD/client.key
current-context: remote-minikube
kind: Config
preferences: {}
EOM
export PATH="$KUBEBUILDER_ASSETS:$PATH"
export PATH="/root/go/bin:$PATH"
export KUBECONFIG=$PWD/kube-config
kubectl config use-context remote-minikube
kubectl get pods --all-namespaces=true
source build/kube_setup.sh
export IMAGE_TAG=`git rev-parse --short=8 HEAD`
kubectl create namespace clowder-system
mkdir artifacts
cat manifest.yaml > artifacts/manifest.yaml
sed -i "s/clowder:latest/clowder:$IMAGE_TAG/g" manifest.yaml
kubectl apply -f manifest.yaml --validate=false
## The default generated config isn't quite right for our tests - so we'll create a new one and restart clowder
kubectl apply -f clowder-config.yaml -n clowder-system
kubectl delete pod -n clowder-system -l operator-name=clowder
# Wait for operator deployment...
kubectl rollout status deployment clowder-controller-manager -n clowder-system
kubectl krew install kuttl
set +e
kubectl get env
kubectl get env
source build/run_kuttl.sh --report xml
mv kuttl-report.xml artifacts/junit-kuttl.xml
CLOWDER_PODS="$(kubectl get pod -n clowder-system -o jsonpath='{.items[*].metadata.name}')"
for pod in $CLOWDER_PODS; do
kubectl logs $pod -n clowder-system > artifacts/$pod.log
kubectl logs $pod -n clowder-system | ./parse-controller-logs > artifacts/$pod-parsed-controller-logs.log
done
# Grab the metrics
kubectl port-forward svc/clowder-controller-manager-metrics-service-non-auth -n clowder-system 8080 &
sleep 5
curl 127.0.0.1:8080/metrics > artifacts/clowder-metrics
STRIMZI_PODS="$(kubectl get pod -n strimzi -o jsonpath='{.items[*].metadata.name}')"
for pod in $STRIMZI_PODS; do
kubectl logs $pod -n strimzi > artifacts/$pod.log
done
EOF

chmod +x minikube_e2e_tests_inner.sh

curl -s ${HELPER_FUNCTIONS} > .general_helper.sh && source ./.general_helper.sh
curl -s ${BOOTSTRAP_FUNCTIONS} > .bootstrap.sh && source "${WORKSPACE}/.bootstrap.sh"

Expand Down
120 changes: 120 additions & 0 deletions ci/minikube_e2e_tests_inner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

CLOWDER_VERSION=`git describe --tags`

IMG=$IMAGE_NAME:$IMAGE_TAG BASE_IMG=$BASE_IMG make docker-build
IMG=$IMAGE_NAME:$IMAGE_TAG make docker-push

# copy the workspace from the Jenkins job off the ro volume into this container
mkdir /container_workspace
cp -r /workspace/. /container_workspace
cd /container_workspace

mkdir -p /container_workspace/bin
cp /opt/app-root/src/go/bin/* /container_workspace/bin

export KUBEBUILDER_ASSETS=/container_workspace/testbin/bin

(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)

source build/template_check.sh

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export PATH="/bins:$PATH"

ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube delete"
ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube start --cpus 6 --disk-size 10GB --memory 16000MB --kubernetes-version=1.23.5 --addons=metrics-server --disable-optimizations"

export MINIKUBE_IP=`ssh -o StrictHostKeyChecking=no $MINIKUBE_USER@$MINIKUBE_HOST -i minikube-ssh-ident "minikube ip"`

scp -o StrictHostKeyChecking=no -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/profiles/minikube/client.key ./
scp -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/profiles/minikube/client.crt ./
scp -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST:$MINIKUBE_ROOTDIR/.minikube/ca.crt ./

ssh -o ExitOnForwardFailure=yes -f -N -L 127.0.0.1:8444:$MINIKUBE_IP:8443 -i minikube-ssh-ident $MINIKUBE_USER@$MINIKUBE_HOST

cat > kube-config <<- EOM
apiVersion: v1
clusters:
- cluster:
certificate-authority: $PWD/ca.crt
server: https://127.0.0.1:8444
name: 127-0-0-1:8444
contexts:
- context:
cluster: 127-0-0-1:8444
user: remote-minikube
name: remote-minikube
users:
- name: remote-minikube
user:
client-certificate: $PWD/client.crt
client-key: $PWD/client.key
current-context: remote-minikube
kind: Config
preferences: {}
EOM

export PATH="$KUBEBUILDER_ASSETS:$PATH"
export PATH="/root/go/bin:$PATH"

export KUBECONFIG=$PWD/kube-config

kubectl config use-context remote-minikube
kubectl get pods --all-namespaces=true

source build/kube_setup.sh

export IMAGE_TAG=`git rev-parse --short=8 HEAD`

kubectl create namespace clowder-system

mkdir artifacts

cat manifest.yaml > artifacts/manifest.yaml

sed -i "s/clowder:latest/clowder:$IMAGE_TAG/g" manifest.yaml

kubectl apply -f manifest.yaml --validate=false

## The default generated config isn't quite right for our tests - so we'll create a new one and restart clowder
kubectl apply -f clowder-config.yaml -n clowder-system
kubectl delete pod -n clowder-system -l operator-name=clowder

# Wait for operator deployment...
kubectl rollout status deployment clowder-controller-manager -n clowder-system

kubectl krew install kuttl

set +e

kubectl get env
kubectl get env

source build/run_kuttl.sh --report xml

mv kuttl-report.xml artifacts/junit-kuttl.xml

CLOWDER_PODS="$(kubectl get pod -n clowder-system -o jsonpath='{.items[*].metadata.name}')"
for pod in $CLOWDER_PODS; do
kubectl logs $pod -n clowder-system > artifacts/$pod.log
kubectl logs $pod -n clowder-system | ./parse-controller-logs > artifacts/$pod-parsed-controller-logs.log
done

# Grab the metrics
kubectl port-forward svc/clowder-controller-manager-metrics-service-non-auth -n clowder-system 8080 &
sleep 5
curl 127.0.0.1:8080/metrics > artifacts/clowder-metrics

STRIMZI_PODS="$(kubectl get pod -n strimzi -o jsonpath='{.items[*].metadata.name}')"
for pod in $STRIMZI_PODS; do
kubectl logs $pod -n strimzi > artifacts/$pod.log
done

0 comments on commit 3cbc3fb

Please sign in to comment.