Skip to content

Commit 2e89d43

Browse files
Some test fixes
Signed-off-by: Joshua Pritchard <[email protected]>
1 parent b2e14d5 commit 2e89d43

File tree

7 files changed

+142
-28
lines changed

7 files changed

+142
-28
lines changed

install/helm/agentgateway/templates/deployment.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ spec:
111111
- name: KGW_XDS_TLS_ENABLED
112112
value: "true"
113113
{{- end }}
114+
- name: KGW_GATEWAY_CLASS_PARAMETERS_REFS
115+
value: {{ .Values.gatewayClassParametersRefs | toJson | quote }}
114116
# TODO: Remove this once the cleanup is done. Required as the agentgateway-system
115117
# namespace is the default namespace and conformance will fail as a result.
116118
- name: POD_NAMESPACE
@@ -143,4 +145,13 @@ spec:
143145
tolerations:
144146
{{- toYaml . | nindent 8 }}
145147
{{- end }}
146-
148+
{{- if .Values.gatewayClassParametersRefs }}
149+
{{- range $className, $ref := .Values.gatewayClassParametersRefs }}
150+
{{- if not $ref.name }}
151+
{{ fail (printf "gatewayClassParametersRefs.%s.name must be set" $className) }}
152+
{{- end }}
153+
{{- if not $ref.namespace }}
154+
{{ fail (printf "gatewayClassParametersRefs.%s.namespace must be set" $className) }}
155+
{{- end }}
156+
{{- end }}
157+
{{- end }}

install/helm/agentgateway/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,15 @@ inferenceExtension:
100100

101101
# -- List of namespace selectors (OR'ed): each entry can use 'matchLabels' or 'matchExpressions' (AND'ed within each entry if used together). Agentgateway includes the selected namespaces in config discovery. For more information, see the docs https://kgateway.dev/docs/latest/install/advanced/#namespace-discovery.
102102
discoveryNamespaceSelectors: []
103+
104+
# -- Map of GatewayClass names to GatewayParameters references that will be set on
105+
# the default GatewayClasses managed by kgateway. Each entry must define both the
106+
# name and namespace of the GatewayParameters resource.
107+
# The default GatewayClasses managed by kgateway are:
108+
# - agentgateway
109+
# Example:
110+
# gatewayClassParametersRefs:
111+
# agentgateway:
112+
# name: shared-gwp
113+
# namespace: kgateway-system
114+
gatewayClassParametersRefs: {}

pkg/utils/helmutils/constants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package helmutils
33
const (
44
ChartName = "kgateway"
55
CRDChartName = "kgateway-crds"
6-
AgentGatewayChartName = "agentgateway"
7-
AgentGatewayCRDChartName = "agentgateway-crds"
6+
AgentgatewayChartName = "agentgateway"
7+
AgentgatewayCRDChartName = "agentgateway-crds"
88

99
DefaultChartUri = "oci://ghcr.io/kgateway-dev/charts/kgateway"
1010
DefaultCRDChartUri = "oci://ghcr.io/kgateway-dev/charts/kgateway-crds"
11-
DefaultAgentGatewayChartUri = "oci://ghcr.io/kgateway-dev/charts/agentgateway"
12-
DefaultAgentGatewayCRDChartUri = "oci://ghcr.io/kgateway-dev/charts/agentgateway-crds"
11+
DefaultagentGatewayChartUri = "oci://ghcr.io/kgateway-dev/charts/agentgateway"
12+
DefaultagentGatewayCRDChartUri = "oci://ghcr.io/kgateway-dev/charts/agentgateway-crds"
1313
)

test/e2e/features/parallelcontrollers/suite.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,28 +603,28 @@ func (s *testingSuite) installAgentgatewayChart() {
603603
}
604604

