Skip to content

Commit 45a3b14

Browse files
committed
it test changes from michaelschiff:rules_gitops:symlink-config-stable
1 parent fd76291 commit 45a3b14

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

examples/WORKSPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ load("@com_adobe_rules_gitops//gitops:repositories.bzl", "rules_gitops_repositor
2323

2424
rules_gitops_repositories()
2525

26+
load("@com_adobe_rules_gitops//skylib:k8s.bzl", "kubeconfig")
27+
28+
kubeconfig(
29+
name = "k8s_test",
30+
cluster = "kind-kind",
31+
symlink = True,
32+
)
33+
2634
#
2735
# Repository dependencies
2836
#

examples/helloworld/BUILD

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ licenses(["notice"]) # Apache 2.0
1212

1313
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
1414
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
15-
load("@com_adobe_rules_gitops//gitops:defs.bzl", "k8s_deploy")
15+
load("@com_adobe_rules_gitops//gitops:defs.bzl", "k8s_deploy", "k8s_test_setup")
1616

1717
go_library(
1818
name = "go_default_library",
@@ -138,3 +138,27 @@ sh_test(
138138
"@bazel_tools//tools/bash/runfiles",
139139
],
140140
)
141+
142+
k8s_test_setup(
143+
name = "service_it.setup",
144+
kubeconfig = "@k8s_test//:kubeconfig",
145+
objects = [
146+
":mynamespace",
147+
],
148+
)
149+
150+
go_test(
151+
name = "helloworld_integration_test",
152+
srcs = ["helloworld_integration_test.go"],
153+
args = [
154+
"-setup",
155+
"$(location :service_it.setup)",
156+
],
157+
data = [
158+
":service_it.setup",
159+
],
160+
rundir = ".",
161+
deps = [
162+
"@com_adobe_rules_gitops//testing/it_sidecar/client:go_default_library",
163+
],
164+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"io/ioutil"
7+
"strings"
8+
"testing"
9+
10+
"github.com/adobe/rules_gitops/testing/it_sidecar/client"
11+
)
12+
13+
var setup client.K8STestSetup
14+
15+
func TestMain(m *testing.M) {
16+
setup = client.K8STestSetup{PortForwardServices: map[string]int{"helloworld": 8080}}
17+
setup.TestMain(m)
18+
}
19+
20+
func TestSuccessfulReceival(t *testing.T) {
21+
localPort := setup.GetServiceLocalPort("helloworld")
22+
fmt.Printf("helloworld server is available at localport %d\n", localPort)
23+
resp, err := http.Get(fmt.Sprintf("http://localhost:%d", localPort))
24+
if err != nil {
25+
t.Fatalf("request error %s", err)
26+
}
27+
if resp.StatusCode != 200 {
28+
t.Fatalf("Unexpected status code %d, expectted 200", resp.StatusCode)
29+
}
30+
body, _ := ioutil.ReadAll(resp.Body)
31+
if !strings.Contains(string(body), "Hello World") {
32+
t.Error("Unexpected content returned:", string(body))
33+
}
34+
}

0 commit comments

Comments
 (0)