-
Notifications
You must be signed in to change notification settings - Fork 6
97 lines (78 loc) · 3.1 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Build and Deploy
on: [push, pull_request]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
CHECKPOINT_DIR: /var/lib/kubelet/checkpoints
REGISTRY_PORT: 5000
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Install dependencies
run: |
# Install bats
sudo apt-get update
sudo apt-get install -y bats
# Install kind
curl -sLo kind "$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r '[.assets[] | select(.name == "kind-linux-amd64")] | first | .browser_download_url')"
chmod +x kind
sudo mv kind /bin/
# Install kubectl
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /bin/
- name: Prepare Checkpoints Directory in Host
run: |
sudo mkdir -p ${{ env.CHECKPOINT_DIR }}
sudo chmod 700 ${{ env.CHECKPOINT_DIR }}
- name: Generate Checkpoint Tar Files
run: ./test/generate_checkpoint_tar.sh
- name: Create Kubernetes cluster
run: |
kind create cluster --config=./test/kind-config.yaml
kind export kubeconfig
- name: Connect the registry to the Kind network
id: connect-registry
run: |
REGISTRY_ID=$(docker ps -qf "ancestor=registry:2")
REGISTRY_NAME=$(docker inspect -f '{{.Name}}' $REGISTRY_ID | sed 's/\///')
echo "REGISTRY_NAME=$REGISTRY_NAME" >> $GITHUB_ENV
./test/configure_local_registry.sh
env:
REGISTRY_PORT: ${{ env.REGISTRY_PORT }}
REGISTRY_NAME: ${{ env.REGISTRY_NAME }}
- name: Build and push to local registry
uses: docker/build-push-action@v6
with:
push: true
tags: localhost:5000/checkpoint-restore-operator:ci
- name: Deploy to Kubernetes
run: |
make install
make deploy IMG=localhost:5000/checkpoint-restore-operator:ci
- name: Wait for deployments to be ready
run: ./test/wait_for_deployment.sh checkpoint-restore-operator-controller-manager
- name: Check resources
run: kubectl get all -n checkpoint-restore-operator-system
- name: Test Garbage Collection
run: sudo -E bats -f "test_garbage_collection" ./test/run_tests.bats
- name: Test Max Checkpoints Set to 0
run: sudo -E bats -f "test_max_checkpoints_set_to_0" ./test/run_tests.bats
- name: Test Max Checkpoints Set to 1
run: sudo -E bats -f "test_max_checkpoints_set_to_1" ./test/run_tests.bats