Skip to content

Commit

Permalink
Finalize e2e k3d scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiatekus committed Jan 14, 2025
1 parent 09ba78e commit 2736628
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 10 deletions.
3 changes: 3 additions & 0 deletions tests/btp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: e2e-test
e2e-test:
./integration-test-btp.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash

echo "Running kyma@v3 integration tests uing connected managed kyma runtime"
echo "KUBECONFIG=${KUBECONFIG}"

# -------------------------------------------------------------------------------------
echo "Step1: Generating temporary access for new service account"

bin/kyma@v3 alpha access --clusterrole cluster-admin --name test-sa --output /tmp/kubeconfig.yaml --time 2h
../../bin/kyma@v3 alpha access --clusterrole cluster-admin --name test-sa --output /tmp/kubeconfig.yaml --time 2h

export KUBECONFIG="/tmp/kubeconfig.yaml"
if [[ $(kubectl config view --minify --raw | yq '.users[0].name') != 'test-sa' ]]; then
Expand All @@ -15,7 +14,7 @@ fi
echo "Running test in user context of: $(kubectl config view --minify --raw | yq '.users[0].name')"
# -------------------------------------------------------------------------------------
echo "Step2: List modules"
bin/kyma@v3 alpha module list
../../bin/kyma@v3 alpha module list

# -------------------------------------------------------------------------------------
echo "Step3: Connecting to remote BTP subaccount"
Expand All @@ -24,7 +23,7 @@ echo "Step4: Create Shared Service Instance Reference"
# -------------------------------------------------------------------------------------
# Enable Docker Registry
echo "Step5: Enable Docker Registry from experimental channel (with persistent BTP based storage)"
bin/kyma@v3 alpha module add docker-registry --channel experimental --cr-path hack/exposed-docker-registry.yaml
../../bin/kyma@v3 alpha module add docker-registry --channel experimental --cr-path k8s-resources/exposed-docker-registry.yaml

echo "..waiting for docker registry"
kubectl wait --for condition=Installed dockerregistries.operator.kyma-project.io/default -n kyma-system --timeout=360s
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/k3d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: e2e-test
e2e-test:
./integration-test-k3d.sh
33 changes: 27 additions & 6 deletions hack/integration-test-k3d.sh → tests/k3d/integration-test-k3d.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#!/bin/bash

echo "Running kyma@v3 integration tests uing connected k3d kyma runtime"
echo "KUBECONFIG=${KUBECONFIG}"
if ! which pack; then
echo "Installing pack..."
(curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.36.0/pack-v0.36.0-linux.tgz" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack)
fi

# -------------------------------------------------------------------------------------
echo "Step1: Generating temporary access for new service account"
echo "Running basic test scenario for kyma@v3 CLI on k3d runtime"

bin/kyma@v3 alpha access --clusterrole cluster-admin --name test-sa --output /tmp/kubeconfig.yaml --time 2h
# -------------------------------------------------------------------------------------
# Generate kubeconfig for service account

echo "Step1: Generating temporary access for new service account"
../../bin/kyma@v3 alpha access --clusterrole cluster-admin --name test-sa --output /tmp/kubeconfig.yaml --time 2h
export KUBECONFIG="/tmp/kubeconfig.yaml"
if [[ $(kubectl config view --minify --raw | yq '.users[0].name') != 'test-sa' ]]; then
exit 1
fi
echo "Running test in user context of: $(kubectl config view --minify --raw | yq '.users[0].name')"

# -------------------------------------------------------------------------------------
# Enable Docker Registry

Expand All @@ -22,11 +27,27 @@ kubectl apply -f https://github.com/kyma-project/docker-registry/releases/latest
kubectl apply -f https://github.com/kyma-project/docker-registry/releases/latest/download/default-dockerregistry-cr.yaml -n kyma-system
echo "..waiting for docker registry"
kubectl wait --for condition=Installed dockerregistries.operator.kyma-project.io/default -n kyma-system --timeout=360s

# -------------------------------------------------------------------------------------
echo "Step3: Push sample Java application (w/o Dockerfile)"
# Push sample go app

echo "Step3: Push sample Go application (tests/k3d/sample-go)"
../../bin/kyma@v3 alpha app push --name test-app --code-path sample-go
kubectl wait --for condition=Available deployment test-app --timeout=60s
kubectl port-forward deployments/test-app 8080:8080 &
sleep 3 # wait for ports to get forwarded
response=$(curl localhost:8080)
echo "HTTP response from sample app: $response"

if [[ $response != 'okey dokey' ]]; then
exit 1
fi

# -------------------------------------------------------------------------------------
# Cleanup

echo "Step4: Cleanup"
kubectl delete deployment test-app

# -------------------------------------------------------------------------------------
exit 0
3 changes: 3 additions & 0 deletions tests/k3d/sample-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/kyma-project/pack-test

go 1.23.2
20 changes: 20 additions & 0 deletions tests/k3d/sample-go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"fmt"
"net/http"
"os"
)

func main() {
mux := &http.ServeMux{}
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("got request")
w.WriteHeader(200)
w.Write([]byte("okey dokey"))
})
if err := http.ListenAndServe(":8080", mux); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}

0 comments on commit 2736628

Please sign in to comment.