diff --git a/.github/workflows/e2e-deploy-changes.yaml b/.github/workflows/e2e-deploy-changes.yaml new file mode 100644 index 0000000000..00fcc3419f --- /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/*/ | grep -v 'common/') + 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 e0abf70bfc..58b0dc273c 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 423c30d2f0..52ec91b989 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 ed8a590b87..c112f687ee 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 0a80e5a1bc..16013c017a 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 819e8bc1da..ef65361729 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/common/common_helpers.go b/test/deploy_changes/common/common_helpers.go new file mode 100644 index 0000000000..23150eee0b --- /dev/null +++ b/test/deploy_changes/common/common_helpers.go @@ -0,0 +1,57 @@ +package common + +import ( + "bytes" + "os" + "os/exec" + "strings" + "time" + + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/gomega" +) + +const ( + pollingInterval = time.Second * 2 + pollingDurationLong = time.Minute * 2 + filePath = "commonValues.yaml" + chartPath = "../../../chart" +) + +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() { + 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()) +} 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 0000000000..76e8fd1a7e --- /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 0000000000..3f09bc2dcf --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/deploy_changes_networking.go @@ -0,0 +1,46 @@ +package deploynetworkingchanges + +import ( + "github.com/loft-sh/vcluster/test/deploy_changes/common" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" +) + +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") + common.ReplaceYAMLPlaceholders() + + ginkgo.By("Deploying changes to vCluster") + common.DeployChangesToVClusterUsingCLI(f) + + ginkgo.By("Disconnecting from vCluster") + common.DisconnectFromVCluster() + + ginkgo.By("Verifying cluster is active") + common.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 0000000000..4c37c6be6c --- /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 0000000000..27220d0375 --- /dev/null +++ b/test/deploy_changes/deploy_changes_networking/helpers.go @@ -0,0 +1,60 @@ +package deploynetworkingchanges + +import ( + "os/exec" + "time" + + "github.com/loft-sh/vcluster/test/framework" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + pollingInterval = time.Second * 2 + pollingDurationLong = time.Minute * 2 + filePath = "commonValues.yaml" + chartPath = "../../../chart" +) + +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 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 0000000000..234ef6b525 --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/commonValues.yaml @@ -0,0 +1,35 @@ +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 0000000000..5aa7987b5d --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync.go @@ -0,0 +1,67 @@ +package deploysyncchanges + +import ( + "time" + + "github.com/loft-sh/vcluster/pkg/platform/random" + "github.com/loft-sh/vcluster/test/deploy_changes/common" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + "k8s.io/apimachinery/pkg/runtime" +) + +var ( + scheme = runtime.NewScheme() +) + +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.Describe("Deploy sync changes to vCluster", func() { + ginkgo.It("should deploy a vCluster using kubectl and verify sync changes ", func() { + f := framework.DefaultFramework + saName := "t-sa-" + random.String(6) + podName := "t-pod-" + random.String(6) + testNamespace := "t-ns-" + random.String(6) + 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 sync status") + verifyPodSyncToHostStatus(testNamespace, podName, f, true) + verifyServiceAccountSyncToHostStatus(testNamespace, saName, f, false) + + ginkgo.By("Updating sync settings for vCluster") + syncSettings := []string{ + ".sync.toHost.serviceAccounts.enabled=true", + } + updateVClusterSyncSettings(syncSettings) + + ginkgo.By("Replacing placeholders in YAML") + common.ReplaceYAMLPlaceholders() + + ginkgo.By("Deploying changes to vCluster") + common.DeployChangesToVClusterUsingCLI(f) + + ginkgo.By("Disconnecting from vCluster") + common.DisconnectFromVCluster() + + ginkgo.By("Verifying cluster is active") + common.VerifyClusterIsActive(f) + + ginkgo.By("Verifying service account sync to Host") + verifyServiceAccountSyncToHostStatus(testNamespace, saName, f, true) + }) +}) 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 0000000000..f425e6f8d7 --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/deploy_changes_sync_suite_test.go @@ -0,0 +1,37 @@ +package deploysyncchanges + +import ( + "context" + "testing" + + "github.com/loft-sh/log" + "github.com/loft-sh/vcluster/test/framework" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + + // Enable cloud provider auth + + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + _ "k8s.io/client-go/plugin/pkg/client/auth" +) + +func init() { + _ = clientgoscheme.AddToScheme(scheme) +} + +func TestRunDeployChangesSyncTests(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 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 0000000000..1163a26bec --- /dev/null +++ b/test/deploy_changes/deploy_changes_sync/helpers.go @@ -0,0 +1,86 @@ +package deploysyncchanges + +import ( + "os/exec" + + "github.com/loft-sh/vcluster/pkg/util/translate" + "github.com/loft-sh/vcluster/test/framework" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +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) + + err = f.WaitForPodRunning(podName, testNamespace) + framework.ExpectNoError(err, "A pod created in the vcluster is expected to be in the Running phase eventually.") +} + +func verifyPodSyncToHostStatus(ns, podName string, f *framework.Framework, sync bool) { + 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) { + hostSaName := translate.Default.HostName(nil, saName, ns) + _, err := f.HostClient.CoreV1().ServiceAccounts(hostSaName.Namespace).Get(f.Context, hostSaName.Name, metav1.GetOptions{}) + if sync { + framework.ExpectNoError(err, "ServiceAccount is not synced to Host as expected") + } else { + framework.ExpectError(err, "ServiceAccount is synced to Host which is not expected") + } +} + +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") + } +} 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 83c0fbc51c..50d1884245 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 1823f051d0..7b7e18bdf9 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 1c4f6a7026..3a7719d3bb 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 640b9fdb46..b349021dca 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 7bfc9e4796..103d2b3f08 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 99cfdcb554..272bcc34e5 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 3ffb0c9940..1529d1f830 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 db6eb3bf76..5fc91edf78 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 e7bdf33c03..e9fb9d6134 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 cf683775b7..903c0dbe39 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 16adb50396..7507c4100c 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 eb41b07caa..d1345035a4 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