diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..b7a2f4c --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,68 @@ +name: Integration Test + +on: + pull_request: + +jobs: + + k8s: + runs-on: ubuntu-latest + strategy: + matrix: + cluster: + - cluster-01 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: start minikube + id: minikube + uses: medyagh/setup-minikube@latest + + - name: Setup namespace + run: | + kubectl config set-context --current --namespace=openedx-harmony + + - name: Helm dependency add + run: | + helm dependency list charts/harmony-chart 2> /dev/null | tail +2 | awk '{ print "helm" " repo add " $1 " " $3 }' | while read cmd; do $cmd || true; done + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.crds.yaml --namespace=harmony + + - name: Helm dependency build + run: | + helm dependency update charts/harmony-chart + helm dependency build charts/harmony-chart + + - name: Helm install + run: | + helm install harmony --namespace harmony --create-namespace -f integration-test/${{matrix.cluster}}/values.yaml charts/harmony-chart + + - name: Setup domain + run: | + export CLUSTER_HTTP_URL=$(minikube service harmony-ingress-nginx-controller -n harmony --url | head -n 1) + curl $CLUSTER_HTTP_URL/cluster-echo-test -H "host: harmony.test" + + - name: setup python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install openedx + run: | + export INSTALLATIONS=$(ls -d integration-test/${{matrix.cluster}}/*/) + export CI_ROOT=$(pwd) + for i in $(ls -d integration-test/cluster-01/*/) + do + echo "Running for installation $i" + cd $i + export TUTOR_PLUGINS_ROOT=$(pwd)/plugins/ export TUTOR_ROOT=$(pwd) + python3 -m venv venv && source venv/bin/activate + pip install -r $TUTOR_ROOT/requirements.txt + tutor config save + tutor plugins enable k8s_harmony + tutor k8s start + tutor k8s init + cd $CI_ROOT + deactivate + done diff --git a/integration-test/cluster-01/openedx-01/Makefile b/integration-test/cluster-01/openedx-01/Makefile new file mode 100644 index 0000000..7fcb87b --- /dev/null +++ b/integration-test/cluster-01/openedx-01/Makefile @@ -0,0 +1,2 @@ +install: # Run any arbitrary commands necessary to prepare your installation + echo "Hi, running from $(pwd)" diff --git a/integration-test/cluster-01/openedx-01/config.yml b/integration-test/cluster-01/openedx-01/config.yml new file mode 100644 index 0000000..7e7c3f9 --- /dev/null +++ b/integration-test/cluster-01/openedx-01/config.yml @@ -0,0 +1 @@ +K8S_NAMESPACE: openedx-01 diff --git a/integration-test/cluster-01/openedx-01/requirements.txt b/integration-test/cluster-01/openedx-01/requirements.txt new file mode 100644 index 0000000..c77e537 --- /dev/null +++ b/integration-test/cluster-01/openedx-01/requirements.txt @@ -0,0 +1,2 @@ +../../../tutor-contrib-harmony-plugin +tutor[full]<19 diff --git a/integration-test/cluster-01/values.yaml b/integration-test/cluster-01/values.yaml new file mode 100644 index 0000000..26b25f9 --- /dev/null +++ b/integration-test/cluster-01/values.yaml @@ -0,0 +1,35 @@ +# Disable HTTPS cert provisioning for testing with minikube +cert-manager: + enabled: true + +clusterDomain: harmony.test + +elasticsearch: + enabled: true + + # TODO: move this to a separate PR + # Permit co-located instances for solitary minikube virtual machines. + antiAffinity: "soft" + + volumeClaimTemplate: + resources: + requests: + storage: 8Gi + +opensearch: + enabled: false + + # Permit co-located instances for solitary minikube virtual machines. + antiAffinity: "soft" + + persistence: + size: 8Gi + +prometheusstack: + enabled: true + +k8sdashboard: + enabled: false + +openfaas: + enabled: false diff --git a/temp.txt b/temp.txt new file mode 100644 index 0000000..e895f94 --- /dev/null +++ b/temp.txt @@ -0,0 +1,34 @@ +# ingress nginx +# cert manager +# elastichsearch - openedx +# opensearch - openedx +# prometheusstack + + + +# steps +# 1. Create a key for a CA +openssl genrsa -des3 -out harmony.key 2048 +# 2. Generate a root certificate +openssl req -x509 -new -nodes -key harmony.key -sha256 -days 1825 -out harmony.pem +# 3. Install Certificate +sudo cp harmony.pem /usr/local/share/ca-certificates/harmony.crt +sudo update-ca-certificates +# 4. Creating CA-signed certificates for dev site +openssl genrsa -out harmony.test.key 2048 +# 4.1 Create CSR: +openssl req -new -key harmony.test.key -out harmony.test.csr +# 4.2 Sign certifcate +openssl x509 -req -in harmony.test.csr -CA harmony.pem -CAkey harmony.key -CAcreateserial -out harmony.test.crt -days 825 -sha256 -extfile harmony.test.ext + +# Setup certificates +sudo mkdir -p /etc/systemd/resolved.conf.d +sudo tee /etc/systemd/resolved.conf.d/minikube.conf << EOF +[Resolve] +DNS=$(minikube ip) +Domains=~harmony.test +EOF +sudo systemctl restart systemd-resolved + +# Enable certificate on minikube +cp harmony.pem $HOME/.minikube/certs/harmony.pem \ No newline at end of file diff --git a/values-minikube.yaml b/values-minikube.yaml index 8509816..26b25f9 100644 --- a/values-minikube.yaml +++ b/values-minikube.yaml @@ -1,11 +1,11 @@ # Disable HTTPS cert provisioning for testing with minikube cert-manager: - enabled: false + enabled: true -clusterDomain: "example.local" +clusterDomain: harmony.test elasticsearch: - enabled: false + enabled: true # TODO: move this to a separate PR # Permit co-located instances for solitary minikube virtual machines. @@ -26,7 +26,7 @@ opensearch: size: 8Gi prometheusstack: - enabled: false + enabled: true k8sdashboard: enabled: false