605605
// Install agentgateway CRDs
606-
crdChartURI, err := helper.GetLocalChartPath(helmutils.AgentGatewayCRDChartName, "")
606+
crdChartURI, err := helper.GetLocalChartPath(helmutils.AgentgatewayCRDChartName, "")
607607
s.Require().NoError(err)
608608
err = s.TestInstallation.Actions.Helm().WithReceiver(os.Stdout).Upgrade(
609609
s.Ctx,
610610
helmutils.InstallOpts{
611611
CreateNamespace: true,
612-
ReleaseName: helmutils.AgentGatewayCRDChartName,
612+
ReleaseName: helmutils.AgentgatewayCRDChartName,
613613
Namespace: s.TestInstallation.Metadata.InstallNamespace,
614614
ChartUri: crdChartURI,
615615
})
616616
s.Require().NoError(err, "agentgateway CRD chart install should succeed")
617617

618618
// Install agentgateway core chart
619-
chartUri, err := helper.GetLocalChartPath(helmutils.AgentGatewayChartName, "")
619+
chartUri, err := helper.GetLocalChartPath(helmutils.AgentgatewayChartName, "")
620620
s.Require().NoError(err)
621621
err = s.TestInstallation.Actions.Helm().WithReceiver(os.Stdout).Upgrade(
622622
s.Ctx,
623623
helmutils.InstallOpts{
624624
Namespace: s.TestInstallation.Metadata.InstallNamespace,
625625
CreateNamespace: true,
626626
ValuesFiles: []string{s.TestInstallation.Metadata.ProfileValuesManifestFile, s.TestInstallation.Metadata.ValuesManifestFile},
627-
ReleaseName: helmutils.AgentGatewayChartName,
627+
ReleaseName: helmutils.AgentgatewayChartName,
628628
ChartUri: chartUri,
629629
ExtraArgs: s.TestInstallation.Metadata.ExtraHelmArgs,
630630
})
@@ -700,7 +700,7 @@ func (s *testingSuite) uninstallAgentgatewayChart() {
700700
err := s.TestInstallation.Actions.Helm().WithReceiver(os.Stdout).Uninstall(
701701
s.Ctx,
702702
helmutils.UninstallOpts{
703-
ReleaseName: helmutils.AgentGatewayChartName,
703+
ReleaseName: helmutils.AgentgatewayChartName,
704704
Namespace: s.TestInstallation.Metadata.InstallNamespace,
705705
},
706706
)
@@ -712,7 +712,7 @@ func (s *testingSuite) uninstallAgentgatewayChart() {
712712
err = s.TestInstallation.Actions.Helm().WithReceiver(os.Stdout).Uninstall(
713713
s.Ctx,
714714
helmutils.UninstallOpts{
715-
ReleaseName: helmutils.AgentGatewayCRDChartName,
715+
ReleaseName: helmutils.AgentgatewayCRDChartName,
716716
Namespace: s.TestInstallation.Metadata.InstallNamespace,
717717
},
718718
)

test/e2e/test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,19 @@ func (i *TestInstallation) InstallAgentgatewayCRDsFromLocalChart(ctx context.Con
226226

227227
// Check if we should skip installation if the release already exists (PERSIST_INSTALL or FAIL_FAST_AND_PERSIST mode)
228228
if testutils.ShouldPersistInstall() || testutils.ShouldFailFastAndPersist() {
229-
if i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentGatewayCRDChartName, i.Metadata.InstallNamespace) {
229+
if i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentgatewayCRDChartName, i.Metadata.InstallNamespace) {
230230
return
231231
}
232232
}
233233

234234
// install the CRD chart first
235-
crdChartURI, err := helper.GetLocalChartPath(helmutils.AgentGatewayCRDChartName, "")
235+
crdChartURI, err := helper.GetLocalChartPath(helmutils.AgentgatewayCRDChartName, "")
236236
i.Assertions.Require.NoError(err)
237237
err = i.Actions.Helm().WithReceiver(os.Stdout).Upgrade(
238238
ctx,
239239
helmutils.InstallOpts{
240240
CreateNamespace: true,
241-
ReleaseName: helmutils.AgentGatewayCRDChartName,
241+
ReleaseName: helmutils.AgentgatewayCRDChartName,
242242
Namespace: i.Metadata.InstallNamespace,
243243
ChartUri: crdChartURI,
244244
})
@@ -253,21 +253,21 @@ func (i *TestInstallation) InstallAgentgatewayCoreFromLocalChart(ctx context.Con
253253

254254
// Check if we should skip installation if the release already exists (PERSIST_INSTALL or FAIL_FAST_AND_PERSIST mode)
255255
if testutils.ShouldPersistInstall() || testutils.ShouldFailFastAndPersist() {
256-
if i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentGatewayChartName, i.Metadata.InstallNamespace) {
256+
if i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentgatewayChartName, i.Metadata.InstallNamespace) {
257257
return
258258
}
259259
}
260260

261261
// and then install the main chart
262-
chartUri, err := helper.GetLocalChartPath(helmutils.AgentGatewayChartName, "")
262+
chartUri, err := helper.GetLocalChartPath(helmutils.AgentgatewayChartName, "")
263263
i.Assertions.Require.NoError(err)
264264
err = i.Actions.Helm().WithReceiver(os.Stdout).Upgrade(
265265
ctx,
266266
helmutils.InstallOpts{
267267
Namespace: i.Metadata.InstallNamespace,
268268
CreateNamespace: true,
269269
ValuesFiles: []string{i.Metadata.ProfileValuesManifestFile, i.Metadata.ValuesManifestFile},
270-
ReleaseName: helmutils.AgentGatewayChartName,
270+
ReleaseName: helmutils.AgentgatewayChartName,
271271
ChartUri: chartUri,
272272
ExtraArgs: i.Metadata.ExtraHelmArgs,
273273
})
@@ -314,7 +314,7 @@ func (i *TestInstallation) UninstallKgatewayCore(ctx context.Context) {
314314
},
315315
)
316316
i.Assertions.Require.NoError(err, "failed to uninstall main chart")
317-
i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx)
317+
i.Assertions.EventuallyGatewayUninstallSucceeded(ctx)
318318
}
319319

