From 2c9d013d33ac0e919a27ff9291d4efe614a2599e Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Wed, 31 Jul 2024 19:38:13 +0900 Subject: [PATCH] Start k3d in ci-container and execute e2e test to k8s cluster (#2554) * feat: start k3d in ci container and execute e2e test to k8s cluster Signed-off-by: hlts2 fix: verify for e2e Signed-off-by: hlts2 fix: deleted sudo Signed-off-by: hlts2 fix: use trimPrefix insted of TrimLeft Signed-off-by: hlts2 fix: e2e host Signed-off-by: hlts2 fix: update host Signed-off-by: hlts2 fix: use bash Signed-off-by: hlts2 * fix: deleted unnecessary deps Signed-off-by: hlts2 * fix: refactor k3d option settings Signed-off-by: hlts2 * Update .github/actions/setup-k3d/action.yaml Signed-off-by: Yusuke Kato --------- Signed-off-by: hlts2 Signed-off-by: Yusuke Kato Co-authored-by: Yusuke Kato --- .github/actions/setup-e2e/action.yaml | 4 ++-- .github/actions/setup-k3d/action.yaml | 2 +- .github/helm/values/values-chaos.yaml | 2 +- .github/workflows/e2e-chaos.yaml | 14 +++++++++----- .github/workflows/e2e-code-bench-agent.yaml | 2 ++ .github/workflows/e2e-max-dim.yml | 3 ++- .github/workflows/e2e-profiling.yml | 7 ++----- .github/workflows/e2e.yml | 11 ++++++++++- tests/e2e/kubernetes/portforward/portforward.go | 2 +- 9 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/actions/setup-e2e/action.yaml b/.github/actions/setup-e2e/action.yaml index e3a18d35de2..6cf17458096 100644 --- a/.github/actions/setup-e2e/action.yaml +++ b/.github/actions/setup-e2e/action.yaml @@ -58,8 +58,8 @@ runs: if: ${{ inputs.require_libhdf5 == 'true' }} shell: bash run: | - sudo apt-get update - sudo apt-get install -y libhdf5-dev + apt-get update + apt-get install -y libhdf5-dev - name: Setup Go environment if: ${{ inputs.require_go == 'true' }} uses: ./.github/actions/setup-go diff --git a/.github/actions/setup-k3d/action.yaml b/.github/actions/setup-k3d/action.yaml index cf917d0c3ee..a39abc5e12b 100644 --- a/.github/actions/setup-k3d/action.yaml +++ b/.github/actions/setup-k3d/action.yaml @@ -96,7 +96,7 @@ runs: k3d cluster create ${{ inputs.name }} ${{ steps.k3d_options.outputs.options }} \ --image docker.io/rancher/k3s:latest \ --k3s-arg "--disable=traefik@server:*" \ - --api-port 0.0.0.0:6443 \ + --api-port host.docker.internal:6550 \ --wait k3d cluster start ${{ inputs.name }} k3d kubeconfig merge ${{ inputs.name }} --kubeconfig-switch-context diff --git a/.github/helm/values/values-chaos.yaml b/.github/helm/values/values-chaos.yaml index 20566b4c226..99d65826e42 100644 --- a/.github/helm/values/values-chaos.yaml +++ b/.github/helm/values/values-chaos.yaml @@ -35,7 +35,7 @@ gateway: enabled: true ingress: enabled: true - host: "localhost" + host: "host.docker.internal" service: # NOTE: https://doc.traefik.io/traefik/routing/providers/kubernetes-ingress/#on-service annotations: diff --git a/.github/workflows/e2e-chaos.yaml b/.github/workflows/e2e-chaos.yaml index ed93101f731..3cf97154920 100644 --- a/.github/workflows/e2e-chaos.yaml +++ b/.github/workflows/e2e-chaos.yaml @@ -30,12 +30,12 @@ env: INGRESS_PORT: 8081 jobs: dump-contexts-to-log: - if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-chaos' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/dump-context detect-ci-container: + if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy' uses: ./.github/workflows/_detect-ci-container.yml agent-failure: name: "E2E chaos test (Agent failure: to test insert/search works even if one of the agents is failing)" @@ -44,6 +44,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -68,7 +69,7 @@ jobs: - name: Run Insert and Search operations run: | make hack/benchmark/assets/dataset/${{ env.DATASET }} - make E2E_BIND_HOST=localhost \ + make E2E_BIND_HOST=host.docker.internal \ E2E_BIND_PORT=8081 \ E2E_PORTFORWARD_ENABLED=false \ E2E_DATASET_NAME=${{ env.DATASET }} \ @@ -84,6 +85,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -108,7 +110,7 @@ jobs: - name: Run Insert and Search operations run: | make hack/benchmark/assets/dataset/${{ env.DATASET }} - make E2E_BIND_HOST=localhost \ + make E2E_BIND_HOST=host.docker.internal \ E2E_BIND_PORT=8081 \ E2E_PORTFORWARD_ENABLED=false \ E2E_DATASET_NAME=${{ env.DATASET }} \ @@ -124,6 +126,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -148,7 +151,7 @@ jobs: - name: Run Insert and Search operations run: | make hack/benchmark/assets/dataset/${{ env.DATASET }} - make E2E_BIND_HOST=localhost \ + make E2E_BIND_HOST=host.docker.internal \ E2E_BIND_PORT=8081 \ E2E_PORTFORWARD_ENABLED=false \ E2E_DATASET_NAME=${{ env.DATASET }} \ @@ -164,6 +167,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -188,7 +192,7 @@ jobs: - name: Run Insert and Search operations run: | make hack/benchmark/assets/dataset/${{ env.DATASET }} - make E2E_BIND_HOST=localhost \ + make E2E_BIND_HOST=host.docker.internal \ E2E_BIND_PORT=8081 \ E2E_PORTFORWARD_ENABLED=false \ E2E_DATASET_NAME=${{ env.DATASET }} \ diff --git a/.github/workflows/e2e-code-bench-agent.yaml b/.github/workflows/e2e-code-bench-agent.yaml index 015873aaef6..f6bfe972ce6 100644 --- a/.github/workflows/e2e-code-bench-agent.yaml +++ b/.github/workflows/e2e-code-bench-agent.yaml @@ -58,6 +58,7 @@ jobs: needs: [detect-ci-container] container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -85,6 +86,7 @@ jobs: needs: [detect-ci-container] container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config diff --git a/.github/workflows/e2e-max-dim.yml b/.github/workflows/e2e-max-dim.yml index 00bf9e53607..23610f34dc0 100644 --- a/.github/workflows/e2e-max-dim.yml +++ b/.github/workflows/e2e-max-dim.yml @@ -27,12 +27,12 @@ on: - "labeled" jobs: dump-contexts-to-log: - if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-max-dim' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/dump-context detect-ci-container: + if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy' uses: ./.github/workflows/_detect-ci-container.yml e2e-max-dimension-insert: name: "E2E test (Max Dimension Insert: skip strict exist check)" @@ -41,6 +41,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config diff --git a/.github/workflows/e2e-profiling.yml b/.github/workflows/e2e-profiling.yml index 38b0d9332a9..203e189bb84 100644 --- a/.github/workflows/e2e-profiling.yml +++ b/.github/workflows/e2e-profiling.yml @@ -28,12 +28,12 @@ env: DATASET: fashion-mnist-784-euclidean.hdf5 jobs: dump-contexts-to-log: - if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-profiling' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/dump-context detect-ci-container: + if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy' uses: ./.github/workflows/_detect-ci-container.yml e2e-profiling: name: "E2E profiling" @@ -42,6 +42,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -104,10 +105,6 @@ jobs: path: ./profiles-main key: ${{ runner.os }}-profiles-main-${{ github.sha }} restore-keys: ${{ runner.os }}-profiles-main- - - name: Install dependencies - run: | - sudo apt update - sudo apt install -y graphviz - name: Generate graphs run: | tag=$(cat profiles-main/VALD_VERSION || echo "unknown") diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 104878d2436..14b20bdb24d 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -28,12 +28,12 @@ env: DATASET: fashion-mnist-784-euclidean.hdf5 jobs: dump-contexts-to-log: - if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/dump-context detect-ci-container: + if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy' uses: ./.github/workflows/_detect-ci-container.yml e2e-stream-crud: name: "E2E test (Stream CRUD)" @@ -42,6 +42,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -82,6 +83,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -100,6 +102,7 @@ jobs: require_helm: false require_k3d: false - name: Merge Docker image tag + shell: bash run: | IMAGE_TAGS=(${{ steps.setup_e2e.outputs.IMAGE_TAGS }}) @@ -144,6 +147,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -188,6 +192,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -228,6 +233,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -264,6 +270,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -297,6 +304,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config @@ -347,6 +355,7 @@ jobs: timeout-minutes: 60 container: image: ghcr.io/vdaas/vald/vald-ci-container:${{ needs.detect-ci-container.outputs.TAG }} + options: "--add-host host.docker.internal:host-gateway" steps: - uses: actions/checkout@v4 - name: Set Git config diff --git a/tests/e2e/kubernetes/portforward/portforward.go b/tests/e2e/kubernetes/portforward/portforward.go index 1d53431f64d..09c11a7af6f 100644 --- a/tests/e2e/kubernetes/portforward/portforward.go +++ b/tests/e2e/kubernetes/portforward/portforward.go @@ -68,7 +68,7 @@ func (p *Portforward) Start() error { path := fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/portforward", p.namespace, p.podName) - hostIP := strings.TrimLeft(p.restConfig.Host, "https:/") + hostIP := strings.TrimPrefix(strings.TrimPrefix(p.restConfig.Host, "http://"), "https://") transport, upgrader, err := spdy.RoundTripperFor(p.restConfig) if err != nil {