Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add meilisearch integration testing #111

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Integration Test

on:
pull_request:

jobs:

k8s:
runs-on: ubuntu-latest
strategy:
matrix:
cluster:
- elasticsearch
- meilisearch

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Kind
uses: helm/[email protected]
with:
install_only: true

- name: Start Kind
run: |
kind create cluster --config integration-test/cluster.yaml
kubectl config set-context --current --namespace=openedx-harmony
sudo echo "127.0.0.1 harmony.test" | sudo tee -a /etc/hosts

- 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 openedx-harmony --create-namespace -f integration-test/${{matrix.cluster}}/values.yaml charts/harmony-chart
kubectl rollout status deployment --timeout 300s

- name: Healthcheck
run: |
curl http://harmony.test/cluster-echo-test

- name: Boostrap cluster
run: |
bash integration-test/${{matrix.cluster}}/cluster.sh

- 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 installation in $(ls -d integration-test/${{matrix.cluster}}/*/)
do
bash integration-test/environment.sh $installation
done
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ infra-*/secrets.auto.tfvars
.terraform
*secrets.auto.tfvars
my-notes
**/env/
**/venv/
7 changes: 5 additions & 2 deletions charts/harmony-chart/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ dependencies:
- name: openfaas
repository: https://openfaas.github.io/faas-netes
version: 14.2.34
digest: sha256:548b955e15c04e3eb4a270b4f6a869675d20becad8e75702cf945b214809a63e
generated: "2024-10-07T15:49:37.65074391-05:00"
- name: meilisearch
repository: https://meilisearch.github.io/meilisearch-kubernetes
version: 0.10.2
digest: sha256:4ec85343278799faafdf7a5ce04e71e3b9a03ab2333c18813da76422198603d2
generated: "2024-11-15T11:32:33.060844445-05:00"
5 changes: 5 additions & 0 deletions charts/harmony-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ dependencies:
version: "14.2.34"
repository: https://openfaas.github.io/faas-netes
condition: openfaas.enabled

- name: meilisearch
version: "0.10.2"
repository: "https://meilisearch.github.io/meilisearch-kubernetes"
condition: meilisearch.enabled
4 changes: 4 additions & 0 deletions charts/harmony-chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ Examples of more stuff that can be in a NOTES file:
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
*/}}

{{- if .Values.meilisearch.enabled }}
Meilisearch enabled, make sure to install tutor-contrib-meilisearch on your Open edX installation.
{{- end }}
14 changes: 14 additions & 0 deletions charts/harmony-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,17 @@ velero:

openfaas:
enabled: false

meilisearch:
enabled: false
environment:
MEILI_ENV: production
MEILI_MASTER_KEY: Cu5t0mS3cR3tK3Y
ingress:
enabled: false
persistence:
enabled: true
size: "10Gi"
replicaCount: 1
serviceMonitor:
enabled: false
20 changes: 20 additions & 0 deletions integration-test/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
listenAddress: 127.0.0.1 # omit for 0.0.0.0
protocol: TCP
- containerPort: 443
hostPort: 443
listenAddress: 127.0.0.1 # omit for 0.0.0.0
protocol: TCP

Empty file.
80 changes: 80 additions & 0 deletions integration-test/elasticsearch/openedx-01/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
CMS_OAUTH2_SECRET: kWYPh15ecORZ75TvEqtzfghk
DISCOVERY_INDEX_OVERRIDES:
course_discovery.apps.course_metadata.search_indexes.documents.course: openedx-01-owrj-course
course_discovery.apps.course_metadata.search_indexes.documents.course_run: openedx-01-owrj-course_run
course_discovery.apps.course_metadata.search_indexes.documents.learner_pathway: openedx-01-owrj-learner_pathway
course_discovery.apps.course_metadata.search_indexes.documents.person: openedx-01-owrj-person
course_discovery.apps.course_metadata.search_indexes.documents.program: openedx-01-owrj-program
ELASTICSEARCH_HOST: harmony-search-cluster.openedx-harmony.svc.cluster.local
ELASTICSEARCH_SCHEME: https
ENABLE_HTTPS: true
ENABLE_WEB_PROXY: false
ID: K3vsruy7oOdTvOcKmhiCybNz
JWT_RSA_PRIVATE_KEY: '-----BEGIN RSA PRIVATE KEY-----

