Skip to content

Commit

Permalink
WIP E2E Testing
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics
  • Loading branch information
jfaltermeier committed Aug 23, 2024
1 parent 2d811d5 commit 7438942
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: "[E2E Tests] Minikube"

on:
push:
branches:
- e2e-testing
inputs:
theia-cloud-helm-branch:
description: "Theia Cloud Helm Branch to use"
type: string
default: "main"
workflow_dispatch:
inputs:
theia-cloud-helm-branch:
description: "Theia Cloud Helm Branch to use"
type: string
default: "main"

permissions:
contents: read

concurrency:
group: ci-e2e-theia-cloud-minikube-${{ github.ref }}
cancel-in-progress: true

jobs:
runtests:
name: Run Tests on Minikube
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetes: [v1.31.0] #[v1.31.0, v1.30.4, v1.29.8, v1.28.13]
paths: [false] #[true, false]
ephemeral: [true] #[true, false]
keycloak: [false] #[true, false]
steps:
- name: Checkout Theia Cloud
uses: actions/checkout@v4
with:
path: "./theia-cloud"

- name: Checkout Theia Cloud Helm
uses: actions/checkout@v4
with:
repository: "eclipsesource/theia-cloud-helm"
ref: "${{ github.event.inputs.theia-cloud-helm-branch }}"
path: "./theia-cloud-helm"

- name: Setup Minikube
uses: manusa/actions-setup-minikube@92af4db914ab207f837251cd53eb7060e6477614
with:
minikube version: v1.33.1
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}
start args: "--force"

- name: Enable Minikube Addons
run: |
minikube addons enable dashboard
minikube addons enable default-storageclass
minikube addons enable ingress
minikube addons enable metrics-server
- name: List Minikube Addons
run: minikube addons list

- name: Patch Ingress to allow snippet annotations and restart
run: |
kubectl -n ingress-nginx patch cm ingress-nginx-controller --patch '{"data":{"allow-snippet-annotations":"true"}}'
kubectl -n ingress-nginx delete pod -l app.kubernetes.io/name=ingress-nginx
- name: Build Theia Cloud Images
run: |
eval $(minikube -p minikube docker-env)
cd theia-cloud
docker build --no-cache -t theiacloud/theia-cloud-service:minikube-ci-e2e -f dockerfiles/service/Dockerfile .
docker build --no-cache -t theiacloud/theia-cloud-operator:minikube-ci-e2e -f dockerfiles/operator/Dockerfile .
docker build --no-cache -t theiacloud/theia-cloud-landing-page:minikube-ci-e2e -f dockerfiles/landing-page/Dockerfile .
docker build --no-cache -t theiacloud/theia-cloud-wondershaper:minikube-ci-e2e -f dockerfiles/wondershaper/Dockerfile .
docker build --no-cache -t theiacloud/theia-cloud-conversion-webhook:minikube-ci-e2e -f dockerfiles/conversion-webhook/Dockerfile .
- name: Get NGINX Ingress Controller Host
id: ingress_info
run: |
INGRESS_HOST=$(kubectl get svc -n ingress-nginx ingress-nginx-controller -o jsonpath='{.spec.clusterIP}')
echo "INGRESS_HOST=$INGRESS_HOST" >> $GITHUB_ENV
- name: Run Terraform
run: |
cd theia-cloud/terraform/ci-configurations
terraform init
terraform apply \
-var="ingress_ip=${{ env.INGRESS_HOST }}" \
-var="use_paths=${{ matrix.paths }}" \
-var="use_ephemeral_storage=${{ matrix.ephemeral }}" \
-var="enable_keycloak=${{ matrix.keycloak }}" \
-auto-approve
- name: List All Services in All Namespaces
run: kubectl get services --all-namespaces

- name: List All Ingresses in All Namespaces
run: kubectl get ingress --all-namespaces

- name: List All Pods in All Namespaces
run: kubectl get pods --all-namespaces