320320
func (i *TestInstallation) UninstallKgatewayCRDs(ctx context.Context) {
@@ -347,7 +347,7 @@ func (i *TestInstallation) UninstallAgentgatewayCore(ctx context.Context) {
347347
}
348348

349349
// Check if the release exists before attempting to uninstall
350-
if !i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentGatewayChartName, i.Metadata.InstallNamespace) {
350+
if !i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentgatewayChartName, i.Metadata.InstallNamespace) {
351351
// Release doesn't exist, nothing to uninstall
352352
return
353353
}
@@ -357,12 +357,12 @@ func (i *TestInstallation) UninstallAgentgatewayCore(ctx context.Context) {
357357
ctx,
358358
helmutils.UninstallOpts{
359359
Namespace: i.Metadata.InstallNamespace,
360-
ReleaseName: helmutils.AgentGatewayChartName,
360+
ReleaseName: helmutils.AgentgatewayChartName,
361361
ExtraArgs: []string{"--wait"}, // Default timeout is 5m
362362
},
363363
)
364364
i.Assertions.Require.NoError(err, "failed to uninstall main chart")
365-
i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx)
365+
i.Assertions.EventuallyGatewayUninstallSucceeded(ctx)
366366
}
367367

368368
// UninstallAgentgatewayCRDs uninstalls the agentgateway CRD chart
@@ -372,7 +372,7 @@ func (i *TestInstallation) UninstallAgentgatewayCRDs(ctx context.Context) {
372372
}
373373

