From 607184bff77a4b5075feb5347057fc164a57f256 Mon Sep 17 00:00:00 2001 From: Sowmya viswam Date: Thu, 8 Aug 2024 13:34:07 -0700 Subject: [PATCH] Adding in deploy changes tests for vcluster --- .github/workflows/e2e-deploy-changes.yaml | 273 ++++++++++++++++++ .github/workflows/e2e.yaml | 45 +-- Justfile | 4 +- devspace.yaml | 8 +- .../test-helm-install.sh | 2 +- .../test-kubectl-install.sh | 2 +- .../commonValues.yaml | 45 +++ .../deploy_changes_networking.go | 54 ++++ .../deploy_changes_networking_suite_test.go | 41 +++ .../deploy_changes_networking/helpers.go | 94 ++++++ .../deploy_changes_sync/commonValues.yaml | 42 +++ .../deploy_changes_sync.go | 121 ++++++++ .../deploy_changes_sync_suite_test.go | 16 + .../deploy_changes_sync/helpers.go | 215 ++++++++++++++ test/{ => functional_tests}/README.md | 8 +- test/{ => functional_tests}/commonValues.yaml | 0 .../e2e/coredns/coredns.go | 0 .../e2e/e2e_suite_test.go | 20 +- .../k8sdefaultendpoint/k8sdefaultendpoint.go | 0 .../e2e/manifests/chart.go | 0 .../e2e/manifests/init.go | 0 test/{ => functional_tests}/e2e/node/node.go | 0 .../e2e/servicesync/servicesync.go | 0 .../syncer/networkpolicies/networkpolicies.go | 0 .../e2e/syncer/pods/pods.go | 0 .../e2e/syncer/pvc/pvc.go | 0 .../e2e/syncer/services/services.go | 0 test/{ => functional_tests}/e2e/values.yaml | 0 .../e2e/webhook/cert.go | 0 .../e2e/webhook/utiils.go | 0 .../e2e/webhook/webhook.go | 0 .../e2e_cli/connect/connect.go | 0 .../e2e_cli/e2e_cli_suite_test.go | 2 +- .../e2e_cli/values.yaml | 0 .../clusterscope/ingressclasses.go | 0 .../e2e_generic/e2e_generic_suite_test.go | 2 +- .../e2e_generic/values.yaml | 0 .../e2e_isolation_mode_test.go | 22 +- .../e2e_isolation_mode/isolation/isolated.go | 0 .../e2e_isolation_mode/values.yaml | 0 .../e2e_metrics_proxy_test.go | 2 +- .../metricsproxy/metrics_proxy.go | 0 .../e2e_metrics_proxy/values.yaml | 0 .../e2e_node/e2e_node_suite_test.go | 20 +- .../e2e_node/node/node.go | 0 .../e2e_node/values.yaml | 0 .../e2e_pause_resume_vcluster_test.go | 2 +- .../e2e_pause_resume/pauseresume/vcluster.go | 0 .../e2e_pause_resume/values.yaml | 0 .../e2e_plugin/e2e_plugin_suite_test.go | 2 +- .../e2e_plugin/plugin/plugin.go | 0 .../e2e_plugin/values.yaml | 0 .../e2e_rootless_mode_suite_test.go | 22 +- .../e2e_rootless/rootless/rootlessmode.go | 0 .../e2e_rootless/values.yaml | 0 .../e2e_scheduler/e2e_scheduler_suite_test.go | 20 +- .../e2e_scheduler/scheduler/scheduler.go | 0 .../scheduler/waitforfirstconsumer.go | 0 .../e2e_scheduler/values.yaml | 0 .../e2e_target_namespace_test.go | 2 +- .../e2e_target_namespace/role.yaml | 0 .../targetnamespace/target_namespace.go | 0 .../e2e_target_namespace/values.yaml | 0 .../multins_values.yaml | 0 test/{ => functional_tests}/proValues.yaml | 0 test/{ => functional_tests}/values_ha.yaml | 0 66 files changed, 994 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/e2e-deploy-changes.yaml create mode 100644 test/deploy_changes/deploy_changes_networking/commonValues.yaml create mode 100644 test/deploy_changes/deploy_changes_networking/deploy_changes_networking.go create mode 100644 test/deploy_changes/deploy_changes_networking/deploy_changes_networking_suite_test.go create mode 100644 test/deploy_changes/deploy_changes_networking/helpers.go create mode 100644 test/deploy_changes/deploy_changes_sync/commonValues.yaml create mode 100644 test/deploy_changes/deploy_changes_sync/deploy_changes_sync.go create mode 100644 test/deploy_changes/deploy_changes_sync/deploy_changes_sync_suite_test.go create mode 100644 test/deploy_changes/deploy_changes_sync/helpers.go rename test/{ => functional_tests}/README.md (85%) rename test/{ => functional_tests}/commonValues.yaml (100%) rename test/{ => functional_tests}/e2e/coredns/coredns.go (100%) rename test/{ => functional_tests}/e2e/e2e_suite_test.go (71%) rename test/{ => functional_tests}/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go (100%) rename test/{ => functional_tests}/e2e/manifests/chart.go (100%) rename test/{ => functional_tests}/e2e/manifests/init.go (100%) rename test/{ => functional_tests}/e2e/node/node.go (100%) rename test/{ => functional_tests}/e2e/servicesync/servicesync.go (100%) rename test/{ => functional_tests}/e2e/syncer/networkpolicies/networkpolicies.go (100%) rename test/{ => functional_tests}/e2e/syncer/pods/pods.go (100%) rename test/{ => functional_tests}/e2e/syncer/pvc/pvc.go (100%) rename test/{ => functional_tests}/e2e/syncer/services/services.go (100%) rename test/{ => functional_tests}/e2e/values.yaml (100%) rename test/{ => functional_tests}/e2e/webhook/cert.go (100%) rename test/{ => functional_tests}/e2e/webhook/utiils.go (100%) rename test/{ => functional_tests}/e2e/webhook/webhook.go (100%) rename test/{ => functional_tests}/e2e_cli/connect/connect.go (100%) rename test/{ => functional_tests}/e2e_cli/e2e_cli_suite_test.go (92%) rename test/{ => functional_tests}/e2e_cli/values.yaml (100%) rename test/{ => functional_tests}/e2e_generic/clusterscope/ingressclasses.go (100%) rename test/{ => functional_tests}/e2e_generic/e2e_generic_suite_test.go (91%) rename test/{ => functional_tests}/e2e_generic/values.yaml (100%) rename test/{ => functional_tests}/e2e_isolation_mode/e2e_isolation_mode_test.go (69%) rename test/{ => functional_tests}/e2e_isolation_mode/isolation/isolated.go (100%) rename test/{ => functional_tests}/e2e_isolation_mode/values.yaml (100%) rename test/{ => functional_tests}/e2e_metrics_proxy/e2e_metrics_proxy_test.go (95%) rename test/{ => functional_tests}/e2e_metrics_proxy/metricsproxy/metrics_proxy.go (100%) rename test/{ => functional_tests}/e2e_metrics_proxy/values.yaml (100%) rename test/{ => functional_tests}/e2e_node/e2e_node_suite_test.go (71%) rename test/{ => functional_tests}/e2e_node/node/node.go (100%) rename test/{ => functional_tests}/e2e_node/values.yaml (100%) rename test/{ => functional_tests}/e2e_pause_resume/e2e_pause_resume_vcluster_test.go (95%) rename test/{ => functional_tests}/e2e_pause_resume/pauseresume/vcluster.go (100%) rename test/{ => functional_tests}/e2e_pause_resume/values.yaml (100%) rename test/{ => functional_tests}/e2e_plugin/e2e_plugin_suite_test.go (96%) rename test/{ => functional_tests}/e2e_plugin/plugin/plugin.go (100%) rename test/{ => functional_tests}/e2e_plugin/values.yaml (100%) rename test/{ => functional_tests}/e2e_rootless/e2e_rootless_mode_suite_test.go (69%) rename test/{ => functional_tests}/e2e_rootless/rootless/rootlessmode.go (100%) rename test/{ => functional_tests}/e2e_rootless/values.yaml (100%) rename test/{ => functional_tests}/e2e_scheduler/e2e_scheduler_suite_test.go (71%) rename test/{ => functional_tests}/e2e_scheduler/scheduler/scheduler.go (100%) rename test/{ => functional_tests}/e2e_scheduler/scheduler/waitforfirstconsumer.go (100%) rename test/{ => functional_tests}/e2e_scheduler/values.yaml (100%) rename test/{ => functional_tests}/e2e_target_namespace/e2e_target_namespace_test.go (95%) rename test/{ => functional_tests}/e2e_target_namespace/role.yaml (100%) rename test/{ => functional_tests}/e2e_target_namespace/targetnamespace/target_namespace.go (100%) rename test/{ => functional_tests}/e2e_target_namespace/values.yaml (100%) rename test/{ => functional_tests}/multins_values.yaml (100%) rename test/{ => functional_tests}/proValues.yaml (100%) rename test/{ => functional_tests}/values_ha.yaml (100%) diff --git a/.github/workflows/e2e-deploy-changes.yaml b/.github/workflows/e2e-deploy-changes.yaml new file mode 100644 index 000000000..f9eec9d4d --- /dev/null +++ b/.github/workflows/e2e-deploy-changes.yaml @@ -0,0 +1,273 @@ +name: E2E Deploy Changes CI + +on: + workflow_dispatch: + release: + types: [created] + pull_request: + branches: + - main + - v* + paths: + - "test/deploy_changes/**" + + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + REPOSITORY_NAME: ghcr.io/${{ github.repository }}-ci + TAG_NAME: PR${{ github.event.number }} + VCLUSTER_SUFFIX: vcluster + VCLUSTER_NAME: vcluster + VCLUSTER_NAMESPACE: vcluster + +jobs: + build-and-push-syncer-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.22" + - name: Setup Just + uses: extractions/setup-just@v2 + - name: Setup Syft + uses: anchore/sbom-action/download-syft@v0.17.0 + - name: Setup GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + install-only: true + version: latest + - name: Build and save syncer image + run: | + set -x + TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster --clean --output ./vcluster + docker build -t "${{ env.REPOSITORY_NAME }}:${{ env.TAG_NAME }}" -f Dockerfile.release --build-arg TARGETARCH=amd64 --build-arg TARGETOS=linux . + docker save -o vcluster_syncer "${{ env.REPOSITORY_NAME }}:${{ env.TAG_NAME }}" + - name: Upload syncer image to artifact + uses: actions/upload-artifact@v4 + with: + name: vcluster_syncer + path: ./vcluster_syncer + retention-days: 7 + + build-vcluster-cli: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.22" + - name: Setup Just + uses: extractions/setup-just@v2 + - name: Setup Syft + uses: anchore/sbom-action/download-syft@v0.17.0 + - name: Setup GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + install-only: true + - name: Build vcluster cli + run: | + set -x + TELEMETRY_PRIVATE_KEY="" goreleaser build --single-target --snapshot --id vcluster-cli --clean --output ./vcluster + - name: Upload vcluster cli to artifact + uses: actions/upload-artifact@v4 + with: + name: vcluster + path: ./vcluster + retention-days: 7 + + build-tests: + name: Build tests binaries + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure git + run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ + env: + GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + + - name: Build e2e binary + run: | + cd ./test + go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo build --require-suite -r --mod vendor $(ls -d ./deploy_changes/deploy_* | jq -R . | jq -rcs '. | join(" \\\n")') + env: + GOWORK: off + + - name: Upload test binaries to artifacts + uses: actions/upload-artifact@v4 + with: + name: test-binaries + path: test/deploy_changes/**/*.test + retention-days: 7 + + generate-matrix: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: List test directories + id: set-paths-matrix + run: | + cd ./test + set -x + sudo apt-get install -y jq + + paths=$(ls -d ./deploy_changes/*/) + echo "matrix=$(printf '%s\n' "${paths}" | jq -R . | jq -cs .)" >> "$GITHUB_OUTPUT" + + outputs: + matrix: ${{ steps.set-paths-matrix.outputs.matrix }} + + execute-deploy-tests: + needs: + - build-and-push-syncer-image + - build-vcluster-cli + - build-tests + - generate-matrix + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test-suite-path: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: azure/setup-helm@v4 + name: Setup Helm + with: + version: "v3.11.0" + + - name: Set up kind k8s cluster + uses: engineerd/setup-kind@v0.5.0 + with: + version: "v0.20.0" + image: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e + + - name: Testing kind cluster set-up + run: | + set -x + kubectl cluster-info + kubectl get pods -n kube-system + echo "kubectl config current-context:" $(kubectl config current-context) + echo "KUBECONFIG env var:" ${KUBECONFIG} + + - name: Download vcluster cli + uses: actions/download-artifact@v4 + with: + name: vcluster + + - name: Download syncer image + uses: actions/download-artifact@v4 + with: + name: vcluster_syncer + + - name: Download test binaries + uses: actions/download-artifact@v4 + with: + name: test-binaries + path: ./test/deploy_changes + + - name: Create vcluster + id: create-vcluster + run: | + set -x + + kind load image-archive vcluster_syncer + + chmod +x vcluster && sudo mv vcluster /usr/bin + + cd ./test + + sudo apt-get install -y sed + + sed -i "s|REPLACE_REPOSITORY_NAME|${{ env.REPOSITORY_NAME }}|g" ${{ matrix.test-suite-path }}commonValues.yaml + sed -i "s|REPLACE_TAG_NAME|${{ env.TAG_NAME }}|g" ${{ matrix.test-suite-path }}commonValues.yaml + + vcluster create ${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} \ + --create-namespace \ + --debug \ + --connect=false \ + --local-chart-dir ../chart \ + -f ${{ matrix.test-suite-path }}commonValues.yaml + continue-on-error: true + + - name: Wait until vcluster is ready + id: wait-until-vcluster-is-ready + if: steps.create-vcluster.outcome == 'success' + run: | + set -x + + ./hack/wait-for-pod.sh -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} + + continue-on-error: true + + - name: Collect deployment information in case vcluster fails to start + if: steps.wait-until-vcluster-is-ready.outcome != 'success' + run: | + set -x + kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }} + echo "======================================================================================================================" + kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp' + echo "======================================================================================================================" + kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 + echo "======================================================================================================================" + kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }} + exit 1 + + # Skips NetworkPolicy tests because they require network plugin with support (e.g. Calico) + - name: Execute tests + id: execute-tests + run: | + set -x + + cd ./test/deploy_changes + + cd $(echo "${{ matrix.test-suite-path }}" | sed -e 's#^./deploy_changes/##' -e 's#/$##') + + sudo chmod +x $(echo "${{ matrix.test-suite-path }}" | sed -e 's#^./deploy_changes/##' -e 's#/$##').test + + VCLUSTER_SUFFIX=${{ env.VCLUSTER_SUFFIX }} VCLUSTER_NAME=${{ env.VCLUSTER_NAME }} VCLUSTER_NAMESPACE=${{ env.VCLUSTER_NAMESPACE }} ./$(echo "${{ matrix.test-suite-path }}" | sed -e 's#^./deploy_changes/##' -e 's#/$##').test -test.v --ginkgo.v --ginkgo.skip='.*NetworkPolicy.*' --ginkgo.fail-fast + + if kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p >/dev/null 2>/dev/null; then + echo "vCluster has restarted during testing, failing..." + exit 1 + fi + + continue-on-error: true + + - name: Print logs if tests fail + if: steps.execute-tests.outcome == 'failure' + run: | + set -x + kubectl get pods -o yaml -n ${{ env.VCLUSTER_NAMESPACE }} + echo "======================================================================================================================" + kubectl get events -n ${{ env.VCLUSTER_NAMESPACE }} --sort-by='.lastTimestamp' + echo "======================================================================================================================" + kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 + echo "======================================================================================================================" + kubectl describe pods -n ${{ env.VCLUSTER_NAMESPACE }} + exit 1 + diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index e0abf70bf..58b0dc273 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -10,7 +10,7 @@ on: paths: - "**.go" - "!**_test.go" # exclude test files to ignore unit test changes - - "test/**" # include test files in e2e again + - "test/functional_tests/**" # include test files in e2e again - "!**.md" - "Dockerfile.release" - ".github/workflows/e2e.yaml" @@ -104,7 +104,7 @@ jobs: run: | set -x sudo apt-get install -y jq - paths=$(ls -d ./test/e2e*) + paths=$(ls -d ./test/functional_tests/e2e*) echo "matrix=$(printf '%s\n' "${paths}" | jq -R . | jq -cs .)" >> "$GITHUB_OUTPUT" outputs: matrix: ${{ steps.set-paths-matrix.outputs.matrix }} @@ -129,7 +129,8 @@ jobs: - name: Build e2e binary run: | - go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo build --require-suite -r --mod vendor $(ls -d ./test/e2e* | jq -R . | jq -rcs '. | join(" \\\n")') + go run -mod=vendor github.com/onsi/ginkgo/v2/ginkgo build --require-suite -r --mod vendor $(ls -d ./test/functional_tests/e2e* | jq -R . | jq -rcs '. | join(" \\\n")') + env: GOWORK: off @@ -137,7 +138,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: e2e-binaries - path: ./test/*/*.test + path: ./test/functional_tests/*/*.test retention-days: 7 vcluster-install-delete: @@ -287,14 +288,14 @@ jobs: chmod +x ./vcluster-dev/vcluster set -x - sed -i "s|REPLACE_REPOSITORY_NAME|${{ env.REPOSITORY_NAME }}|g" test/commonValues.yaml - sed -i "s|REPLACE_TAG_NAME|${{ env.TAG_NAME }}|g" test/commonValues.yaml + sed -i "s|REPLACE_REPOSITORY_NAME|${{ env.REPOSITORY_NAME }}|g" test/functional_tests/commonValues.yaml + sed -i "s|REPLACE_TAG_NAME|${{ env.TAG_NAME }}|g" test/functional_tests/commonValues.yaml ./vcluster-dev/vcluster create vcluster --distro=${{ matrix.distribution }} \ --connect=false \ --upgrade \ --local-chart-dir ./chart \ - -f ./test/commonValues.yaml + -f ./test/functional_tests/commonValues.yaml ./hack/wait-for-pod.sh -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} @@ -317,15 +318,15 @@ jobs: include: - distribution: "k8s" ha: "true" - test-suite-path: "./test/e2e" + test-suite-path: "./test/functional_tests/e2e" multinamespace-mode: "false" - distribution: "k3s" ha: "true" - test-suite-path: "./test/e2e" + test-suite-path: "./test/functional_tests/e2e" multinamespace-mode: "false" - distribution: "k0s" ha: "true" - test-suite-path: "./test/e2e" + test-suite-path: "./test/functional_tests/e2e" multinamespace-mode: "false" exclude: - ha: "true" @@ -335,13 +336,13 @@ jobs: multinamespace-mode: "true" - distribution: "k3s" multinamespace-mode: "true" - test-suite-path: "./test/e2e_target_namespace" + test-suite-path: "./test/functional_tests/e2e_target_namespace" - distribution: "k3s" multinamespace-mode: "true" - test-suite-path: "./test/e2e_plugin" + test-suite-path: "./test/functional_tests/e2e_plugin" - distribution: "k3s" multinamespace-mode: "true" - test-suite-path: "./test/e2e_isolation_mode" + test-suite-path: "./test/functional_tests/e2e_isolation_mode" steps: - name: Checkout repository @@ -380,7 +381,7 @@ jobs: uses: actions/download-artifact@v4 with: name: e2e-binaries - path: ./test + path: ./test/functional_tests/ # - name: Setup upterm session for debugging # uses: lhotari/action-upterm@v1 @@ -392,18 +393,18 @@ jobs: extraArgs=() if [ ${{ matrix.multinamespace-mode }} == "true" ]; then - extraArgs+=( -f ./test/multins_values.yaml ) + extraArgs+=( -f ./test/functional_tests/multins_values.yaml ) fi - if [ ${{ matrix.test-suite-path }} == "./test/e2e_metrics_proxy" ]; then + if [ ${{ matrix.test-suite-path }} == "./test/functional_tests/e2e_metrics_proxy" ]; then helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ helm upgrade --install metrics-server metrics-server/metrics-server --set args={--kubelet-insecure-tls} --set containerPort=4443 -n kube-system fi if [ ${{ matrix.ha }} == "true" ]; then - haValues="-f ./test/values_ha.yaml" + haValues="-f ./test/functional_tests/values_ha.yaml" fi - if [ ${{ matrix.test-suite-path }} == "./test/e2e_target_namespace" ]; then + if [ ${{ matrix.test-suite-path }} == "./test/functional_tests/e2e_target_namespace" ]; then kubectl apply -f ${{ matrix.test-suite-path }}/role.yaml fi @@ -422,7 +423,7 @@ jobs: --connect=false \ --distro=${{ matrix.distribution }} \ --local-chart-dir ./chart \ - -f ./test/commonValues.yaml \ + -f ./test/functional_tests/commonValues.yaml \ $haValues \ -f ${{ matrix.test-suite-path }}/values.yaml \ "${extraArgs[@]}" @@ -448,7 +449,7 @@ jobs: echo "======================================================================================================================" kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 echo "======================================================================================================================" - if [[ "${{ matrix.test-suite-path }}" = "./test/e2e_plugin" ]]; then + if [[ "${{ matrix.test-suite-path }}" = "./test/functional_tests/e2e_plugin" ]]; then kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c bootstrap-with-deployment --tail=-1 -p || kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c bootstrap-with-deployment --tail=-1 echo "======================================================================================================================" fi @@ -462,9 +463,9 @@ jobs: run: | set -x - sudo chmod +x $(echo "${{ matrix.test-suite-path }}" | sed "s#./test/##g").test + sudo chmod +x $(echo "${{ matrix.test-suite-path }}" | sed "s#./test/functional_tests/##g").test - VCLUSTER_SUFFIX=${{ env.VCLUSTER_SUFFIX }} VCLUSTER_NAME=${{ env.VCLUSTER_NAME }} VCLUSTER_NAMESPACE=${{ env.VCLUSTER_NAMESPACE }} MULTINAMESPACE_MODE=${{ matrix.multinamespace-mode }} ./$(echo "${{ matrix.test-suite-path }}" | sed "s#./test/##g").test -test.v --ginkgo.v --ginkgo.skip='.*NetworkPolicy.*' --ginkgo.fail-fast + VCLUSTER_SUFFIX=${{ env.VCLUSTER_SUFFIX }} VCLUSTER_NAME=${{ env.VCLUSTER_NAME }} VCLUSTER_NAMESPACE=${{ env.VCLUSTER_NAMESPACE }} MULTINAMESPACE_MODE=${{ matrix.multinamespace-mode }} ./$(echo "${{ matrix.test-suite-path }}" | sed "s#./test/functional_tests/##g").test -test.v --ginkgo.v --ginkgo.skip='.*NetworkPolicy.*' --ginkgo.fail-fast if kubectl logs -l app=${{ env.VCLUSTER_SUFFIX }} -n ${{ env.VCLUSTER_NAMESPACE }} -c syncer --tail=-1 -p >/dev/null 2>/dev/null; then echo "vCluster has restarted during testing, failing..." exit 1 diff --git a/Justfile b/Justfile index 423c30d2f..52ec91b98 100644 --- a/Justfile +++ b/Justfile @@ -84,7 +84,7 @@ embed-chart version="0.0.0": RELEASE_VERSION={{ version }} go generate -tags embed_chart ./... # Run e2e tests -e2e distribution="k3s" path="./test/e2e" multinamespace="false": create-kind && delete-kind +e2e distribution="k3s" path="./test/functional_tests/e2e" multinamespace="false": create-kind && delete-kind echo "Execute test suites ({{ distribution }}, {{ path }}, {{ multinamespace }})" TELEMETRY_PRIVATE_KEY="" goreleaser build --snapshot --clean @@ -113,7 +113,7 @@ e2e distribution="k3s" path="./test/e2e" multinamespace="false": create-kind && --local-chart-dir ./chart/ \ -f ./dist/commonValues.yaml \ -f {{ path }}/values.yaml \ - $([[ "{{ multinamespace }}" = "true" ]] && echo "-f ./test/multins_values.yaml" || echo "") + $([[ "{{ multinamespace }}" = "true" ]] && echo "-f ./test/functional_tests/multins_values.yaml" || echo "") kubectl wait --for=condition=ready pod -l app=vcluster -n vcluster --timeout=300s diff --git a/devspace.yaml b/devspace.yaml index ed8a590b8..c112f687e 100644 --- a/devspace.yaml +++ b/devspace.yaml @@ -6,9 +6,9 @@ vars: # Make sure vcluster is the default namespace DEVSPACE_FLAGS: "-n vcluster" SYNCER_IMAGE: ghcr.io/loft-sh/loft-enterprise/dev-vcluster - COMMON_VALUES: ./test/commonValues.yaml - PRO_VALUES: ./test/proValues.yaml - VALUES_FILE: ./test/e2e/values.yaml + COMMON_VALUES: ./test/functional_tests/commonValues.yaml + PRO_VALUES: ./test/functional_tests/proValues.yaml + VALUES_FILE: ./test/functional_tests/e2e/values.yaml # Images DevSpace will build for vcluster images: @@ -218,7 +218,7 @@ profiles: commands: # e.g. devspace run test k3s - # e.g. devspace run test k3s --var VALUES_FILE=./test/e2e_node + # e.g. devspace run test k3s --var VALUES_FILE=./test/functional_tests/e2e_node test: |- devspace purge -n ${DEVSPACE_NAMESPACE} --debug devspace dev -n ${DEVSPACE_NAMESPACE} --profile test-$@ diff --git a/hack/vcluster-install-scripts/test-helm-install.sh b/hack/vcluster-install-scripts/test-helm-install.sh index 0a80e5a1b..16013c017 100755 --- a/hack/vcluster-install-scripts/test-helm-install.sh +++ b/hack/vcluster-install-scripts/test-helm-install.sh @@ -5,7 +5,7 @@ VCLUSTER_NAME="${VCLUSTER_NAME}" VCLUSTER_NAMESPACE="${VCLUSTER_NAMESPACE}" POLL_INTERVAL=10 MAX_WAIT_TIME=180 -PATH_TO_VALUES_FILE="./test/commonValues.yaml" +PATH_TO_VALUES_FILE="./test/functional_tests/commonValues.yaml" HELM_CHART_DIR="./chart" if [ -z "$VCLUSTER_NAME" ]; then diff --git a/hack/vcluster-install-scripts/test-kubectl-install.sh b/hack/vcluster-install-scripts/test-kubectl-install.sh index 819e8bc1d..ef6536172 100755 --- a/hack/vcluster-install-scripts/test-kubectl-install.sh +++ b/hack/vcluster-install-scripts/test-kubectl-install.sh @@ -6,7 +6,7 @@ VCLUSTER_NAMESPACE="${VCLUSTER_NAMESPACE}" POLL_INTERVAL=10 MAX_WAIT_TIME=180 MANIFEST_FILE="vcluster-manifest.yaml" -PATH_TO_VALUES_FILE="./test/commonValues.yaml" +PATH_TO_VALUES_FILE="./test/functional_tests/commonValues.yaml" HELM_CHART_DIR="./chart" if [ -z "$VCLUSTER_NAME" ]; then diff --git a/test/deploy_changes/deploy_changes_networking/commonValues.yaml b/test/deploy_changes/deploy_changes_networking/commonValues.yaml new file mode 100644 index 000000000..76e8fd1a7 --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/commonValues.yaml @@ -0,0 +1,45 @@ +sync: + toHost: + pods: + useSecretsForSATokens: true + fromHost: + nodes: + enabled: true + selector: + labels: + kubernetes.io/hostname: "kind-control-plane" +controlPlane: + backingStore: + etcd: + deploy: + statefulSet: + resources: + requests: + cpu: "0" + statefulSet: + image: + registry: "" + repository: REPLACE_REPOSITORY_NAME + tag: REPLACE_TAG_NAME + env: + - name: DEBUG + value: "true" + resources: + requests: + cpu: "0" +# values for general test suite +networking: + replicateServices: + toHost: + - from: test/test + to: test + - from: test/nginx + to: nginx + fromHost: + - from: test/test + to: default/test + - from: test/nginx + to: default/nginx +experimental: + syncSettings: + setOwner: true \ No newline at end of file diff --git a/test/deploy_changes/deploy_changes_networking/deploy_changes_networking.go b/test/deploy_changes/deploy_changes_networking/deploy_changes_networking.go new file mode 100644 index 000000000..2cc668782 --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/deploy_changes_networking.go @@ -0,0 +1,54 @@ +package deploynetworkingchanges + +import ( + "time" + + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" +) + +const ( + pollingInterval = time.Second * 2 + pollingDurationLong = time.Minute * 2 + filePath = "commonValues.yaml" + chartPath = "../../../chart" +) + +var _ = ginkgo.Describe("Deploy networking changes to vCluster", func() { + f := framework.DefaultFramework + ginkgo.It("Deploys new changes to vCluster", func() { + + ginkgo.By("Checking for no Resource Quota availability") + framework.ExpectError(CheckNoResourceQuota(f)) + + ginkgo.By("Check if no Limit Range is available") + framework.ExpectError(CheckNoLimitRange(f)) + + ginkgo.By("Check if no network policy is available") + framework.ExpectError(CheckNoNetworkPolicy(f)) + + ginkgo.By("Enabling isolation policies in YAML") + EnableIsolationPolicies() + + ginkgo.By("Replacing placeholders in YAML") + ReplaceYAMLPlaceholders() + + ginkgo.By("Deploying changes to vCluster") + DeployChangesToVClusterUsingCLI(f) + + ginkgo.By("Disconnecting from vCluster") + DisconnectFromVCluster(f) + + ginkgo.By("Verifying cluster is active") + VerifyClusterIsActive(f) + + ginkgo.By("Checking for Resource Quota availability") + framework.ExpectNoError(CheckResourceQuota(f)) + + ginkgo.By("Checking for Limit Range availability") + framework.ExpectNoError(CheckLimitRange(f)) + + ginkgo.By("Checking for Network Policy availability") + framework.ExpectNoError(CheckNetworkPolicy(f)) + }) +}) diff --git a/test/deploy_changes/deploy_changes_networking/deploy_changes_networking_suite_test.go b/test/deploy_changes/deploy_changes_networking/deploy_changes_networking_suite_test.go new file mode 100644 index 000000000..4c37c6be6 --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/deploy_changes_networking_suite_test.go @@ -0,0 +1,41 @@ +package deploynetworkingchanges + +import ( + "context" + "testing" + + "github.com/loft-sh/log" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + + // Enable cloud provider auth + _ "k8s.io/client-go/plugin/pkg/client/auth" +) + +var ( + scheme = runtime.NewScheme() +) + +func init() { + _ = clientgoscheme.AddToScheme(scheme) +} + +func TestRunDeployChangesTests(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + err := framework.CreateFramework(context.Background(), scheme) + if err != nil { + log.GetInstance().Fatalf("Error setting up framework: %v", err) + } + + var _ = ginkgo.AfterSuite(func() { + err = framework.DefaultFramework.Cleanup() + if err != nil { + log.GetInstance().Warnf("Error executing testsuite cleanup: %v", err) + } + }) + + ginkgo.RunSpecs(t, "Vcluster Deploy changes suite") +} diff --git a/test/deploy_changes/deploy_changes_networking/helpers.go b/test/deploy_changes/deploy_changes_networking/helpers.go new file mode 100644 index 000000000..21df93773 --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/helpers.go @@ -0,0 +1,94 @@ +package deploynetworkingchanges + +import ( + "bytes" + "os" + "os/exec" + "strings" + + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func CheckNoResourceQuota(f *framework.Framework) error { + _, err := f.HostClient.CoreV1().ResourceQuotas(f.VclusterNamespace).Get(f.Context, "vc-vcluster", metav1.GetOptions{}) + return err +} + +func CheckNoLimitRange(f *framework.Framework) error { + _, err := f.HostClient.CoreV1().LimitRanges(f.VclusterNamespace).Get(f.Context, "vc-vcluster", metav1.GetOptions{}) + return err +} + +func CheckNoNetworkPolicy(f *framework.Framework) error { + _, err := f.HostClient.NetworkingV1().NetworkPolicies(f.VclusterNamespace).Get(f.Context, "vc-work-vcluster", metav1.GetOptions{}) + return err +} + +func EnableIsolationPolicies() { + isolationParameters := []string{ + ".policies.resourceQuota.enabled = true", + ".policies.limitRange.enabled = true", + ".policies.networkPolicy.enabled = true", + } + + for _, expr := range isolationParameters { + cmdExec := exec.Command("yq", "e", "-i", expr, filePath) + err := cmdExec.Run() + framework.ExpectNoError(err, "Failure to edit file") + } +} + +func ReplaceYAMLPlaceholders() { + replaceCmd := exec.Command("sed", "-i", "s|REPLACE_REPOSITORY_NAME|"+os.Getenv("REPOSITORY_NAME")+"|g", filePath) + err := replaceCmd.Run() + framework.ExpectNoError(err, "Failure to edit file") + + replaceCmd = exec.Command("sed", "-i", "s|REPLACE_TAG_NAME|"+os.Getenv("TAG_NAME")+"|g", filePath) + err = replaceCmd.Run() + framework.ExpectNoError(err, "Failure to edit file") +} + +func DeployChangesToVClusterUsingCLI(f *framework.Framework) { + gomega.Eventually(func() bool { + stdout := &bytes.Buffer{} + deployCmd := exec.Command("vcluster", "create", "--upgrade", f.VclusterName, "--namespace", f.VclusterNamespace, "--local-chart-dir", chartPath, "-f", filePath) + deployCmd.Stdout = stdout + err := deployCmd.Run() + framework.ExpectNoError(err) + return err == nil && strings.Contains(stdout.String(), "Switched active kube context to") + }).WithPolling(pollingInterval).WithTimeout(pollingDurationLong).Should(gomega.BeTrue()) +} + +func DisconnectFromVCluster(f *framework.Framework) { + disconnectCmd := exec.Command("vcluster", "disconnect") + err := disconnectCmd.Run() + if err != nil && !strings.Contains(err.Error(), "not a virtual cluster context") { + framework.ExpectNoError(err, "Error disconnecting from vCluster") + } +} + +func VerifyClusterIsActive(f *framework.Framework) { + gomega.Eventually(func() bool { + checkCmd := exec.Command("vcluster", "list") + output, err := checkCmd.CombinedOutput() + framework.ExpectNoError(err) + return err == nil && strings.Contains(string(output), f.VclusterName) && strings.Contains(string(output), "Running") + }).WithPolling(pollingInterval).WithTimeout(pollingDurationLong).Should(gomega.BeTrue()) +} + +func CheckResourceQuota(f *framework.Framework) error { + _, err := f.HostClient.CoreV1().ResourceQuotas(f.VclusterNamespace).Get(f.Context, "vc-"+f.VclusterName, metav1.GetOptions{}) + return err +} + +func CheckLimitRange(f *framework.Framework) error { + _, err := f.HostClient.CoreV1().LimitRanges(f.VclusterNamespace).Get(f.Context, "vc-"+f.VclusterName, metav1.GetOptions{}) + return err +} + +func CheckNetworkPolicy(f *framework.Framework) error { + _, err := f.HostClient.NetworkingV1().NetworkPolicies(f.VclusterNamespace).Get(f.Context, "vc-work-"+f.VclusterName, metav1.GetOptions{}) + return err +} diff --git a/test/deploy_changes/deploy_changes_sync/commonValues.yaml b/test/deploy_changes/deploy_changes_sync/commonValues.yaml new file mode 100644 index 000000000..691838adb --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/commonValues.yaml @@ -0,0 +1,42 @@ +sync: + fromHost: + nodes: + enabled: false + selector: + labels: + kubernetes.io/hostname: "kind-control-plane" +controlPlane: + backingStore: + etcd: + deploy: + statefulSet: + resources: + requests: + cpu: "0" + statefulSet: + image: + registry: "" + repository: REPLACE_REPOSITORY_NAME + tag: REPLACE_TAG_NAME + env: + - name: DEBUG + value: "true" + resources: + requests: + cpu: "0" +# values for general test suite +networking: + replicateServices: + toHost: + - from: test/test + to: test + - from: test/nginx + to: nginx + fromHost: + - from: test/test + to: default/test + - from: test/nginx + to: default/nginx +experimental: + syncSettings: + setOwner: true diff --git a/test/deploy_changes/deploy_changes_sync/deploy_changes_sync.go b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync.go new file mode 100644 index 000000000..e42a78b44 --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync.go @@ -0,0 +1,121 @@ +package deploysyncchanges + +import ( + "context" + "fmt" + "os" + "time" + + "github.com/loft-sh/log" + "github.com/loft-sh/vcluster/pkg/platform/random" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" +) + +var ( + scheme = runtime.NewScheme() +) + +func init() { + _ = clientgoscheme.AddToScheme(scheme) +} + +const ( + pollingInterval = time.Second * 2 + pollingDurationLong = time.Minute * 2 + vclusterRepo = "https://charts.loft.sh" + filePath = "commonValues.yaml" + chartPath = "../../../chart" + initialNsLabelKey = "testing-ns-label" + initialNsLabelValue = "testing-ns-label-value" + testingContainerName = "nginx" + testingContainerImage = "nginxinc/nginx-unprivileged" +) + +var _ = ginkgo.AfterSuite(func() { + err := framework.DefaultFramework.Cleanup() + if err != nil { + log.GetInstance().Warnf("Error executing testsuite cleanup: %v", err) + } +}) + +var _ = ginkgo.Describe("Deploy sync changes to vCluster", func() { + ginkgo.It("should deploy a vCluster using kubectl and verify sync changes ", func() { + vClusterName := "t-cluster-" + random.String(6) + vClusterNamespace := "t-ns-" + random.String(6) + saName := "t-sa-" + random.String(6) + podName := "t-pod-" + random.String(6) + testNamespace := "t-ns-" + random.String(6) + + ginkgo.By("Conect to virtual cluster vcluster deployed.") + err := ConnectVirtualCluster(os.Getenv("VCLUSTER_NAME")) + if err != nil { + fmt.Println("Failed to connect to virtual cluster vcluster.") + return + } + + ginkgo.By("Create namespace for vCluster to be deployed in.") + createNamespace(vClusterNamespace) + + ginkgo.By("Replacing placeholders in YAML") + err = ReplaceYAMLPlaceholders() + if err != nil { + fmt.Println("Failure to edit file.") + return + } + + ginkgo.By("Deploy vCluster") + err = deployVClusterUsingHelm(vClusterName, vClusterNamespace) + if err != nil { + fmt.Println("Failure to deploy vCluster.") + return + } + + ginkgo.By("Verify vCluster is Active") + verifyClusterIsActive(vClusterName, vClusterNamespace) + + ginkgo.By("Set up framework") + err = framework.CreateFramework(context.Background(), scheme) + framework.ExpectNoError(err, "Error setting up framework") + f := framework.DefaultFramework + + ginkgo.By("Create test namespace in vCluster") + createVClusterTestNamespace(testNamespace, f) + + ginkgo.By("Create service account and pod in vCluster") + createServiceAccount(testNamespace, saName, f) + createPod(testNamespace, podName, f) + + ginkgo.By("Verifying pod, service account and node sync status") + verifyPodSyncToHostStatus(testNamespace, podName, f, true) + verifyServiceAccountSyncToHostStatus(testNamespace, saName, f, false) + verifyNodeSyncFromHostStatus(f, false) + + ginkgo.By("Updating sync settings for vCluster") + syncSettings := []string{ + ".sync.fromHost.nodes.enabled=true", + ".sync.toHost.serviceAccounts.enabled=true", + } + updateVClusterSyncSettings(syncSettings) + + ginkgo.By("Updating vCluster configuration") + updateVClusterUsingHelm(vClusterName, vClusterNamespace) + + ginkgo.By("Verify vCluster is Active") + verifyClusterIsActive(vClusterName, vClusterNamespace) + + ginkgo.By("Verifying updated service account and node sync status") + verifyServiceAccountSyncToHostStatus(testNamespace, saName, f, true) + verifyNodeSyncFromHostStatus(f, true) + ginkgo.By("Verifying service account sync to Host") + + ginkgo.By("Delete vCluster using Helm") + deleteVClusterUsingHelm(vClusterName, vClusterNamespace) + + ginkgo.By("Verify vCluster is deleted") + verifyVClusterDeleted(vClusterName, vClusterNamespace) + + }) +}) diff --git a/test/deploy_changes/deploy_changes_sync/deploy_changes_sync_suite_test.go b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync_suite_test.go new file mode 100644 index 000000000..1c79c957a --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync_suite_test.go @@ -0,0 +1,16 @@ +package deploysyncchanges + +import ( + "testing" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + + // Enable cloud provider auth + _ "k8s.io/client-go/plugin/pkg/client/auth" +) + +func TestRunDeployChangesSyncTests(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "Vcluster Deploy sync changes suite") +} diff --git a/test/deploy_changes/deploy_changes_sync/helpers.go b/test/deploy_changes/deploy_changes_sync/helpers.go new file mode 100644 index 000000000..b96be3273 --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/helpers.go @@ -0,0 +1,215 @@ +package deploysyncchanges + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "strings" + + "github.com/loft-sh/vcluster/pkg/util/translate" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func createNamespace(namespace string) { + createNamespaceCmd := exec.Command("kubectl", "create", "namespace", namespace) + err := createNamespaceCmd.Run() + framework.ExpectNoError(err, "Failed to create namespace") +} + +func deployVClusterUsingHelm(vClusterName string, vClusterNamespace string) error { + var out bytes.Buffer + helmCmd := exec.Command("helm", "upgrade", "--install", vClusterName, chartPath, "--repo", vclusterRepo, "--namespace", vClusterNamespace, "--values", filePath) + helmCmd.Stdout = &out + helmCmd.Stderr = &out // Capture stderr as well + fmt.Println("helmCmd: ", helmCmd) + err := helmCmd.Run() + if err != nil { + fmt.Printf("Error executing helm command: %v\n", err) + fmt.Printf("Command output: %s\n", out.String()) + return err + } + return nil +} + +func verifyClusterIsActive(vClusterName string, vClusterNamespace string) { + gomega.Eventually(func() bool { + checkCmd := exec.Command("vcluster", "list", "-n", vClusterNamespace) + output, err := checkCmd.CombinedOutput() + fmt.Println("output:", string(output)) + if err != nil { + fmt.Printf("Error listing vCluster: %v\n", err) + fmt.Printf("Command output: %s\n", string(output)) + return false + } + return strings.Contains(string(output), vClusterName) && strings.Contains(string(output), "Running") + }).WithPolling(pollingInterval).WithTimeout(pollingDurationLong).Should(gomega.BeTrue(), "Expected vCluster to be Running") +} + +func createVClusterTestNamespace(testNamespace string, f *framework.Framework) { + _, err := f.VClusterClient.CoreV1().Namespaces().Create(f.Context, &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: testNamespace, + Labels: map[string]string{initialNsLabelKey: initialNsLabelValue}, + }, + }, metav1.CreateOptions{}) + framework.ExpectNoError(err, "Failed to create test namespace") +} + +func createServiceAccount(testNamespace string, saName string, f *framework.Framework) { + _, err := f.VClusterClient.CoreV1().ServiceAccounts(testNamespace).Create(f.Context, &corev1.ServiceAccount{ + ObjectMeta: metav1.ObjectMeta{ + Name: saName, + }, + }, metav1.CreateOptions{}) + framework.ExpectNoError(err, "Failed to create service account") + + err = f.WaitForServiceAccount(saName, testNamespace) + framework.ExpectNoError(err) +} + +func createPod(testNamespace string, podName string, f *framework.Framework) { + + _, err := f.VClusterClient.CoreV1().Pods(testNamespace).Create(f.Context, &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: podName}, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: testingContainerName, + Image: testingContainerImage, + ImagePullPolicy: corev1.PullIfNotPresent, + SecurityContext: f.GetDefaultSecurityContext(), + }, + }, + }, + }, metav1.CreateOptions{}) + framework.ExpectNoError(err) + + f.WaitForPodRunning(podName, testNamespace) +} + +func verifyPodSyncToHostStatus(ns, podName string, f *framework.Framework, sync bool) { + fmt.Println("podName in vCluster", podName) + vpod, err := f.VClusterClient.CoreV1().Pods(ns).Get(f.Context, podName, metav1.GetOptions{}) + framework.ExpectNoError(err) + + pPodName := translate.Default.HostName(nil, podName, ns) + pod, err := f.HostClient.CoreV1().Pods(pPodName.Namespace).Get(f.Context, pPodName.Name, metav1.GetOptions{}) + + if sync { + framework.ExpectNoError(err) + framework.ExpectEqual(vpod.Status, pod.Status, "Pod status should be synced between vCluster and Host") + } else { + framework.ExpectError(err) + framework.ExpectNotEqual(vpod.Status, pod.Status, "Pod status should not be synced between vCluster and Host") + } + +} + +func verifyServiceAccountSyncToHostStatus(ns, saName string, f *framework.Framework, sync bool) { + _, err := f.HostClient.CoreV1().ServiceAccounts(ns).Get(f.Context, saName, metav1.GetOptions{}) + if sync { + framework.ExpectNoError(err) + } else { + framework.ExpectError(err) + } +} + +func verifyNodeSyncFromHostStatus(f *framework.Framework, sync bool) { + hostNodes, err := f.HostClient.CoreV1().Nodes().List(f.Context, metav1.ListOptions{}) + framework.ExpectNoError(err) + + virtualNodes, err := f.VClusterClient.CoreV1().Nodes().List(f.Context, metav1.ListOptions{}) + framework.ExpectNoError(err) + + hostname := "kind-control-plane" + + if kindName, ok := os.LookupEnv("KIND_NAME"); ok { + hostname = kindName + "-control-plane" + } + + hostSyncedNodeName := "" + hostNodeLabels := make(map[string]map[string]string) + for _, node := range hostNodes.Items { + hostNodeLabels[node.Name] = node.Labels + if node.Labels["kubernetes.io/hostname"] == hostname { + hostSyncedNodeName = node.Name + break + } + } + + if sync { + framework.ExpectEqual(hostSyncedNodeName, virtualNodes.Items[0].Name) + } else { + framework.ExpectNotEqual(hostSyncedNodeName, virtualNodes.Items[0].Name) + } +} + +func updateVClusterSyncSettings(syncSettings []string) { + for _, expr := range syncSettings { + cmdExec := exec.Command("yq", "e", "-i", expr, filePath) + err := cmdExec.Run() + framework.ExpectNoError(err, "Failure to edit file") + } +} + +func updateVClusterUsingHelm(vClusterName, vClusterNamespace string) { + var out bytes.Buffer + helmCmd := exec.Command("helm", "template", vClusterName, "vcluster", "--repo", vclusterRepo, "-n", vClusterNamespace, "--local-chart-dir", chartPath, "-f", filePath) + helmCmd.Stdout = &out + err := helmCmd.Run() + framework.ExpectNoError(err) + + kubectlCmd := exec.Command("kubectl", "apply", "-f", "-") + kubectlCmd.Stdin = &out + err = kubectlCmd.Run() + framework.ExpectNoError(err) +} + +func deleteVClusterUsingHelm(vClusterName string, vClusterNamespace string) { + // helm delete my-vcluster -n vcluster-my-vcluster + helmCmd := exec.Command("helm", "delete", vClusterName, "-n", vClusterNamespace) + err := helmCmd.Run() + framework.ExpectNoError(err, "Failed to delete vCluster using Helm") +} + +func verifyVClusterDeleted(vClusterName string, vClusterNamespace string) { + checkCmd := exec.Command("vcluster", "list", "-n", vClusterNamespace) + output, err := checkCmd.CombinedOutput() + framework.ExpectNoError(err) + vClusterFound := strings.Contains(string(output), vClusterName) + gomega.Expect(vClusterFound).To(gomega.BeFalse(), "vCluster %s was found in namespace %s", vClusterName, vClusterNamespace) +} + +func ReplaceYAMLPlaceholders() error { + var out bytes.Buffer + replaceCmd := exec.Command("sed", "-i", "s|REPLACE_REPOSITORY_NAME|"+os.Getenv("REPOSITORY_NAME")+"|g", filePath) + replaceCmd.Stdout = &out + replaceCmd.Stderr = &out + err := replaceCmd.Run() + if err != nil { + fmt.Printf("Error executing helm command: %v\n", err) + fmt.Printf("Command output: %s\n", out.String()) + return err + } + + replaceCmd = exec.Command("sed", "-i", "s|REPLACE_TAG_NAME|"+os.Getenv("TAG_NAME")+"|g", filePath) + err = replaceCmd.Run() + if err != nil { + return err + } + return nil +} + +func ConnectVirtualCluster(clusterName string) error { + checkCmd := exec.Command("vcluster", "connect", clusterName) + _, err := checkCmd.CombinedOutput() + if err != nil { + fmt.Printf("Error executing helm command: %v\n", err) + return err + } + return nil +} diff --git a/test/README.md b/test/functional_tests/README.md similarity index 85% rename from test/README.md rename to test/functional_tests/README.md index 83c0fbc51..50d188424 100644 --- a/test/README.md +++ b/test/functional_tests/README.md @@ -3,13 +3,13 @@ 1. Start test environment: - Start the vcluster in test mode `devspace run test ` - - To run the test from the a general test suite i.e from `./test/e2e`. + - To run the test from the a general test suite i.e from `./test/functional_tests/e2e`. `devspace --namespace vcluster run test k3s` - To run tests from a specific test suite, you'll need to specify the values file path from that test suite. - `devspace --namespace vcluster run test k3s --var VALUES_FILE=./test/e2e_node/values.yaml` + `devspace --namespace vcluster run test k3s --var VALUES_FILE=./test/functional_tests/e2e_node/values.yaml` - Then run following command in the terminal to start vcluster syncer. - To run default test suite start syncer with following command @@ -17,11 +17,11 @@ go run -mod vendor cmd/vcluster/main.go start --sync 'networkpolicies' --name=vcluster --service-account=vc-workload-vcluster --kube-config-context-name=my-vcluster --leader-elect=false --sync=nodes --sync=-ingressclasses --node-selector=kubernetes.io/hostname=kind-control-plane '--map-host-service=test/test=default/test' '--map-virtual-service=test/test=test' ``` - - To run tests from other test suites you'll need to change the flags for `go run -mod vendor cmd/vcluster/main.go start` accordingly. You can check the list of syncer flags by running `helm template vcluster ./charts/k3s/ -f ./test/commonValues.yaml -f ./test//values.yaml` + - To run tests from other test suites you'll need to change the flags for `go run -mod vendor cmd/vcluster/main.go start` accordingly. You can check the list of syncer flags by running `helm template vcluster ./charts/k3s/ -f ./test/functional_tests/commonValues.yaml -f ./test/functional_tests//values.yaml` For e.g. ``` - helm template vcluster ./charts/k3s/ -f ./test/commonValues.yaml -f ./test/e2e_target_namespace/values.yaml + helm template vcluster ./charts/k3s/ -f ./test/functional_tests/commonValues.yaml -f ./test/functional_tests/e2e_target_namespace/values.yaml # Then look for `name: syncer` container diff --git a/test/commonValues.yaml b/test/functional_tests/commonValues.yaml similarity index 100% rename from test/commonValues.yaml rename to test/functional_tests/commonValues.yaml diff --git a/test/e2e/coredns/coredns.go b/test/functional_tests/e2e/coredns/coredns.go similarity index 100% rename from test/e2e/coredns/coredns.go rename to test/functional_tests/e2e/coredns/coredns.go diff --git a/test/e2e/e2e_suite_test.go b/test/functional_tests/e2e/e2e_suite_test.go similarity index 71% rename from test/e2e/e2e_suite_test.go rename to test/functional_tests/e2e/e2e_suite_test.go index 1823f051d..7b7e18bdf 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/functional_tests/e2e/e2e_suite_test.go @@ -19,16 +19,16 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e/coredns" - _ "github.com/loft-sh/vcluster/test/e2e/k8sdefaultendpoint" - _ "github.com/loft-sh/vcluster/test/e2e/manifests" - _ "github.com/loft-sh/vcluster/test/e2e/node" - _ "github.com/loft-sh/vcluster/test/e2e/servicesync" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/networkpolicies" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pods" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pvc" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/services" - _ "github.com/loft-sh/vcluster/test/e2e/webhook" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/coredns" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/k8sdefaultendpoint" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/manifests" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/node" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/servicesync" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/networkpolicies" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pods" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pvc" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/services" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/webhook" ) var ( diff --git a/test/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go b/test/functional_tests/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go similarity index 100% rename from test/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go rename to test/functional_tests/e2e/k8sdefaultendpoint/k8sdefaultendpoint.go diff --git a/test/e2e/manifests/chart.go b/test/functional_tests/e2e/manifests/chart.go similarity index 100% rename from test/e2e/manifests/chart.go rename to test/functional_tests/e2e/manifests/chart.go diff --git a/test/e2e/manifests/init.go b/test/functional_tests/e2e/manifests/init.go similarity index 100% rename from test/e2e/manifests/init.go rename to test/functional_tests/e2e/manifests/init.go diff --git a/test/e2e/node/node.go b/test/functional_tests/e2e/node/node.go similarity index 100% rename from test/e2e/node/node.go rename to test/functional_tests/e2e/node/node.go diff --git a/test/e2e/servicesync/servicesync.go b/test/functional_tests/e2e/servicesync/servicesync.go similarity index 100% rename from test/e2e/servicesync/servicesync.go rename to test/functional_tests/e2e/servicesync/servicesync.go diff --git a/test/e2e/syncer/networkpolicies/networkpolicies.go b/test/functional_tests/e2e/syncer/networkpolicies/networkpolicies.go similarity index 100% rename from test/e2e/syncer/networkpolicies/networkpolicies.go rename to test/functional_tests/e2e/syncer/networkpolicies/networkpolicies.go diff --git a/test/e2e/syncer/pods/pods.go b/test/functional_tests/e2e/syncer/pods/pods.go similarity index 100% rename from test/e2e/syncer/pods/pods.go rename to test/functional_tests/e2e/syncer/pods/pods.go diff --git a/test/e2e/syncer/pvc/pvc.go b/test/functional_tests/e2e/syncer/pvc/pvc.go similarity index 100% rename from test/e2e/syncer/pvc/pvc.go rename to test/functional_tests/e2e/syncer/pvc/pvc.go diff --git a/test/e2e/syncer/services/services.go b/test/functional_tests/e2e/syncer/services/services.go similarity index 100% rename from test/e2e/syncer/services/services.go rename to test/functional_tests/e2e/syncer/services/services.go diff --git a/test/e2e/values.yaml b/test/functional_tests/e2e/values.yaml similarity index 100% rename from test/e2e/values.yaml rename to test/functional_tests/e2e/values.yaml diff --git a/test/e2e/webhook/cert.go b/test/functional_tests/e2e/webhook/cert.go similarity index 100% rename from test/e2e/webhook/cert.go rename to test/functional_tests/e2e/webhook/cert.go diff --git a/test/e2e/webhook/utiils.go b/test/functional_tests/e2e/webhook/utiils.go similarity index 100% rename from test/e2e/webhook/utiils.go rename to test/functional_tests/e2e/webhook/utiils.go diff --git a/test/e2e/webhook/webhook.go b/test/functional_tests/e2e/webhook/webhook.go similarity index 100% rename from test/e2e/webhook/webhook.go rename to test/functional_tests/e2e/webhook/webhook.go diff --git a/test/e2e_cli/connect/connect.go b/test/functional_tests/e2e_cli/connect/connect.go similarity index 100% rename from test/e2e_cli/connect/connect.go rename to test/functional_tests/e2e_cli/connect/connect.go diff --git a/test/e2e_cli/e2e_cli_suite_test.go b/test/functional_tests/e2e_cli/e2e_cli_suite_test.go similarity index 92% rename from test/e2e_cli/e2e_cli_suite_test.go rename to test/functional_tests/e2e_cli/e2e_cli_suite_test.go index 1c4f6a702..3a7719d3b 100644 --- a/test/e2e_cli/e2e_cli_suite_test.go +++ b/test/functional_tests/e2e_cli/e2e_cli_suite_test.go @@ -15,7 +15,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e_cli/connect" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_cli/connect" ) var ( diff --git a/test/e2e_cli/values.yaml b/test/functional_tests/e2e_cli/values.yaml similarity index 100% rename from test/e2e_cli/values.yaml rename to test/functional_tests/e2e_cli/values.yaml diff --git a/test/e2e_generic/clusterscope/ingressclasses.go b/test/functional_tests/e2e_generic/clusterscope/ingressclasses.go similarity index 100% rename from test/e2e_generic/clusterscope/ingressclasses.go rename to test/functional_tests/e2e_generic/clusterscope/ingressclasses.go diff --git a/test/e2e_generic/e2e_generic_suite_test.go b/test/functional_tests/e2e_generic/e2e_generic_suite_test.go similarity index 91% rename from test/e2e_generic/e2e_generic_suite_test.go rename to test/functional_tests/e2e_generic/e2e_generic_suite_test.go index 640b9fdb4..b349021dc 100644 --- a/test/e2e_generic/e2e_generic_suite_test.go +++ b/test/functional_tests/e2e_generic/e2e_generic_suite_test.go @@ -15,7 +15,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e_generic/clusterscope" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_generic/clusterscope" ) var ( diff --git a/test/e2e_generic/values.yaml b/test/functional_tests/e2e_generic/values.yaml similarity index 100% rename from test/e2e_generic/values.yaml rename to test/functional_tests/e2e_generic/values.yaml diff --git a/test/e2e_isolation_mode/e2e_isolation_mode_test.go b/test/functional_tests/e2e_isolation_mode/e2e_isolation_mode_test.go similarity index 69% rename from test/e2e_isolation_mode/e2e_isolation_mode_test.go rename to test/functional_tests/e2e_isolation_mode/e2e_isolation_mode_test.go index 7bfc9e479..103d2b3f0 100644 --- a/test/e2e_isolation_mode/e2e_isolation_mode_test.go +++ b/test/functional_tests/e2e_isolation_mode/e2e_isolation_mode_test.go @@ -19,17 +19,17 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e/coredns" - _ "github.com/loft-sh/vcluster/test/e2e/k8sdefaultendpoint" - _ "github.com/loft-sh/vcluster/test/e2e/manifests" - _ "github.com/loft-sh/vcluster/test/e2e/node" - _ "github.com/loft-sh/vcluster/test/e2e/servicesync" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/networkpolicies" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pods" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pvc" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/services" - _ "github.com/loft-sh/vcluster/test/e2e/webhook" - _ "github.com/loft-sh/vcluster/test/e2e_isolation_mode/isolation" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/coredns" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/k8sdefaultendpoint" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/manifests" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/node" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/servicesync" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/networkpolicies" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pods" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pvc" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/services" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/webhook" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_isolation_mode/isolation" ) var ( diff --git a/test/e2e_isolation_mode/isolation/isolated.go b/test/functional_tests/e2e_isolation_mode/isolation/isolated.go similarity index 100% rename from test/e2e_isolation_mode/isolation/isolated.go rename to test/functional_tests/e2e_isolation_mode/isolation/isolated.go diff --git a/test/e2e_isolation_mode/values.yaml b/test/functional_tests/e2e_isolation_mode/values.yaml similarity index 100% rename from test/e2e_isolation_mode/values.yaml rename to test/functional_tests/e2e_isolation_mode/values.yaml diff --git a/test/e2e_metrics_proxy/e2e_metrics_proxy_test.go b/test/functional_tests/e2e_metrics_proxy/e2e_metrics_proxy_test.go similarity index 95% rename from test/e2e_metrics_proxy/e2e_metrics_proxy_test.go rename to test/functional_tests/e2e_metrics_proxy/e2e_metrics_proxy_test.go index 99cfdcb55..272bcc34e 100644 --- a/test/e2e_metrics_proxy/e2e_metrics_proxy_test.go +++ b/test/functional_tests/e2e_metrics_proxy/e2e_metrics_proxy_test.go @@ -19,7 +19,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e_metrics_proxy/metricsproxy" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_metrics_proxy/metricsproxy" ) var ( diff --git a/test/e2e_metrics_proxy/metricsproxy/metrics_proxy.go b/test/functional_tests/e2e_metrics_proxy/metricsproxy/metrics_proxy.go similarity index 100% rename from test/e2e_metrics_proxy/metricsproxy/metrics_proxy.go rename to test/functional_tests/e2e_metrics_proxy/metricsproxy/metrics_proxy.go diff --git a/test/e2e_metrics_proxy/values.yaml b/test/functional_tests/e2e_metrics_proxy/values.yaml similarity index 100% rename from test/e2e_metrics_proxy/values.yaml rename to test/functional_tests/e2e_metrics_proxy/values.yaml diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/functional_tests/e2e_node/e2e_node_suite_test.go similarity index 71% rename from test/e2e_node/e2e_node_suite_test.go rename to test/functional_tests/e2e_node/e2e_node_suite_test.go index 3ffb0c994..1529d1f83 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/functional_tests/e2e_node/e2e_node_suite_test.go @@ -19,16 +19,16 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e/coredns" - _ "github.com/loft-sh/vcluster/test/e2e/k8sdefaultendpoint" - _ "github.com/loft-sh/vcluster/test/e2e/manifests" - _ "github.com/loft-sh/vcluster/test/e2e/servicesync" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/networkpolicies" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pods" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pvc" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/services" - _ "github.com/loft-sh/vcluster/test/e2e/webhook" - _ "github.com/loft-sh/vcluster/test/e2e_node/node" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/coredns" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/k8sdefaultendpoint" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/manifests" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/servicesync" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/networkpolicies" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pods" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pvc" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/services" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/webhook" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_node/node" ) var ( diff --git a/test/e2e_node/node/node.go b/test/functional_tests/e2e_node/node/node.go similarity index 100% rename from test/e2e_node/node/node.go rename to test/functional_tests/e2e_node/node/node.go diff --git a/test/e2e_node/values.yaml b/test/functional_tests/e2e_node/values.yaml similarity index 100% rename from test/e2e_node/values.yaml rename to test/functional_tests/e2e_node/values.yaml diff --git a/test/e2e_pause_resume/e2e_pause_resume_vcluster_test.go b/test/functional_tests/e2e_pause_resume/e2e_pause_resume_vcluster_test.go similarity index 95% rename from test/e2e_pause_resume/e2e_pause_resume_vcluster_test.go rename to test/functional_tests/e2e_pause_resume/e2e_pause_resume_vcluster_test.go index db6eb3bf7..5fc91edf7 100644 --- a/test/e2e_pause_resume/e2e_pause_resume_vcluster_test.go +++ b/test/functional_tests/e2e_pause_resume/e2e_pause_resume_vcluster_test.go @@ -15,7 +15,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" - _ "github.com/loft-sh/vcluster/test/e2e_pause_resume/pauseresume" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_pause_resume/pauseresume" // Enable cloud provider auth _ "k8s.io/client-go/plugin/pkg/client/auth" diff --git a/test/e2e_pause_resume/pauseresume/vcluster.go b/test/functional_tests/e2e_pause_resume/pauseresume/vcluster.go similarity index 100% rename from test/e2e_pause_resume/pauseresume/vcluster.go rename to test/functional_tests/e2e_pause_resume/pauseresume/vcluster.go diff --git a/test/e2e_pause_resume/values.yaml b/test/functional_tests/e2e_pause_resume/values.yaml similarity index 100% rename from test/e2e_pause_resume/values.yaml rename to test/functional_tests/e2e_pause_resume/values.yaml diff --git a/test/e2e_plugin/e2e_plugin_suite_test.go b/test/functional_tests/e2e_plugin/e2e_plugin_suite_test.go similarity index 96% rename from test/e2e_plugin/e2e_plugin_suite_test.go rename to test/functional_tests/e2e_plugin/e2e_plugin_suite_test.go index e7bdf33c0..e9fb9d613 100644 --- a/test/e2e_plugin/e2e_plugin_suite_test.go +++ b/test/functional_tests/e2e_plugin/e2e_plugin_suite_test.go @@ -15,7 +15,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" - _ "github.com/loft-sh/vcluster/test/e2e_plugin/plugin" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_plugin/plugin" // Enable cloud provider auth _ "k8s.io/client-go/plugin/pkg/client/auth" diff --git a/test/e2e_plugin/plugin/plugin.go b/test/functional_tests/e2e_plugin/plugin/plugin.go similarity index 100% rename from test/e2e_plugin/plugin/plugin.go rename to test/functional_tests/e2e_plugin/plugin/plugin.go diff --git a/test/e2e_plugin/values.yaml b/test/functional_tests/e2e_plugin/values.yaml similarity index 100% rename from test/e2e_plugin/values.yaml rename to test/functional_tests/e2e_plugin/values.yaml diff --git a/test/e2e_rootless/e2e_rootless_mode_suite_test.go b/test/functional_tests/e2e_rootless/e2e_rootless_mode_suite_test.go similarity index 69% rename from test/e2e_rootless/e2e_rootless_mode_suite_test.go rename to test/functional_tests/e2e_rootless/e2e_rootless_mode_suite_test.go index cf683775b..903c0dbe3 100644 --- a/test/e2e_rootless/e2e_rootless_mode_suite_test.go +++ b/test/functional_tests/e2e_rootless/e2e_rootless_mode_suite_test.go @@ -19,17 +19,17 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e/coredns" - _ "github.com/loft-sh/vcluster/test/e2e/k8sdefaultendpoint" - _ "github.com/loft-sh/vcluster/test/e2e/manifests" - _ "github.com/loft-sh/vcluster/test/e2e/node" - _ "github.com/loft-sh/vcluster/test/e2e/servicesync" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/networkpolicies" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pods" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pvc" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/services" - _ "github.com/loft-sh/vcluster/test/e2e/webhook" - _ "github.com/loft-sh/vcluster/test/e2e_rootless/rootless" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/coredns" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/k8sdefaultendpoint" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/manifests" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/node" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/servicesync" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/networkpolicies" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pods" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pvc" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/services" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/webhook" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_rootless/rootless" ) var ( diff --git a/test/e2e_rootless/rootless/rootlessmode.go b/test/functional_tests/e2e_rootless/rootless/rootlessmode.go similarity index 100% rename from test/e2e_rootless/rootless/rootlessmode.go rename to test/functional_tests/e2e_rootless/rootless/rootlessmode.go diff --git a/test/e2e_rootless/values.yaml b/test/functional_tests/e2e_rootless/values.yaml similarity index 100% rename from test/e2e_rootless/values.yaml rename to test/functional_tests/e2e_rootless/values.yaml diff --git a/test/e2e_scheduler/e2e_scheduler_suite_test.go b/test/functional_tests/e2e_scheduler/e2e_scheduler_suite_test.go similarity index 71% rename from test/e2e_scheduler/e2e_scheduler_suite_test.go rename to test/functional_tests/e2e_scheduler/e2e_scheduler_suite_test.go index 16adb5039..7507c4100 100644 --- a/test/e2e_scheduler/e2e_scheduler_suite_test.go +++ b/test/functional_tests/e2e_scheduler/e2e_scheduler_suite_test.go @@ -19,16 +19,16 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests - _ "github.com/loft-sh/vcluster/test/e2e/coredns" - _ "github.com/loft-sh/vcluster/test/e2e/k8sdefaultendpoint" - _ "github.com/loft-sh/vcluster/test/e2e/manifests" - _ "github.com/loft-sh/vcluster/test/e2e/servicesync" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/networkpolicies" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pods" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/pvc" - _ "github.com/loft-sh/vcluster/test/e2e/syncer/services" - _ "github.com/loft-sh/vcluster/test/e2e/webhook" - _ "github.com/loft-sh/vcluster/test/e2e_scheduler/scheduler" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/coredns" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/k8sdefaultendpoint" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/manifests" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/servicesync" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/networkpolicies" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pods" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/pvc" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/syncer/services" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e/webhook" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_scheduler/scheduler" ) var ( diff --git a/test/e2e_scheduler/scheduler/scheduler.go b/test/functional_tests/e2e_scheduler/scheduler/scheduler.go similarity index 100% rename from test/e2e_scheduler/scheduler/scheduler.go rename to test/functional_tests/e2e_scheduler/scheduler/scheduler.go diff --git a/test/e2e_scheduler/scheduler/waitforfirstconsumer.go b/test/functional_tests/e2e_scheduler/scheduler/waitforfirstconsumer.go similarity index 100% rename from test/e2e_scheduler/scheduler/waitforfirstconsumer.go rename to test/functional_tests/e2e_scheduler/scheduler/waitforfirstconsumer.go diff --git a/test/e2e_scheduler/values.yaml b/test/functional_tests/e2e_scheduler/values.yaml similarity index 100% rename from test/e2e_scheduler/values.yaml rename to test/functional_tests/e2e_scheduler/values.yaml diff --git a/test/e2e_target_namespace/e2e_target_namespace_test.go b/test/functional_tests/e2e_target_namespace/e2e_target_namespace_test.go similarity index 95% rename from test/e2e_target_namespace/e2e_target_namespace_test.go rename to test/functional_tests/e2e_target_namespace/e2e_target_namespace_test.go index eb41b07ca..d1345035a 100644 --- a/test/e2e_target_namespace/e2e_target_namespace_test.go +++ b/test/functional_tests/e2e_target_namespace/e2e_target_namespace_test.go @@ -16,7 +16,7 @@ import ( apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" // Enable cloud provider auth - _ "github.com/loft-sh/vcluster/test/e2e_target_namespace/targetnamespace" + _ "github.com/loft-sh/vcluster/test/functional_tests/e2e_target_namespace/targetnamespace" _ "k8s.io/client-go/plugin/pkg/client/auth" // Register tests ) diff --git a/test/e2e_target_namespace/role.yaml b/test/functional_tests/e2e_target_namespace/role.yaml similarity index 100% rename from test/e2e_target_namespace/role.yaml rename to test/functional_tests/e2e_target_namespace/role.yaml diff --git a/test/e2e_target_namespace/targetnamespace/target_namespace.go b/test/functional_tests/e2e_target_namespace/targetnamespace/target_namespace.go similarity index 100% rename from test/e2e_target_namespace/targetnamespace/target_namespace.go rename to test/functional_tests/e2e_target_namespace/targetnamespace/target_namespace.go diff --git a/test/e2e_target_namespace/values.yaml b/test/functional_tests/e2e_target_namespace/values.yaml similarity index 100% rename from test/e2e_target_namespace/values.yaml rename to test/functional_tests/e2e_target_namespace/values.yaml diff --git a/test/multins_values.yaml b/test/functional_tests/multins_values.yaml similarity index 100% rename from test/multins_values.yaml rename to test/functional_tests/multins_values.yaml diff --git a/test/proValues.yaml b/test/functional_tests/proValues.yaml similarity index 100% rename from test/proValues.yaml rename to test/functional_tests/proValues.yaml diff --git a/test/values_ha.yaml b/test/functional_tests/values_ha.yaml similarity index 100% rename from test/values_ha.yaml rename to test/functional_tests/values_ha.yaml