Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2672 from nojnhuh/fix-upgrade-e2e
Browse files Browse the repository at this point in the history
fix(e2e): Update upgrade test with new CRD versions
  • Loading branch information
nojnhuh authored Mar 2, 2021
2 parents 840fb29 + 22f7925 commit edcc181
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 65 deletions.
1 change: 1 addition & 0 deletions cmd/cli/mesh_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (u *meshUpgradeCmd) run(config *helm.Configuration) error {

upgradeClient := helm.NewUpgrade(config)
upgradeClient.Wait = true
upgradeClient.Timeout = 5 * time.Minute
upgradeClient.ResetValues = true
if _, err = upgradeClient.Run(u.meshName, u.chart, values); err != nil {
return err
Expand Down
84 changes: 19 additions & 65 deletions tests/e2e/e2e_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
smiAccessV1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2"
smiSpecsV1alpha3 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli"
Expand Down Expand Up @@ -111,54 +109,22 @@ var _ = OSMDescribe("Upgrade from latest",

Expect(Td.WaitForPodsRunningReady(ns, 90*time.Second, 2)).To(Succeed())

httpRG := smiSpecsV1alpha3.HTTPRouteGroup{
ObjectMeta: metav1.ObjectMeta{
Name: "routes",
},
Spec: smiSpecsV1alpha3.HTTPRouteGroupSpec{
Matches: []smiSpecsV1alpha3.HTTPMatch{
{
Name: "all",
PathRegex: ".*",
Methods: []string{"*"},
},
},
},
}
// Deploy allow rule client->server
httpRG, trafficTarget := Td.CreateSimpleAllowPolicy(
SimpleAllowPolicy{
RouteGroupName: "routes",
TrafficTargetName: "test-target",

trafficTarget := smiAccessV1alpha2.TrafficTarget{
ObjectMeta: metav1.ObjectMeta{
Name: "test-target",
},
Spec: smiAccessV1alpha2.TrafficTargetSpec{
Sources: []smiAccessV1alpha2.IdentityBindingSubject{
{
Kind: "ServiceAccount",
Name: "client",
Namespace: ns,
},
},
Destination: smiAccessV1alpha2.IdentityBindingSubject{
Kind: "ServiceAccount",
Name: "server",
Namespace: ns,
},
Rules: []smiAccessV1alpha2.TrafficTargetRule{
{
Kind: "HTTPRouteGroup",
Name: "routes",
Matches: []string{
"all",
},
},
},
},
}
SourceNamespace: ns,
SourceSVCAccountName: "client",

// Configs have to be put into a monitored NS, and osm-system can't be by cli
_, err = Td.SmiClients.SpecClient.SpecsV1alpha3().HTTPRouteGroups(ns).Create(context.Background(), &httpRG, metav1.CreateOptions{})
DestinationNamespace: ns,
DestinationSvcAccountName: "server",
},
)
_, err = Td.CreateHTTPRouteGroup(ns, httpRG)
Expect(err).NotTo(HaveOccurred())
_, err = Td.SmiClients.AccessClient.AccessV1alpha2().TrafficTargets(ns).Create(context.Background(), &trafficTarget, metav1.CreateOptions{})
_, err = Td.CreateTrafficTarget(ns, trafficTarget)
Expect(err).NotTo(HaveOccurred())

// All ready. Expect client to reach server
Expand Down Expand Up @@ -190,7 +156,7 @@ var _ = OSMDescribe("Upgrade from latest",
defer prometheus.Stop()
cond := Td.WaitForRepeatedSuccess(func() bool {
expectedProxyCount := float64(2)
proxies, err := prometheus.VectorQuery("sum(envoy_control_plane_connected_state)", time.Now())
proxies, err := prometheus.VectorQuery("osm_proxy_connect_count", time.Now())
if err != nil {
Td.T.Log("error querying prometheus:", err)
return false
Expand All @@ -213,9 +179,9 @@ var _ = OSMDescribe("Upgrade from latest",
// TODO: Only delete and recreate the CRDs if needed
By("Upgrading CRDs")

err = Td.SmiClients.SpecClient.SpecsV1alpha3().HTTPRouteGroups(ns).Delete(context.Background(), httpRG.Name, metav1.DeleteOptions{})
err = Td.SmiClients.SpecClient.SpecsV1alpha4().HTTPRouteGroups(ns).Delete(context.Background(), httpRG.Name, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
err = Td.SmiClients.AccessClient.AccessV1alpha2().TrafficTargets(ns).Delete(context.Background(), trafficTarget.Name, metav1.DeleteOptions{})
err = Td.SmiClients.AccessClient.AccessV1alpha3().TrafficTargets(ns).Delete(context.Background(), trafficTarget.Name, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

helm := &action.Configuration{}
Expand Down Expand Up @@ -250,22 +216,10 @@ var _ = OSMDescribe("Upgrade from latest",
}
Expect(err).NotTo(HaveOccurred())

// Deploy allow rule client->server
newHTTPRG, newTrafficTarget := Td.CreateSimpleAllowPolicy(
SimpleAllowPolicy{
RouteGroupName: "routes",
TrafficTargetName: "test-target",

SourceNamespace: ns,
SourceSVCAccountName: "client",

DestinationNamespace: ns,
DestinationSvcAccountName: "server",
},
)
_, err = Td.CreateHTTPRouteGroup(ns, newHTTPRG)
// Re-deploy policies
_, err = Td.CreateHTTPRouteGroup(ns, httpRG)
Expect(err).NotTo(HaveOccurred())
_, err = Td.CreateTrafficTarget(ns, newTrafficTarget)
_, err = Td.CreateTrafficTarget(ns, trafficTarget)
Expect(err).NotTo(HaveOccurred())

checkClientToServerOK()
Expand Down

0 comments on commit edcc181

Please sign in to comment.