Skip to content

Commit 4df0775

Browse files
committed
NE-2292: Add Gateway API OLM to NO-OLM migration upgrade test
Add upgrade test validating Gateway API migration from OLM-based Istio to CIO-managed Sail Library during 4.21 to 4.22 upgrades. Setup creates Gateway/HTTPRoute with OLM provisioning and tests connectivity. Test validates migration: Gateway remains programmed, Istiod running, Istio CRDs stay OLM-managed, GatewayClass has CIO finalizer, Istio CR deleted, subscription persists. Teardown cleans up all resources.
1 parent 2fa0e14 commit 4df0775

2 files changed

Lines changed: 309 additions & 0 deletions

File tree

test/e2e/upgrade/upgrade.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"github.com/openshift/origin/test/e2e/upgrade/manifestdelete"
4545
mc "github.com/openshift/origin/test/extended/machine_config"
4646
"github.com/openshift/origin/test/extended/prometheus"
47+
"github.com/openshift/origin/test/extended/router"
4748
"github.com/openshift/origin/test/extended/util/disruption"
4849
"github.com/openshift/origin/test/extended/util/operator"
4950
)
@@ -69,6 +70,7 @@ func AllTests() []upgrades.Test {
6970
&prometheus.ImagePullsAreFast{},
7071
&prometheus.MetricsAvailableAfterUpgradeTest{},
7172
&dns.UpgradeTest{},
73+
&router.GatewayAPIMigrationUpgradeTest{},
7274
}
7375
}
7476

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
package router
2+
3+
import (
4+
"context"
5+
"strings"
6+
"time"
7+
8+
g "github.com/onsi/ginkgo/v2"
9+
o "github.com/onsi/gomega"
10+
11+
exutil "github.com/openshift/origin/test/extended/util"
12+
13+
corev1 "k8s.io/api/core/v1"
14+
apierrors "k8s.io/apimachinery/pkg/api/errors"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
17+
"k8s.io/apimachinery/pkg/runtime/schema"
18+
"k8s.io/apimachinery/pkg/util/wait"
19+
"k8s.io/kubernetes/test/e2e/framework"
20+
"k8s.io/kubernetes/test/e2e/upgrades"
21+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
22+
)
23+
24+
// List of Istio CRDs that should remain OLM-managed after migration
25+
var istioCRDNames = []string{
26+
"wasmplugins.extensions.istio.io",
27+
"destinationrules.networking.istio.io",
28+
"envoyfilters.networking.istio.io",
29+
"gateways.networking.istio.io",
30+
"proxyconfigs.networking.istio.io",
31+
"serviceentries.networking.istio.io",
32+
"sidecars.networking.istio.io",
33+
"virtualservices.networking.istio.io",
34+
"workloadentries.networking.istio.io",
35+
"workloadgroups.networking.istio.io",
36+
"authorizationpolicies.security.istio.io",
37+
"peerauthentications.security.istio.io",
38+
"requestauthentications.security.istio.io",
39+
"telemetries.telemetry.istio.io",
40+
}
41+
42+
// GatewayAPIMigrationUpgradeTest verifies that Gateway API resources migrate
43+
// from OLM-based provisioning to CIO-based provisioning during upgrade
44+
type GatewayAPIMigrationUpgradeTest struct {
45+
oc *exutil.CLI
46+
namespace string
47+
gatewayName string
48+
routeName string
49+
hostname string
50+
}
51+
52+
func (t *GatewayAPIMigrationUpgradeTest) Name() string {
53+
return "gateway-api-olm-to-no-olm-migration"
54+
}
55+
56+
func (t *GatewayAPIMigrationUpgradeTest) DisplayName() string {
57+
return "[sig-network-edge][Feature:Router][apigroup:gateway.networking.k8s.io] Verify Gateway API migration from OLM to NO-OLM during upgrade"
58+
}
59+
60+
// Setup creates Gateway and HTTPRoute resources with OLM-based provisioning and tests connectivity
61+
func (t *GatewayAPIMigrationUpgradeTest) Setup(ctx context.Context, f *framework.Framework) {
62+
g.By("Setting up Gateway API OLM to NO-OLM migration test")
63+
64+
t.oc = exutil.NewCLIWithFramework(f)
65+
t.namespace = f.Namespace.Name
66+
t.gatewayName = "upgrade-test-gateway"
67+
t.routeName = "test-httproute"
68+
69+
configClient := t.oc.AdminConfigClient()
70+
71+
g.By("Checking if GatewayAPIWithoutOLM feature gate is enabled")
72+
fgs, err := configClient.ConfigV1().FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
73+
o.Expect(err).NotTo(o.HaveOccurred())
74+
75+
for _, fg := range fgs.Status.FeatureGates {
76+
for _, enabledFG := range fg.Enabled {
77+
if enabledFG.Name == "GatewayAPIWithoutOLM" {
78+
g.Skip("Skipping upgrade test - GatewayAPIWithoutOLM is already enabled, this test requires starting from OLM-based provisioning")
79+
}
80+
}
81+
}
82+
83+
g.By("Creating default GatewayClass to trigger Gateway API installation")
84+
gatewayClassName := "openshift-default"
85+
gatewayClassControllerName := "openshift.io/gateway-controller/v1"
86+
gatewayClass := buildGatewayClass(gatewayClassName, gatewayClassControllerName)
87+
_, err = t.oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Create(ctx, gatewayClass, metav1.CreateOptions{})
88+
if err != nil && !apierrors.IsAlreadyExists(err) {
89+
framework.Failf("Failed to create GatewayClass %q: %v", gatewayClassName, err)
90+
}
91+
92+
g.By("Waiting for GatewayClass to be accepted")
93+
err = checkGatewayClass(t.oc, gatewayClassName)
94+
o.Expect(err).NotTo(o.HaveOccurred(), "GatewayClass %q was not accepted", gatewayClassName)
95+
96+
g.By("Getting the default domain")
97+
defaultIngressDomain, err := getDefaultIngressClusterDomainName(t.oc, time.Minute)
98+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to find default domain name")
99+
customDomain := strings.Replace(defaultIngressDomain, "apps.", "gw-upgrade.", 1)
100+
t.hostname = "test-upgrade." + customDomain
101+
102+
g.By("Creating Gateway with OLM-based provisioning")
103+
_, err = createAndCheckGateway(t.oc, t.gatewayName, gatewayClassName, customDomain)
104+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to create Gateway")
105+
106+
g.By("Verify the gateway's LoadBalancer service and DNSRecords")
107+
assertGatewayLoadbalancerReady(t.oc, t.gatewayName, t.gatewayName+"-openshift-default")
108+
assertDNSRecordStatus(t.oc, t.gatewayName)
109+
110+
g.By("Creating HTTPRoute with backend")
111+
backendName := "echo-backend-" + t.gatewayName
112+
createHttpRoute(t.oc.AsAdmin(), t.gatewayName, t.routeName, t.hostname, backendName)
113+
114+
g.By("Waiting for HTTPRoute to be accepted")
115+
_, err = assertHttpRouteSuccessful(t.oc.AsAdmin(), t.gatewayName, t.routeName)
116+
o.Expect(err).NotTo(o.HaveOccurred())
117+
118+
g.By("Verifying HTTP connectivity before upgrade")
119+
assertHttpRouteConnection(t.hostname)
120+
121+
g.By("Verifying OLM-based Istio CR exists before upgrade")
122+
// Check for Istio CR created by OLM (cluster-scoped, will be deleted during migration)
123+
_, err = t.oc.AsAdmin().Run("get").Args("istio", "openshift-gateway").Output()
124+
o.Expect(err).NotTo(o.HaveOccurred(), "Istio CR should exist before upgrade (OLM-based)")
125+
126+
// Check for Sail Operator subscription (will NOT be removed during migration)
127+
_, err = t.oc.AsAdmin().Run("get").Args("subscription", "-n", "openshift-operators", "servicemeshoperator3").Output()
128+
o.Expect(err).NotTo(o.HaveOccurred(), "Sail Operator subscription should exist before upgrade")
129+
130+
framework.Logf("Gateway and HTTPRoute successfully created with OLM-based provisioning, connectivity verified")
131+
}
132+
133+
// Test validates that resources continue working during upgrade and migrate to CIO after upgrade
134+
func (t *GatewayAPIMigrationUpgradeTest) Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, _ upgrades.UpgradeType) {
135+
g.By("Validating Gateway API resources remain functional during upgrade")
136+
137+
// Validate Gateway still exists and is programmed during upgrade
138+
gatewayClient := t.oc.AdminGatewayApiClient()
139+
gw, err := gatewayClient.GatewayV1().Gateways(ingressNamespace).Get(ctx, t.gatewayName, metav1.GetOptions{})
140+
o.Expect(err).NotTo(o.HaveOccurred())
141+
o.Expect(gw).NotTo(o.BeNil())
142+
143+
// Block until upgrade completes
144+
g.By("Waiting for upgrade to complete")
145+
<-done
146+
147+
g.By("Sleeping for a minute to allow CIO to take over Gateway API resources")
148+
time.Sleep(1 * time.Minute)
149+
150+
g.By("Validating migration from OLM to CIO-based provisioning after upgrade")
151+
152+
// Verify Gateway still exists and is programmed
153+
gw, err = gatewayClient.GatewayV1().Gateways(ingressNamespace).Get(ctx, t.gatewayName, metav1.GetOptions{})
154+
o.Expect(err).NotTo(o.HaveOccurred())
155+
o.Expect(gw).NotTo(o.BeNil())
156+
157+
var isProgrammed bool
158+
for _, condition := range gw.Status.Conditions {
159+
if condition.Type == string(gatewayv1.GatewayConditionProgrammed) && condition.Status == metav1.ConditionTrue {
160+
isProgrammed = true
161+
break
162+
}
163+
}
164+
o.Expect(isProgrammed).To(o.BeTrue(), "Gateway should remain programmed after upgrade")
165+
166+
g.By("Verifying Istiod control plane is running after migration")
167+
// Check that Istiod deployment exists and pods are running
168+
deployment, err := t.oc.AdminKubeClient().AppsV1().Deployments(ingressNamespace).Get(ctx, "istiod-openshift-gateway", metav1.GetOptions{})
169+
o.Expect(err).NotTo(o.HaveOccurred(), "Istiod deployment should exist after migration")
170+
171+
// Verify at least one istiod pod is running
172+
err = wait.PollUntilContextTimeout(ctx, 2*time.Second, 2*time.Minute, false, func(ctx context.Context) (bool, error) {
173+
pods, err := t.oc.AdminKubeClient().CoreV1().Pods(ingressNamespace).List(ctx, metav1.ListOptions{
174+
LabelSelector: metav1.FormatLabelSelector(deployment.Spec.Selector),
175+
})
176+
if err != nil {
177+
return false, nil
178+
}
179+
if len(pods.Items) < 1 {
180+
return false, nil
181+
}
182+
for _, pod := range pods.Items {
183+
if pod.Status.Phase == corev1.PodRunning {
184+
return true, nil
185+
}
186+
}
187+
return false, nil
188+
})
189+
o.Expect(err).NotTo(o.HaveOccurred(), "At least one Istiod pod should be running after migration")
190+
191+
g.By("Verifying Istio CRDs remain managed by OLM")
192+
// Istio CRDs were installed by OLM and should remain OLM-managed (not taken over by CIO)
193+
dynamicClient := t.oc.AdminDynamicClient()
194+
crdResource := schema.GroupVersionResource{
195+
Group: "apiextensions.k8s.io",
196+
Version: "v1",
197+
Resource: "customresourcedefinitions",
198+
}
199+
200+
for _, crdName := range istioCRDNames {
201+
crd, err := dynamicClient.Resource(crdResource).Get(ctx, crdName, metav1.GetOptions{})
202+
o.Expect(err).NotTo(o.HaveOccurred(), "Istio CRD %s should exist after migration", crdName)
203+
204+
// Verify OLM management label (CRDs should remain OLM-managed)
205+
labels, found, err := unstructured.NestedStringMap(crd.Object, "metadata", "labels")
206+
o.Expect(err).NotTo(o.HaveOccurred())
207+
o.Expect(found).To(o.BeTrue())
208+
o.Expect(labels).To(o.HaveKeyWithValue("olm.managed", "true"),
209+
"Istio CRD %s should remain OLM-managed after migration", crdName)
210+
}
211+
212+
g.By("Verifying CIO has taken ownership via GatewayClass")
213+
// Check GatewayClass has CIO sail library finalizer
214+
gwc, err := gatewayClient.GatewayV1().GatewayClasses().Get(ctx, "openshift-default", metav1.GetOptions{})
215+
o.Expect(err).NotTo(o.HaveOccurred())
216+
217+
hasCIOFinalizer := false
218+
expectedFinalizer := "openshift.io/ingress-operator-sail-finalizer"
219+
for _, finalizer := range gwc.Finalizers {
220+
if finalizer == expectedFinalizer {
221+
hasCIOFinalizer = true
222+
break
223+
}
224+
}
225+
o.Expect(hasCIOFinalizer).To(o.BeTrue(), "GatewayClass should have CIO sail library finalizer after upgrade")
226+
227+
// Check GatewayClass has required CIO conditions
228+
var hasControllerInstalled, hasCRDsReady bool
229+
for _, condition := range gwc.Status.Conditions {
230+
if condition.Type == "ControllerInstalled" && condition.Status == metav1.ConditionTrue {
231+
hasControllerInstalled = true
232+
}
233+
if condition.Type == "CRDsReady" && condition.Status == metav1.ConditionTrue {
234+
hasCRDsReady = true
235+
}
236+
}
237+
o.Expect(hasControllerInstalled).To(o.BeTrue(), "GatewayClass should have ControllerInstalled condition after upgrade")
238+
o.Expect(hasCRDsReady).To(o.BeTrue(), "GatewayClass should have CRDsReady condition after upgrade")
239+
240+
g.By("Verifying migration from OLM-based Istio CR to Sail Library")
241+
// The OLM Subscription for Sail Operator should still exist (it's not removed during migration)
242+
_, err = t.oc.AsAdmin().Run("get").Args("subscription", "-n", "openshift-operators", "servicemeshoperator3").Output()
243+
o.Expect(err).NotTo(o.HaveOccurred(), "Sail Operator subscription should still exist after upgrade")
244+
245+
// The Istio CR created by OLM should be deleted by CIO during migration
246+
_, err = t.oc.AsAdmin().Run("get").Args("istio", "openshift-gateway").Output()
247+
o.Expect(err).To(o.HaveOccurred(), "Istio CR should be deleted during migration")
248+
o.Expect(apierrors.IsNotFound(err)).To(o.BeTrue(), "Istio CR should return NotFound error")
249+
250+
// IstioRevision should also be cleaned up
251+
_, err = t.oc.AsAdmin().Run("get").Args("istiorevision", "openshift-gateway").Output()
252+
o.Expect(err).To(o.HaveOccurred(), "IstioRevision should be cleaned up during migration")
253+
o.Expect(apierrors.IsNotFound(err)).To(o.BeTrue(), "IstioRevision should return NotFound error")
254+
255+
g.By("Verifying HTTPRoute still exists and is accepted after upgrade")
256+
_, err = assertHttpRouteSuccessful(t.oc.AsAdmin(), t.gatewayName, t.routeName)
257+
o.Expect(err).NotTo(o.HaveOccurred())
258+
259+
g.By("Verifying HTTP connectivity after upgrade")
260+
assertHttpRouteConnection(t.hostname)
261+
262+
framework.Logf("Gateway API successfully migrated from Istio CR (OLM) to Sail Library (CIO Helm-based)")
263+
}
264+
265+
// Teardown cleans up Gateway API resources, Istio CR, and OSSM subscription
266+
// This runs even if the test fails, ensuring complete cleanup
267+
func (t *GatewayAPIMigrationUpgradeTest) Teardown(ctx context.Context, f *framework.Framework) {
268+
g.By("Deleting the Sail Operator subscription")
269+
subscriptionName := "servicemeshoperator3"
270+
subscriptionNamespace := "openshift-operators"
271+
err := t.oc.AsAdmin().Run("delete").Args("--ignore-not-found=true", "subscription", "-n", subscriptionNamespace, subscriptionName).Execute()
272+
if err != nil {
273+
framework.Logf("Failed to delete Subscription %q: %v", subscriptionName, err)
274+
}
275+
276+
g.By("Deleting the Istio CR if it exists")
277+
// Delete the Istio CR explicitly (may still exist if test failed before migration completed)
278+
istioName := "openshift-gateway"
279+
err = t.oc.AsAdmin().Run("delete").Args("--ignore-not-found=true", "istio", istioName).Execute()
280+
if err != nil {
281+
framework.Logf("Failed to delete Istio CR %q: %v", istioName, err)
282+
}
283+
284+
g.By("Deleting the Gateway")
285+
err = t.oc.AdminGatewayApiClient().GatewayV1().Gateways(ingressNamespace).Delete(ctx, t.gatewayName, metav1.DeleteOptions{})
286+
if err != nil && !apierrors.IsNotFound(err) {
287+
framework.Logf("Failed to delete Gateway %q: %v", t.gatewayName, err)
288+
}
289+
290+
g.By("Deleting the GatewayClass")
291+
gatewayClassName := "openshift-default"
292+
err = t.oc.AdminGatewayApiClient().GatewayV1().GatewayClasses().Delete(ctx, gatewayClassName, metav1.DeleteOptions{})
293+
if err != nil && !apierrors.IsNotFound(err) {
294+
framework.Logf("Failed to delete GatewayClass %q: %v", gatewayClassName, err)
295+
}
296+
297+
g.By("Waiting for istiod pods to be deleted")
298+
o.Eventually(func(g o.Gomega) {
299+
podsList, err := t.oc.AdminKubeClient().CoreV1().Pods(ingressNamespace).List(ctx, metav1.ListOptions{
300+
LabelSelector: "app=istiod",
301+
})
302+
g.Expect(err).NotTo(o.HaveOccurred())
303+
g.Expect(podsList.Items).Should(o.BeEmpty(), "Istiod pods should be deleted")
304+
}).WithTimeout(10 * time.Minute).WithPolling(10 * time.Second).Should(o.Succeed())
305+
306+
framework.Logf("Gateway API resources, Istio CR, and OSSM subscription successfully cleaned up")
307+
}

0 commit comments

Comments
 (0)