MIIEowIBAAKCAQEA0IiZ4AR3Iz3PPzdjvCwG+sQT2Fqiq5/Z+SBudvJfhwoMKj6R

KNdmUcqsF+XotuQ6RRWaqmLv1INdlBjWlrhg7YdcJvJstIXE5Hs22M9R6Lth0jyB

159SEATsy9HuZBd10M7gG61LVoeamesn9U5Dd/0Fqfnb6PT2blYQ+SX24RYWV00K

+y1NujnK3NpVeEZGBNUk3xIxLT+W9EYarnGB1PdxQq+IQ56TT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o/lZ3V0ri8uk2CGqT64rALGQxr/rwYXUAcuQR5wQQYmBV49h4vWx

3yHg0GZ11BfFHuRxCvP9OLmKXAr4esOmoPu+t7xMZjIoiWn/5DLMyua8EbtFvd+U

w2qcKQKBgBmTe8NzvMxKstgDcElCnpqFv1e2JVLofXIsrW+07r8qhPywfXIiloR9

JRaR1CjsA4ZsU5n+2fISx8RvZqnrYvsSLFrkW9U6iSkJJwSR0gTJb3sNaxpfv1uT

/GdzMnP1gM/V41wm28/LP6s9Z95tiwXjkHEBhIjYGbWi6DRz22jd

-----END RSA PRIVATE KEY-----'
K8S_HARMONY_NAMESPACE: openedx-harmony
K8S_HARMONY_SEARCH_CLUSTER_HTTP_AUTH: openedx-01:gXkYL5RNzzP3Zc6BHL1oJrKy
K8S_HARMONY_SEARCH_CLUSTER_INDEX_PREFIX: openedx-01-owrj-
K8S_NAMESPACE: openedx-01
LMS_HOST: local.openedx.io
MYSQL_ROOT_PASSWORD: c7SVvBJl
OPENEDX_MYSQL_PASSWORD: M4CBFYO9
OPENEDX_SECRET_KEY: dskQ9UXPKcsSi2molXmggxID
PLUGINS:
- indigo
- k8s_harmony
- mfe
PLUGIN_INDEXES:
- https://overhang.io/tutor/main
RUN_ELASTICSEARCH: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Run any arbitrary commands necessary to verify the installation is working
echo "Make sure to change this script to verify your installation is tested correctly"
8 changes: 8 additions & 0 deletions integration-test/elasticsearch/openedx-01/pre-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export HARMONY_NAMESPACE=$(tutor config printvalue K8S_HARMONY_NAMESPACE)
export INSTANCE_NAMESPACE=$(tutor config printvalue K8S_NAMESPACE)
tutor harmony create-elasticsearch-user

kubectl get secret "search-cluster-certificates-elasticsearch" -n "$HARMONY_NAMESPACE" -o "yaml" | \
grep -v '^\s*namespace:\s' | \
sed s/-elasticsearch//g |\
kubectl apply -n "$INSTANCE_NAMESPACE" --force -f -
2 changes: 2 additions & 0 deletions integration-test/elasticsearch/openedx-01/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
../../../tutor-contrib-harmony-plugin
tutor[full]<19
50 changes: 50 additions & 0 deletions integration-test/elasticsearch/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Disable HTTPS cert provisioning for testing with minikube
cert-manager:
enabled: false

ingress-nginx:
# Use ingress-nginx as a default controller.
enabled: true
controller:
# All these needed for local development
service:
type: NodePort
hostPort:
enabled: true
publishService:
enabled: false
extraArgs:
publish-status-address: localhost

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
replicas: 1

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
29 changes: 29 additions & 0 deletions integration-test/environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cd $1

# Setup environment
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

# Start/init installation
tutor config save
tutor plugins enable k8s_harmony

tutor k8s start

echo "########################################"
echo "# Pre init #"
echo "########################################"

bash ./pre-init.sh

tutor k8s init

echo "########################################"
echo "# Post init #"
echo "########################################"
bash ./post-installation.sh

# Go back
deactivate
cd $CI_ROOT
Empty file.
Loading