- name: Wait for Deployments to be Ready
run: |
kubectl wait --namespace ingress-nginx --for=condition=available deployment/ingress-nginx-controller --timeout=300s
kubectl wait --namespace theiacloud --for=condition=available deployment/conversion-webhook --timeout=300s
kubectl wait --namespace theiacloud --for=condition=available deployment/landing-page-deployment --timeout=300s
kubectl wait --namespace theiacloud --for=condition=available deployment/operator-deployment --timeout=300s
kubectl wait --namespace theiacloud --for=condition=available deployment/service-deployment --timeout=300s
# URLs
# service: servicex
# landing: trynow
# instance: instances
- name: Access NGINX Ingress URL
run: |
curl -LkI "https://trynow.${{ env.INGRESS_HOST }}.nip.io/"
83 changes: 83 additions & 0 deletions terraform/ci-configurations/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 154 additions & 0 deletions terraform/ci-configurations/e2e_tests.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
variable "ingress_ip" {
description = "The IP of the running Minikube Cluster"
type = string
}

variable "use_paths" {
description = "Whether to use Theia Cloud with paths or subdomains"
type = bool
}

variable "use_ephemeral_storage" {
description = "Whether to use ephemeral storage"
type = bool
}

variable "enable_keycloak" {
description = "Whether to enable keycloak"
type = bool
}

provider "kubernetes" {
config_path = "~/.kube/config"
}

provider "helm" {
kubernetes {
config_path = "~/.kube/config"
}
}

resource "kubernetes_persistent_volume" "minikube" {
metadata {
name = "minikube-volume"
}
spec {
storage_class_name = "manual"
capacity = {
storage = "16Gi"
}
access_modes = ["ReadWriteOnce"]
persistent_volume_source {
host_path {
path = "/data/theiacloud"
}
}
}
}

module "helm" {
source = "../modules/helm"

depends_on = [kubernetes_persistent_volume.minikube]

install_ingress_controller = false
install_theia_cloud_base = false
install_theia_cloud_crds = false
install_theia_cloud = false
install_selfsigned_issuer = true
cert_manager_issuer_email = "[email protected]"
cert_manager_cluster_issuer = "keycloak-selfsigned-issuer"
cert_manager_common_name = "${var.ingress_ip}.nip.io"
hostname = "${var.ingress_ip}.nip.io"
service_type = "ClusterIP"
postgresql_storageClass = "manual"
postgresql_volumePermissions = true
keycloak_admin_password = "admin"
postgresql_enabled = true
postgres_postgres_password = "admin"
postgres_password = "admin"
loadBalancerIP = ""
cloudProvider = "MINIKUBE"
}

provider "keycloak" {
client_id = "admin-cli"
username = "admin"
password = "admin"
url = "https://${var.ingress_ip}.nip.io/keycloak"
tls_insecure_skip_verify = true # only for minikube self signed
initial_login = false
client_timeout = 60
}

module "keycloak" {
source = "../modules/keycloak"

depends_on = [module.helm]

hostname = "${var.ingress_ip}.nip.io"
keycloak_test_user_foo_password = "foo"
keycloak_test_user_bar_password = "bar"
valid_redirect_uri = "*"
}

resource "helm_release" "theia-cloud-crds" {
depends_on = [module.keycloak]

name = "theia-cloud-crds"
chart = "../../../theia-cloud-helm/charts/theia-cloud-crds"
namespace = "theiacloud"
create_namespace = true

set {
name = "conversion.image"
value = "theiacloud/theia-cloud-conversion-webhook:minikube-ci-e2e"
}
}

resource "helm_release" "theia-cloud-base" {
depends_on = [module.keycloak]

name = "theia-cloud-base"
chart = "../../../theia-cloud-helm/charts/theia-cloud-base"
namespace = "theiacloud"
create_namespace = true

set {
name = "issuer.email"
value = "[email protected]"
}
}

resource "helm_release" "theia-cloud" {
depends_on = [helm_release.theia-cloud-crds, helm_release.theia-cloud-base]

name = "theia-cloud"
chart = "../../../theia-cloud-helm/charts/theia-cloud"
namespace = "theiacloud"
create_namespace = true

values = [
"${file("${path.module}/valuesE2ECI.yaml")}"
]

set {
name = "hosts.usePaths"
value = var.use_paths
}

set {
name = "hosts.configuration.baseHost"
value = "${var.ingress_ip}.nip.io"
}

set {
name = "landingPage.ephemeralStorage"
value = var.use_ephemeral_storage
}

set {
name = "keycloak.enable"
value = var.enable_keycloak
}
}
4 changes: 4 additions & 0 deletions terraform/ci-configurations/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "ingress_ip" {
description = "The IP of the running Minikube Cluster"
value = var.ingress_ip
}
Loading

0 comments on commit 7438942

Please sign in to comment.