diff --git a/.github/compose.yml b/.github/compose.yml new file mode 100644 index 0000000..ac8ba97 --- /dev/null +++ b/.github/compose.yml @@ -0,0 +1,15 @@ +services: + incus: + image: ghcr.io/miscord-dev/incus-docker-debian:bookworm-slim-6.7-20241127 + container_name: incus + privileged: true + environment: + - SETIPTABLES=true + restart: unless-stopped + network_mode: host + pid: host + cgroup: host + volumes: + - /dev:/dev + - /var/lib/incus:/var/lib/incus + - /lib/modules:/lib/modules:ro diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index b6e9e2a..3b8f36a 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@v4 - run: | - docker compose up -d + cd .github && docker compose up -d docker ps -a curl -LO https://github.com/lxc/incus/releases/latest/download/bin.linux.incus.x86_64 sudo install *incus* /usr/local/bin/incus @@ -58,6 +58,7 @@ jobs: "access_token": idToken, "token": "bearer", })) + require("fs").writeFileSync(homedir + "/.config/incus/oidctokens/incus.txt", idToken) - run: | mkdir -p ~/.config/incus/servercerts @@ -94,6 +95,8 @@ jobs: - name: Running Test e2e run: | + export INCUS_CERT=~/.config/incus/servercerts/incus.crt + export INCUS_TOKEN=~/.config/incus/oidctokens/incus.txt go mod tidy make test-e2e diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index b7c52cd..9a4dfc6 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -58,6 +58,29 @@ var _ = Describe("Manager", Ordered, func() { _, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to install CRDs") + patch, _ := json.Marshal([]any{ + map[string]any{ + "op": "replace", + "path": "/spec/template/spec/containers/0/args", + "value": []string{ + "--leader-elect", + "--health-probe-bind-address=:8081", + "--incus-url=https://localhost:8443", + "--incus-insecure-skip-tls-verify", + "--incus-tls-ca=" + os.Getenv("INCUS_CERT"), + "--incus-oidc-token-file=/tmp/incus-token" + os.Getenv("INCUS_TOKEN"), + }, + }, + }) + + cmd = exec.Command("kubectl", "patch", "deployment", "cluster-api-provider-incus-controller-manager", + "-n", namespace, + "--type=json", + "-p="+string(patch), + ) + _, err = utils.Run(cmd) + Expect(err).NotTo(HaveOccurred(), "Failed to patch Deployment") + By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) _, err = utils.Run(cmd)