374374
// Check if the release exists before attempting to uninstall
375-
if !i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentGatewayCRDChartName, i.Metadata.InstallNamespace) {
375+
if !i.Actions.Helm().ReleaseExists(ctx, helmutils.AgentgatewayCRDChartName, i.Metadata.InstallNamespace) {
376376
// Release doesn't exist, nothing to uninstall
377377
return
378378
}
@@ -382,7 +382,7 @@ func (i *TestInstallation) UninstallAgentgatewayCRDs(ctx context.Context) {
382382
ctx,
383383
helmutils.UninstallOpts{
384384
Namespace: i.Metadata.InstallNamespace,
385-
ReleaseName: helmutils.AgentGatewayCRDChartName,
385+
ReleaseName: helmutils.AgentgatewayCRDChartName,
386386
ExtraArgs: []string{"--wait"}, // Default timeout is 5m
387387
},
388388
)

test/e2e/tests/custom_gwp_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func TestCustomGWP(t *testing.T) {
145145

146146
// install kgateway
147147
testInstallation.InstallKgatewayFromLocalChart(ctx)
148+
testInstallation.InstallAgentgatewayCoreFromLocalChart(ctx)
148149

149150
// Wait for GatewayClasses to be created
150151
testInstallation.Assertions.EventuallyObjectsExist(ctx, &gwv1.GatewayClass{
@@ -238,7 +239,24 @@ func TestCustomGWP(t *testing.T) {
238239
if err != nil {
239240
t.Fatalf("failed to upgrade Helm: %v", err)
240241
}
241-
testInstallation.Assertions.EventuallyGatewayInstallSucceeded(ctx)
242+
testInstallation.Assertions.EventuallyKgatewayInstallSucceeded(ctx)
243+
chartUriAgentgateway, err := helper.GetLocalChartPath(helmutils.AgentgatewayChartName, "")
244+
if err != nil {
245+
t.Fatalf("failed to get chart path: %v", err)
246+
}
247+
err = testInstallation.Actions.Helm().WithReceiver(os.Stdout).Upgrade(
248+
ctx,
249+
helmutils.InstallOpts{
250+
Namespace: installNs,
251+
CreateNamespace: true,
252+
ValuesFiles: []string{e2e.CommonRecommendationManifest, e2e.ManifestPath("custom-gwp-2.yaml")},
253+
ReleaseName: helmutils.AgentgatewayChartName,
254+
ChartUri: chartUriAgentgateway,
255+
})
256+
if err != nil {
257+
t.Fatalf("failed to upgrade Helm: %v", err)
258+
}
259+
testInstallation.Assertions.EventuallyAgentgatewayInstallSucceeded(ctx)
242260

243261
// Verify kgateway GatewayClass is updated with new ref
244262
r := require.New(t)

test/e2e/testutils/assertions/kgateway.go

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
)
1010

11+
const (
12+
// KgatewayLabelSelector is the label selector for kgateway pods
13+
KgatewayLabelSelector = "app.kubernetes.io/name=kgateway"
14+
// AgentgatewayLabelSelector is the label selector for agentgateway pods
15+
AgentgatewayLabelSelector = "app.kubernetes.io/name=agentgateway"
16+
)
17+
1118
// getChartLabelSelector returns the appropriate label selector based on the chart type
1219
func (p *Provider) getChartLabelSelector() string {
1320
chartType := p.installContext.GetChartType()
1421
if chartType == "agentgateway" {
15-
return "app.kubernetes.io/name=agentgateway"
22+
return AgentgatewayLabelSelector
1623
}
17-
return "app.kubernetes.io/name=kgateway"
24+
return KgatewayLabelSelector
1825
}
1926

2027
func (p *Provider) EventuallyGatewayInstallSucceeded(ctx context.Context) {
@@ -26,7 +33,7 @@ func (p *Provider) EventuallyGatewayInstallSucceeded(ctx context.Context) {
2633
})
2734
}
2835

29-
func (p *Provider) EventuallyKgatewayUninstallSucceeded(ctx context.Context) {
36+
func (p *Provider) EventuallyGatewayUninstallSucceeded(ctx context.Context) {
3037
p.expectInstallContextDefined()
3138

3239
p.EventuallyPodsNotExist(ctx, p.installContext.InstallNamespace,
@@ -35,11 +42,77 @@ func (p *Provider) EventuallyKgatewayUninstallSucceeded(ctx context.Context) {
3542
})
3643
}
3744

38-
func (p *Provider) EventuallyKgatewayUpgradeSucceeded(ctx context.Context, version string) {
45+
func (p *Provider) EventuallyGatewayUpgradeSucceeded(ctx context.Context, version string) {
3946
p.expectInstallContextDefined()
4047

4148
p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace,
4249
metav1.ListOptions{
4350
LabelSelector: p.getChartLabelSelector(),
4451
})
4552
}
53+
54+
// EventuallyKgatewayInstallSucceeded verifies that the kgateway chart installation has succeeded.
55+
// This is useful when testing with both kgateway and agentgateway charts installed.
56+
func (p *Provider) EventuallyKgatewayInstallSucceeded(ctx context.Context) {
57+
p.expectInstallContextDefined()
58+
59+
p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace,
60+
metav1.ListOptions{
61+
LabelSelector: KgatewayLabelSelector,
62+
})
63+
}
64+
65+
// EventuallyKgatewayUninstallSucceeded verifies that the kgateway chart has been uninstalled.
66+
// This is useful when testing with both kgateway and agentgateway charts.
67+
func (p *Provider) EventuallyKgatewayUninstallSucceeded(ctx context.Context) {
68+
p.expectInstallContextDefined()
69+
70+
p.EventuallyPodsNotExist(ctx, p.installContext.InstallNamespace,
71+
metav1.ListOptions{
72+
LabelSelector: KgatewayLabelSelector,
73+
})
74+
}
75+
76+
// EventuallyKgatewayUpgradeSucceeded verifies that the kgateway chart upgrade has succeeded.
77+
// This is useful when testing with both kgateway and agentgateway charts installed.
78+
func (p *Provider) EventuallyKgatewayUpgradeSucceeded(ctx context.Context, version string) {
79+
p.expectInstallContextDefined()
80+
81+
p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace,
82+
metav1.ListOptions{
83+
LabelSelector: KgatewayLabelSelector,
84+
})
85+
}
86+
87+
// EventuallyAgentgatewayInstallSucceeded verifies that the agentgateway chart installation has succeeded.
88+
// This is useful when testing with both kgateway and agentgateway charts installed.
89+
func (p *Provider) EventuallyAgentgatewayInstallSucceeded(ctx context.Context) {
90+
p.expectInstallContextDefined()
91+
92+
p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace,
93+
metav1.ListOptions{
94+
LabelSelector: AgentgatewayLabelSelector,
95+
})
96+
}
97+
98+
// EventuallyAgentgatewayUninstallSucceeded verifies that the agentgateway chart has been uninstalled.
99+
// This is useful when testing with both kgateway and agentgateway charts.
100+
func (p *Provider) EventuallyAgentgatewayUninstallSucceeded(ctx context.Context) {
101+
p.expectInstallContextDefined()
102+
103+
p.EventuallyPodsNotExist(ctx, p.installContext.InstallNamespace,
104+
metav1.ListOptions{
105+
LabelSelector: AgentgatewayLabelSelector,
106+
})
107+
}
108+
109+
// EventuallyAgentgatewayUpgradeSucceeded verifies that the agentgateway chart upgrade has succeeded.
110+
// This is useful when testing with both kgateway and agentgateway charts installed.
111+
func (p *Provider) EventuallyAgentgatewayUpgradeSucceeded(ctx context.Context, version string) {
112+
p.expectInstallContextDefined()
113+
114+
p.EventuallyPodsRunning(ctx, p.installContext.InstallNamespace,
115+
metav1.ListOptions{
116+
LabelSelector: AgentgatewayLabelSelector,
117+
})
118+
}

0 commit comments

Comments
 (0)