Skip to content

Commit

Permalink
test namespace
Browse files Browse the repository at this point in the history
Signed-off-by: yiraeChristineKim <yikim@redhat.com>
  • Loading branch information
yiraeChristineKim committed May 8, 2024
1 parent 23829cd commit 212a6ef
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 355 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ jobs:
run: |
KUBECONFIG=${PWD}/kubeconfig_managed make kind-ensure-sa
- name: E2E Tests
run: |
export GOPATH=$(go env GOPATH)
KUBECONFIG=${PWD}/kubeconfig_managed make e2e-test-coverage
- name: Create K8s KinD Cluster to simulate hosted mode - ${{ matrix.kind }}
env:
KIND_VERSION: ${{ matrix.kind }}
run: |
make kind-additional-cluster
- name: E2E tests that simulate hosted mode
run: |
export GOPATH=$(go env GOPATH)
KUBECONFIG=${PWD}/kubeconfig_managed make e2e-test-hosted-mode-coverage
- name: E2E Tests
run: |
export GOPATH=$(go env GOPATH)
KUBECONFIG=${PWD}/kubeconfig_managed make e2e-test-coverage
- name: Verify Deployment Configuration
run: |
make build-images
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,21 @@ install-resources:
kubectl apply -f deploy/manager/service-account.yaml -n $(KIND_NAMESPACE)

IS_HOSTED ?= false
E2E_PROCS=20

.PHONY: e2e-test
e2e-test: e2e-dependencies
$(GINKGO) -v --procs=20 $(E2E_TEST_ARGS) test/e2e -- -is_hosted=$(IS_HOSTED)
$(GINKGO) -v --procs=$(E2E_PROCS) $(E2E_TEST_ARGS) test/e2e -- -is_hosted=$(IS_HOSTED)

.PHONY: e2e-test-coverage
e2e-test-coverage: E2E_TEST_ARGS = --json-report=report_e2e.json --label-filter='!hosted-mode && !running-in-cluster' --output-dir=.
e2e-test-coverage: e2e-run-instrumented e2e-test e2e-stop-instrumented

.PHONY: e2e-test-hosted-mode-coverage
e2e-test-hosted-mode-coverage: E2E_TEST_ARGS = --json-report=report_e2e_hosted_mode.json --label-filter="hosted-mode && hosted-as-well && !running-in-cluster" --output-dir=.
e2e-test-hosted-mode-coverage: E2E_TEST_ARGS = --json-report=report_e2e_hosted_mode.json --label-filter="hosted-mode || hosted-as-well && !running-in-cluster" --output-dir=.
e2e-test-hosted-mode-coverage: COVERAGE_E2E_OUT = coverage_e2e_hosted_mode.out
e2e-test-hosted-mode-coverage: IS_HOSTED=true
e2e-test-hosted-mode-coverage: E2E_PROCS=1
e2e-test-hosted-mode-coverage: export TARGET_KUBECONFIG_PATH = $(PWD)/kubeconfig_managed2
e2e-test-hosted-mode-coverage: e2e-run-instrumented e2e-test e2e-stop-instrumented
.PHONY: e2e-test-running-in-cluster
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/case21_alternative_kubeconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,25 @@ package e2e
import (
"context"
"fmt"
"os"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

"open-cluster-management.io/config-policy-controller/test/utils"
)

var _ = Describe("Test an alternative kubeconfig for policy evaluation", Ordered, Label("hosted-mode"), func() {
const (
envName = "TARGET_KUBECONFIG_PATH"
namespaceName = "e2e-test-ns"
policyName = "create-ns"
policyYAML = "../resources/case21_alternative_kubeconfig/policy.yaml"
parentPolicyName = "parent-create-ns"
parentPolicyYAML = "../resources/case21_alternative_kubeconfig/parent-policy.yaml"
)

var targetK8sClient *kubernetes.Clientset

BeforeAll(func() {
By("Checking that the " + envName + " environment variable is valid")
altKubeconfigPath := os.Getenv(envName)
Expect(altKubeconfigPath).ToNot(Equal(""))

targetK8sConfig, err := clientcmd.BuildConfigFromFlags("", altKubeconfigPath)
Expect(err).ToNot(HaveOccurred())

targetK8sClient, err = kubernetes.NewForConfig(targetK8sConfig)
Expect(err).ToNot(HaveOccurred())
})

AfterAll(func() {
deleteConfigPolicies([]string{policyName})

Expand Down
Loading

0 comments on commit 212a6ef

Please sign in to comment.