Skip to content

Commit 7442ffc

Browse files
authored
Merge pull request #10359 from solo-io/remove-hardcoded-namespace-in-tracing-test-v1.17.x
Remove hardcoded namespace in tracing test v1.17.x
2 parents 051b0ca + 664f692 commit 7442ffc

File tree

7 files changed

+112
-58
lines changed

7 files changed

+112
-58
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
description: >-
4+
Fix failing unit tests in `test/kubernetes/testutils/helper/util_test.go`
5+
and `test/kubernetes/testutils/helper/util_test.go`
6+
- type: NON_USER_FACING
7+
issueLink: https://github.com/solo-io/solo-projects/issues/7223
8+
resolvesIssue: false
9+
description: >-
10+
Remove hard-coded namespaces from the tracing tests. This issue is
11+
causing tests to pass in OSS gloo, but fail in solo-projects.

test/kube2e/upgrade/upgrade_utils_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ var _ = Describe("upgrade utils unit tests", func() {
2626
It("should return latest patch", func() {
2727
ctx := context.Background()
2828
client, _ := githubutils.GetClient(ctx)
29-
minor, err := getLatestReleasedPatchVersion(ctx, client, "gloo", 1, 8)
29+
minor, err := getLatestReleasedPatchVersion(ctx, client, "gloo", 1, 9)
3030
Expect(err).NotTo(HaveOccurred())
31-
Expect(minor.String()).To(Equal("v1.8.37"))
31+
Expect(minor.String()).To(Equal("v1.9.30"))
3232
})
3333
})
3434

test/kubernetes/e2e/features/tracing/suite.go

+44-9
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import (
77

88
"github.com/solo-io/gloo/pkg/utils/kubeutils"
99
"github.com/solo-io/gloo/pkg/utils/requestutils/curl"
10+
gloo_defaults "github.com/solo-io/gloo/projects/gloo/pkg/defaults"
1011
"github.com/solo-io/gloo/test/gomega/matchers"
1112
"github.com/solo-io/gloo/test/kubernetes/e2e"
1213
testdefaults "github.com/solo-io/gloo/test/kubernetes/e2e/defaults"
14+
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
15+
"github.com/solo-io/solo-kit/pkg/api/v1/resources"
16+
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
1317
"github.com/stretchr/testify/assert"
1418
"github.com/stretchr/testify/suite"
1519
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -94,15 +98,38 @@ func (s *testingSuite) BeforeTest(string, string) {
9498
otelcolSelector,
9599
)
96100

97-
// Attempt to apply tracingConfigManifest multiple times. The first time
98-
// fails regularly with this message: "failed to validate Proxy [namespace:
99-
// gloo-gateway-edge-test, name: gateway-proxy] with gloo validation:
100-
// HttpListener Error: ProcessingError. Reason: *v1.Upstream {
101-
// default.opentelemetry-collector } not found"
102-
s.Assert().Eventually(func() bool {
103-
err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, tracingConfigManifest)
104-
return err == nil
105-
}, time.Second*30, time.Second*5, "can apply gloo tracing config")
101+
err = s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, tracingConfigManifest)
102+
s.NoError(err, "can apply gloo tracing resources")
103+
// accept the upstream
104+
s.testInstallation.Assertions.EventuallyResourceStatusMatchesState(
105+
func() (resources.InputResource, error) {
106+
return s.testInstallation.ResourceClients.UpstreamClient().Read(
107+
otelcolUpstream.Namespace, otelcolUpstream.Name, clients.ReadOpts{Ctx: s.ctx})
108+
},
109+
core.Status_Accepted,
110+
gloo_defaults.GlooReporter,
111+
)
112+
// accept the virtual service
113+
s.testInstallation.Assertions.EventuallyResourceStatusMatchesState(
114+
func() (resources.InputResource, error) {
115+
return s.testInstallation.ResourceClients.VirtualServiceClient().Read(
116+
tracingVs.Namespace, tracingVs.Name, clients.ReadOpts{Ctx: s.ctx})
117+
},
118+
core.Status_Accepted,
119+
gloo_defaults.GlooReporter,
120+
)
121+
122+
err = s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, gatewayConfigManifest,
123+
"-n", s.testInstallation.Metadata.InstallNamespace)
124+
s.NoError(err, "can create gateway and service")
125+
s.testInstallation.Assertions.EventuallyResourceStatusMatchesState(
126+
func() (resources.InputResource, error) {
127+
return s.testInstallation.ResourceClients.GatewayClient().Read(
128+
s.testInstallation.Metadata.InstallNamespace, "gateway-proxy-tracing", clients.ReadOpts{Ctx: s.ctx})
129+
},
130+
core.Status_Accepted,
131+
gloo_defaults.GlooReporter,
132+
)
106133
}
107134

108135
func (s *testingSuite) AfterTest(string, string) {
@@ -112,6 +139,10 @@ func (s *testingSuite) AfterTest(string, string) {
112139

113140
err = s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, tracingConfigManifest)
114141
s.Assertions.NoError(err, "can delete gloo tracing config")
142+
143+
err = s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, gatewayConfigManifest,
144+
"-n", s.testInstallation.Metadata.InstallNamespace)
145+
s.Assertions.NoError(err, "can delete gloo tracing config")
115146
}
116147

117148
func (s *testingSuite) TestSpanNameTransformationsWithoutRouteDecorator() {
@@ -125,10 +156,12 @@ func (s *testingSuite) TestSpanNameTransformationsWithoutRouteDecorator() {
125156
curl.WithHostHeader(testHostname),
126157
curl.WithPort(gatewayProxyPort),
127158
curl.WithPath(pathWithoutRouteDescriptor),
159+
curl.Silent(),
128160
},
129161
&matchers.HttpResponse{
130162
StatusCode: http.StatusOK,
131163
},
164+
5*time.Second, 30*time.Second,
132165
)
133166

