Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI|K8s] Fix k8s tests on Jenkins #18766

Merged
merged 11 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@ def k8sTest(versions){
withBeatsEnv(false) {
sh(label: "Install kind", script: ".ci/scripts/install-kind.sh")
sh(label: "Install kubectl", script: ".ci/scripts/install-kubectl.sh")
sh(label: "Integration tests", script: "MODULE=kubernetes make -C metricbeat integration-tests")
sh(label: "Setup kind", script: ".ci/scripts/kind-setup.sh")
sh(label: "Integration tests", script: "MODULE=kubernetes make -C metricbeat integration-tests")
sh(label: "Deploy to kubernetes",script: "make -C deploy/kubernetes test")
sh(label: 'Delete cluster', script: 'kind delete cluster')
}
Expand Down
25 changes: 23 additions & 2 deletions dev-tools/mage/kubernetes/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,30 @@ func (m *KindIntegrationTestStep) Setup(env map[string]string) error {
_, exists := env["KUBECONFIG"]
if exists {
// do nothing
return nil
if mg.Verbose() {
fmt.Println("KUBECONFIG: ", env["KUBECONFIG"])
}
if _, err := os.Stat(env["KUBECONFIG"]); err == nil {
return nil
} else if os.IsNotExist(err) {
if mg.Verbose() {
fmt.Println("KUBECONFIG file not found: ", env["KUBECONFIG"], err)
}
}
}
_, exists = env["KUBE_CONFIG"]
if exists {
// do nothing
return nil
if mg.Verbose() {
fmt.Println("KUBE_CONFIG: ", env["KUBE_CONFIG"])
}
if _, err := os.Stat(env["KUBE_CONFIG"]); err == nil {
return nil
} else if os.IsNotExist(err) {
if mg.Verbose() {
fmt.Println("KUBE_CONFIG file not found: ", env["KUBE_CONFIG"], err)
}
}
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
}
_, err := exec.LookPath("kind")
if err != nil {
Expand All @@ -80,6 +98,9 @@ func (m *KindIntegrationTestStep) Setup(env map[string]string) error {
return err
}
kubeConfig := filepath.Join(kubeCfgDir, "kubecfg")
if mg.Verbose() {
fmt.Println("Kubeconfig: ", kubeConfig)
}
if err := os.MkdirAll(kubeCfgDir, os.ModePerm); err != nil {
return err
}
Expand Down