Skip to content

Commit d9c2053

Browse files
committed
Fix --kubeconfig flag for Kind
1 parent 5bc2af4 commit d9c2053

File tree

6 files changed

+36
-64
lines changed

6 files changed

+36
-64
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ jobs:
6868
REGISTRY_SECRET: regcred
6969
run: |
7070
export KUBECONFIG="$(kind get kubeconfig-path)"
71+
env > ${GITHUB_WORKSPACE}/hack/config/.env
7172
make install
73+
echo
7274
make e2e-tests

Makefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,28 @@ unit-tests: $(BUILD_DIRS)
255255
./hack/test.sh $(SRC_PKGS) \
256256
"
257257

258-
STORAGE_CLASS ?= standard
258+
# - e2e-tests can hold both ginkgo args (as GINKGO_ARGS) and program/test args (as TEST_ARGS).
259+
# make e2e-tests TEST_ARGS="--selfhosted-operator=false --storageclass=standard" GINKGO_ARGS="--flakeAttempts=2"
260+
#
261+
# - Minimalist:
262+
# make e2e-tests
263+
#
264+
# NB: -t is used to catch ctrl-c interrupt from keyboard and -t will be problematic for CI.
265+
266+
GINKGO_ARGS ?=
267+
TEST_ARGS ?=
259268

260269
.PHONY: e2e-tests
261270
e2e-tests: $(BUILD_DIRS)
262-
@docker run \
271+
docker run \
263272
-i \
264273
--rm \
265274
-u $$(id -u):$$(id -g) \
266275
-v $$(pwd):/src \
267276
-w /src \
268277
--net=host \
269-
-v $(HOME)/.kube:/.kube \
278+
-v $(HOME)/.kube:/.kube \
279+
-v $(HOME)/.credentials:$(HOME)/.credentials \
270280
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
271281
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
272282
-v $$(pwd)/.go/cache:/.cache \
@@ -280,10 +290,16 @@ e2e-tests: $(BUILD_DIRS)
280290
VERSION=$(VERSION) \
281291
DOCKER_REGISTRY=$(REGISTRY) \
282292
TAG=$(TAG) \
283-
STORAGE_CLASS=$(STORAGE_CLASS) \
293+
KUBECONFIG=$${KUBECONFIG#$(HOME)} \
294+
GINKGO_ARGS='$(GINKGO_ARGS)' \
295+
TEST_ARGS='$(TEST_ARGS) --image-tag=$(TAG)' \
284296
./hack/e2e.sh \
285297
"
286298

299+
.PHONY: e2e-parallel
300+
e2e-parallel:
301+
@$(MAKE) e2e-tests GINKGO_ARGS="-p -stream" --no-print-directory
302+
287303
ADDTL_LINTERS := goconst,gofmt,goimports,unparam
288304

289305
.PHONY: lint

hack/e2e.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export CGO_ENABLED=0
2020
export GO111MODULE=on
2121
export GOFLAGS="-mod=vendor"
2222

23+
GINKGO_ARGS=${GINKGO_ARGS:-}
24+
TEST_ARGS=${TEST_ARGS:-}
25+
DOCKER_REGISTRY=${DOCKER_REGISTRY:-}
26+
2327
echo "Running e2e tests:"
24-
ginkgo -r --v --progress --trace test -- \
25-
--docker-registry=${DOCKER_REGISTRY} \
26-
--image-tag=${TAG} \
27-
--storageclass=${STORAGE_CLASS}
28-
echo
28+
cmd="ginkgo -r --v --progress --trace ${GINKGO_ARGS} test -- --v=5 --docker-registry=${DOCKER_REGISTRY} ${TEST_ARGS}"
29+
echo $cmd; $cmd

test/e2e/e2e_suite_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package e2e_test
22

33
import (
4-
"path/filepath"
54
"strings"
65
"testing"
76
"time"
@@ -12,7 +11,6 @@ import (
1211
. "github.com/onsi/gomega"
1312
"k8s.io/client-go/discovery"
1413
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
15-
"k8s.io/client-go/util/homedir"
1614
ka "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
1715
"k8s.io/kubernetes/pkg/api/legacyscheme"
1816
discovery_util "kmodules.xyz/client-go/discovery"
@@ -62,20 +60,14 @@ var _ = BeforeSuite(func() {
6260
Expect(err).NotTo(HaveOccurred())
6361

6462
kaClient := ka.NewForConfigOrDie(clientConfig)
65-
framework.StashProjectRoot = filepath.Join(homedir.HomeDir(), "go", "src", "github.com", "appscode", "stash")
6663

6764
root = framework.New(ctrlConfig.KubeClient, ctrlConfig.StashClient, kaClient, clientConfig, options.StorageClass)
6865
err = root.CreateTestNamespace()
6966
Expect(err).NotTo(HaveOccurred())
7067
By("Using test namespace " + root.Namespace())
71-
72-
By("Starting the Stash Operator")
73-
root.InstallStashOperator(options.KubeConfig, options.ExtraOptions)
7468
})
7569

7670
var _ = AfterSuite(func() {
77-
By("Deleting Stash Operator")
78-
root.UninstallStashOperator()
7971
By("Deleting namespace: " + root.Namespace())
8072
err := root.DeleteNamespace(root.Namespace())
8173
Expect(err).NotTo(HaveOccurred())

test/e2e/framework/operator.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

test/e2e/options_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e_test
22

33
import (
44
"flag"
5+
"os"
56
"path/filepath"
67

78
"github.com/appscode/go/flags"
@@ -21,7 +22,13 @@ type E2EOptions struct {
2122
var (
2223
options = &E2EOptions{
2324
ExtraOptions: server.NewExtraOptions(),
24-
KubeConfig: filepath.Join(homedir.HomeDir(), ".kube", "config"),
25+
KubeConfig: func() string {
26+
kubecfg := os.Getenv("KUBECONFIG")
27+
if kubecfg != "" {
28+
return kubecfg
29+
}
30+
return filepath.Join(homedir.HomeDir(), ".kube", "config")
31+
}(),
2532
}
2633
)
2734

0 commit comments

Comments
 (0)