134167
s.EventuallyWithT(func(c *assert.CollectT) {
@@ -150,10 +183,12 @@ func (s *testingSuite) TestSpanNameTransformationsWithRouteDecorator() {
150183
curl.WithHostHeader("example.com"),
151184
curl.WithPort(gatewayProxyPort),
152185
curl.WithPath(pathWithRouteDescriptor),
186+
curl.Silent(),
153187
},
154188
&matchers.HttpResponse{
155189
StatusCode: http.StatusOK,
156190
},
191+
5*time.Second, 30*time.Second,
157192
)
158193

159194
s.EventuallyWithT(func(c *assert.CollectT) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Avoid using the default gateway because we don't want to destroy it when this
2+
# test is over - that will break other tests that depend on the default gateway
3+
# existing.
4+
apiVersion: gateway.solo.io/v1
5+
kind: Gateway
6+
metadata:
7+
labels:
8+
app: gloo
9+
app.kubernetes.io/name: gateway-proxy-tracing
10+
name: gateway-proxy-tracing
11+
spec:
12+
bindAddress: '::'
13+
bindPort: 18080
14+
proxyNames:
15+
- gateway-proxy
16+
httpGateway:
17+
virtualServiceSelector:
18+
gateway-type: tracing
19+
options:
20+
httpConnectionManagerSettings:
21+
tracing:
22+
openTelemetryConfig:
23+
collectorUpstreamRef:
24+
name: opentelemetry-collector
25+
namespace: default
26+
---
27+
apiVersion: v1
28+
kind: Service
29+
metadata:
30+
name: gateway-proxy-tracing
31+
labels:
32+
app.kubernetes.io/name: gateway-proxy-tracing-service
33+
spec:
34+
ports:
35+
- name: gateway-proxy-tracing
36+
port: 18080
37+
protocol: TCP
38+
targetPort: 18080
39+
selector:
40+
gateway-proxy: live
41+
gateway-proxy-id: gateway-proxy
42+

test/kubernetes/e2e/features/tracing/testdata/tracing.yaml

+2-45
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ spec:
3131
apiVersion: gateway.solo.io/v1
3232
kind: VirtualService
3333
metadata:
34-
name: default
34+
name: virtual-service
35+
namespace: default
3536
labels:
3637
gateway-type: tracing
3738
spec:
@@ -71,47 +72,3 @@ spec:
7172
autoHostRewrite: true
7273
tracing:
7374
routeDescriptor: THISISAROUTEDESCRIPTOR
74-
---
75-
# Avoid using the default gateway because we don't want to destroy it when this
76-
# test is over - that will break other tests that depend on the default gateway
77-
# existing.
78-
apiVersion: gateway.solo.io/v1
79-
kind: Gateway
80-
metadata:
81-
labels:
82-
app: gloo
83-
app.kubernetes.io/name: gateway-proxy-tracing
84-
name: gateway-proxy-tracing
85-
namespace: gloo-gateway-edge-test
86-
spec:
87-
bindAddress: '::'
88-
bindPort: 18080
89-
proxyNames:
90-
- gateway-proxy
91-
httpGateway:
92-
virtualServiceSelector:
93-
gateway-type: tracing
94-
options:
95-
httpConnectionManagerSettings:
96-
tracing:
97-
openTelemetryConfig:
98-
collectorUpstreamRef:
99-
name: opentelemetry-collector
100-
namespace: default
101-
---
102-
apiVersion: v1
103-
kind: Service
104-
metadata:
105-
name: gateway-proxy-tracing
106-
namespace: gloo-gateway-edge-test
107-
labels:
108-
app.kubernetes.io/name: gateway-proxy-tracing-service
109-
spec:
110-
ports:
111-
- name: gateway-proxy-tracing
112-
port: 18080
113-
protocol: TCP
114-
targetPort: 18080
115-
selector:
116-
gateway-proxy: live
117-
gateway-proxy-id: gateway-proxy

test/kubernetes/e2e/features/tracing/types.go

+9
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ const (
1919
var (
2020
setupOtelcolManifest = filepath.Join(util.MustGetThisDir(), "testdata", "setup-otelcol.yaml")
2121
tracingConfigManifest = filepath.Join(util.MustGetThisDir(), "testdata", "tracing.yaml")
22+
gatewayConfigManifest = filepath.Join(util.MustGetThisDir(), "testdata", "gateway.yaml")
2223

2324
otelcolPod = &corev1.Pod{
2425
ObjectMeta: metav1.ObjectMeta{Name: "otel-collector", Namespace: "default"},
2526
}
2627
otelcolSelector = metav1.ListOptions{
2728
LabelSelector: "app.kubernetes.io/name=otel-collector",
2829
}
30+
otelcolUpstream = &metav1.ObjectMeta{
31+
Name: "opentelemetry-collector",
32+
Namespace: "default",
33+
}
34+
tracingVs = &metav1.ObjectMeta{
35+
Name: "virtual-service",
36+
Namespace: "default",
37+
}
2938
)

test/kubernetes/testutils/helper/util_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func TestReturnsLatestPatchForMinor(t *testing.T) {
2323
ctx := context.Background()
2424
// this is fine because this is a public repo
2525
client := githubutils.GetClientWithOrWithoutToken(ctx)
26-
minor, err := getLatestReleasedPatchVersion(ctx, client, "gloo", 1, 8)
26+
minor, err := getLatestReleasedPatchVersion(ctx, client, "gloo", 1, 9)
2727
require.NoError(t, err)
2828

29-
assert.Equal(t, "v1.8.37", minor.String())
29+
assert.Equal(t, "v1.9.30", minor.String())
3030
}

0 commit comments

Comments
 (0)