-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/e2e: add tests using multiple k8s clusters
Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
- Loading branch information
1 parent
4d07d80
commit ebc8226
Showing
4 changed files
with
184 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: "e2e-multiple-k8s-clusters" | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "**/*.md" | ||
- "CODEOWNERS" | ||
push: | ||
paths-ignore: | ||
- "**/*.md" | ||
- "CODEOWNERS" | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
build: | ||
runs-on: "ubuntu-22.04" | ||
#runs-on: mantle_large_runner_16core | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
- run: sudo apt-get update | ||
- run: sudo apt-get purge -y apport apport-symptoms fwupd nano netplan.io popularity-contest unattended-upgrades update-manager-core snapd | ||
- run: sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true | ||
- run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup /usr/lib/jvm || true | ||
- run: sudo apt-get purge -y $(dpkg-query -W | grep nginx | awk '{print $1}') | ||
- run: sudo apt-get purge -y aria2 ansible azure-cli shellcheck rpm xorriso zsync firefox gfortran-9 google-chrome-stable google-cloud-sdk | ||
- run: sudo apt-get purge -y imagemagick libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional mercurial apt-transport-https | ||
- run: sudo apt-get purge -y mono-complete unixodbc-dev yarn chrpath libxft-dev libfreetype6-dev libfontconfig1 libfontconfig1-dev | ||
- run: sudo apt-get purge -y snmp pollinate libpq-dev postgresql-client powershell ruby-full sphinxsearch subversion azure-cli | ||
- run: sudo apt-get purge -y $(dpkg-query -W | grep dotnet | awk '{print $1}') | ||
- run: sudo apt-get autoremove -y >/dev/null 2>&1 | ||
- run: sudo apt-get autoclean -y >/dev/null 2>&1 | ||
- name: "KVM setup" | ||
run: |- | ||
VIRTUALIZATION_SUPPORT=$(grep -E -q 'vmx|svm' /proc/cpuinfo && echo yes || echo no) | ||
echo ${VIRTUALIZATION_SUPPORT} | ||
if [ "${VIRTUALIZATION_SUPPORT}" != "yes" ]; then | ||
echo "CPU does not support the virtualization feature." | ||
exit 1 | ||
fi | ||
sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils | ||
kvm-ok | ||
sudo adduser `id -un` libvirt | ||
sudo adduser `id -un` kvm | ||
virsh list --all | ||
sudo ls -la /var/run/libvirt/libvirt-sock | ||
sudo chmod 777 /var/run/libvirt/libvirt-sock | ||
sudo ls -la /var/run/libvirt/libvirt-sock | ||
ls -l /dev/kvm | ||
sudo rmmod kvm_amd | ||
sudo rmmod kvm | ||
sudo modprobe -a kvm | ||
sudo modprobe -a kvm_amd | ||
- name: cache go dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: go-${{ hashFiles('go.sum', 'Makefile', 'versions.mk') }} | ||
restore-keys: | | ||
go- | ||
- run: make -C test/e2e setup | ||
- run: make -C test/e2e test-multiple-k8s-clusters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# End-to-End Tests for Mantle | ||
|
||
## Requirements | ||
|
||
To set up the test environment, you'll need Minikube with the KVM2 driver enabled, so make sure to enable KVM2 beforehand. Don't worry about installing Minikube yourself; it will be installed automatically. | ||
|
||
## Usage | ||
|
||
First, install the necessary software by running: | ||
``` | ||
cd test/e2e | ||
make setup | ||
``` | ||
|
||
Next, you can start the tests: | ||
|
||
- To run the tests using a single Kubernetes cluster: | ||
``` | ||
make test | ||
``` | ||
- To run the tests using multiple Kubernetes clusters: | ||
``` | ||
make test-multiple-k8s-clusters | ||
``` | ||
|
||
These Makefile targets are designed to be idempotent, so if you need to re-run the tests after making changes to the code, simply run the appropriate target again. | ||
|
||
Finally, to clean up your environment, run: | ||
``` | ||
make clean | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/bash -xeu | ||
|
||
set -o pipefail | ||
|
||
# Exits with an "unbound variable" error if one of the following environment | ||
# variables is undefined, thanks to "-u" option to bash. | ||
echo "${MINIKUBE}" | ||
echo "${MINIKUBE_HOME}" | ||
echo "${MINIKUBE_PROFILE_PRIMARY}" | ||
echo "${MINIKUBE_PROFILE_SECONDARY}" | ||
|
||
cat <<EOS | ${MINIKUBE} -p ${MINIKUBE_PROFILE_PRIMARY} kubectl -- apply -f - | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.27.0 | ||
ports: | ||
- containerPort: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 8080 | ||
targetPort: 80 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: nginx | ||
EOS | ||
${MINIKUBE} service list -p ${MINIKUBE_PROFILE_PRIMARY} | ||
|
||
URL=$(${MINIKUBE} service list -p ${MINIKUBE_PROFILE_PRIMARY} -o json | jq -r '.[].URLs | select(. | length > 0)[]' | head -1) | ||
|
||
# Exits with an errornous exit code if curl fails, thanks to "-e" option to bash. | ||
${MINIKUBE} -p ${MINIKUBE_PROFILE_SECONDARY} kubectl -- exec -it -n rook-ceph deploy/rook-ceph-tools -- curl ${URL} > /dev/null |