Skip to content

Commit

Permalink
E2e backstage test case (#160)
Browse files Browse the repository at this point in the history
* WIP. Add backstage e2e workflow and template

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* WIP. Use kustomize to create the VM resource where images are pused on namespace: vm-images

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add write permissions

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use manifest like test-data folders to get data to play, templates

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add events to see if the job is triggered part of this PR

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add pull_request to see if the job is triggered part of this PR

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Set the node version using an env var. Remove the non needed step to checkout this project as done by the first step

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use double quotes as the action cannot get the env var

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use proper syntax to pass the NODE version

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Increase sync reconciliation process time for argocd

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Create gitea organization to be used within the e2e test

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Let's make a test using gitea as repository

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Specify the port of the server: 8443 and prefix the curl URL with https

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add missing " char end of the echo line

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Removing the workingDir

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Remove from path backstage-playground/ as non needed

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Fix the wrong enum value of the imageRepository

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Create the gitea registry credentials as kube secret

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Adding missing gitea provider to the template. Add missing values to the data body

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Tekton pipeline will fail as the git repo ingress url cannot be accessed in a pod. WIP

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Revert the template and test data to use github. Job will fail as tokens are not yet passed using github secrets

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add more enum. WIP

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Fix typo error. WIP

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Comment the step to create the gitea org as non used. Pass the ARGOCD_SERVER_URL

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Remove suffix -job. Add missing enum

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Remove suffix -job

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Set the proper step name to get the repoContentsUrl

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use now github and quay to create repo or image with credentials

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Remove the double port 8443

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Rename ARGO_* to ARGOCD_* env vars

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Pass the github secreats as ENV vars

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add missing $ in front of env var QUAY_ORG

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add rewrite rule for pod to pod communication using gitea

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Switch quay org from snowdrop to qshift

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use catalogInfoUrl for both gitea and github

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Get task events

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Replace simple quotes with double quotes otherwise we dont pass the TASK_ID but the env var name

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Sleep before to fetch the events

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Double quotes the GITEA_PASSWORD as it includes special chars

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Increase sleeping time to get all the events = log messages

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Use qshift instead of snowdrop for quay.io image repository

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Describe the resource not found. Show the pods running within the namespace used to test

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add 2>&1 and change the logic to wait till we got an event of type completion

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add missing double quote

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Add missing until reties

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Remove non needed -n chars

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Rename variable from RESPONSE to EVENTS

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Let's trigger a change to see if the job succeeded or if we still have a missing github token

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Increase time to wait to get the events

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Stop the job if the scaffolding fails

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Fix bash syntax error with done and add break

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* fix the race condition error and improve the logging. #163

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Removing dummy as only used for e2e test and added: amunozhe

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

* Fix wrong git repo for Aurea

Signed-off-by: cmoulliard <cmoulliard@redhat.com>

---------

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
  • Loading branch information
cmoulliard committed Jun 26, 2024
1 parent 725c168 commit eec2062
Show file tree
Hide file tree
Showing 19 changed files with 8,049 additions and 18 deletions.
19 changes: 19 additions & 0 deletions .github/scripts/listShowDescribeResource.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

RESOURCE="${1}"
NAMESPACE="${2}"

echo "#########################################"
echo "List $RESOURCE in namespace: $NAMESPACE"
echo "#########################################"
kubectl get $RESOURCE -n $NAMESPACE

echo "#########################################"
echo "Describe $RESOURCE in namespace: $NAMESPACE"
echo "#########################################"
kubectl describe $RESOURCE -n $NAMESPACE

echo "#########################################"
echo "Show $RESOURCE YAML: $NAME in namespace: $NAMESPACE"
echo "#########################################"
kubectl get $RESOURCE -n $NAMESPACE -o yaml
18 changes: 18 additions & 0 deletions .github/scripts/logApplication.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

REPO_NAME="${1}"
SUFFIX="${2}"
NAMESPACE="${3}"

echo "#########################################"
echo "Failed to get application $REPO_NAME-$SUFFIX Synced in namespace: $NAMESPACE"

echo "#########################################"
echo "Describe Application: $REPO_NAME-$SUFFIX in namespace: $NAMESPACE"
echo "#########################################"
kubectl describe application $REPO_NAME-$SUFFIX -n $NAMESPACE

echo "#########################################"
echo "Application YAML: $REPO_NAME-$SUFFIX in namespace: $NAMESPACE"
echo "#########################################"
kubectl get application $REPO_NAME-$SUFFIX -n $NAMESPACE -o yaml
16 changes: 16 additions & 0 deletions .github/scripts/logTektonResources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo "#########################################"
echo "Get Tekton pipeline ..."
echo "#########################################"
kubectl get pipeline -A --ignore-not-found

echo "#########################################"
echo "Get Tekton pipelineruns ..."
echo "#########################################"
kubectl get pipelineruns -A --ignore-not-found

echo "#########################################"
echo "Get Tekton taskruns ..."
echo "#########################################"
kubectl get taskruns -A --ignore-not-found
35 changes: 35 additions & 0 deletions .github/scripts/waitFor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# usage:
# ./waitFor.sh joke operators Succeeded
# ./waitFor.sh pod operators Running "name -o jsonpath='{.status.phase}'"

RESOURCE="${1}"
NAME="${2}"
KUBE_NAMESPACE="${3}"
EXPECTED="${4}"
EXTRA="${5-}"

retries=10
until [[ $retries == 0 ]]; do
actual=$(kubectl get $RESOURCE $NAME -n $KUBE_NAMESPACE $EXTRA 2>/dev/null || echo "Waiting for $RESOURCE/$NAME in namespace $KUBE_NAMESPACE -> $EXPECTED to appear")
if [[ "$actual" =~ .*"$EXPECTED".* ]]; then
echo "Resource \"$RESOURCE/$NAME\" found" 2>&1
echo "$actual" 2>&1
break
else
echo "Waiting for resource \"$RESOURCE/$NAME\" in namespace $KUBE_NAMESPACE ..." 2>&1
echo "$actual" 2>&1
fi
sleep 15s
retries=$((retries - 1))
done

# echo "#########################################"
# echo "Describe resource: $RESOURCE $NAME in namespace $KUBE_NAMESPACE"
# echo "#########################################"
# kubectl describe $RESOURCE $NAME -n $KUBE_NAMESPACE 2>&1

# echo "#########################################"
# echo "Resource YAML: $NAME in namespace $KUBE_NAMESPACE"
# echo "#########################################"
# kubectl get $RESOURCE $NAME -n $KUBE_NAMESPACE -o yaml
37 changes: 37 additions & 0 deletions .github/test-data/quarkus-app-3.11-db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"templateRef": "template:default/quarkus-application",
"values": {
"component_id": "my-quarkus-app-job",
"owner": "user:guest",
"native": false,
"quarkusVersion": "io.quarkus.platform:3.11",
"groupId": "io.quarkus",
"artifactId": "my-quarkus-app-job",
"version": "1.0.0-SNAPSHOT",
"java_package_name": "io.quarkus.demo",
"description": "A cool quarkus app",
"javaVersion": "17",
"buildTool": "MAVEN",
"database": "quarkus-jdbc-postgresql",
"healthEndpoint": true,
"metricsEndpoint": true,
"infoEndpoint": true,
"extensions": [
"io.quarkus:quarkus-rest-jackson",
"io.quarkus:quarkus-smallrye-openapi",
"io.quarkus:quarkus-hibernate-orm-rest-data-panache",
"io.quarkus:quarkus-hibernate-validator"
],
"repo": {
"host": "github.com",
"org": "q-shift",
"visibility": "public"
},
"namespace": "dummy",
"imageRepository": "quay.io",
"imageUrl": "quay.io/qshift/my-quarkus-app-job",
"virtualMachineName": "quarkus-dev",
"virtualMachineNamespace": "dummy"
},
"secrets": {}
}
Loading

0 comments on commit eec2062

Please sign in to comment.