Skip to content

Commit

Permalink
fix: enable upgrade test (envoyproxy#3764)
Browse files Browse the repository at this point in the history
adapt upgrade test to v1.1

Signed-off-by: Guy Daich <guy.daich@sap.com>
Co-authored-by: zirain <zirain2009@gmail.com>
  • Loading branch information
guydc and zirain authored Jul 14, 2024
1 parent 7b09c21 commit cd51ad3
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 157 deletions.
5 changes: 5 additions & 0 deletions internal/utils/helm/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (pt *PackageTool) Setup() error {
return err
}

if pt.logger == nil {
pt.logger = NewPrinterForWriter(os.Stdout, false)
}

if err = pt.actionConfig.Init(
kubectlFactory,
ns,
Expand Down Expand Up @@ -350,6 +354,7 @@ func (pt *PackageTool) setUninstallOptions(opts *PackageOptions) {
pt.actionUninstall.KeepHistory = false

pt.actionUninstall.DryRun = opts.DryRun
pt.actionUninstall.Timeout = opts.Timeout

if opts.Wait {
pt.actionUninstall.Wait = opts.Wait
Expand Down
106 changes: 106 additions & 0 deletions internal/utils/helm/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package helm

import (
"testing"
"time"

"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/cli/values"
)

func TestPackageTool_Setup(t *testing.T) {
type fields struct {
chartName string
envSettings *cli.EnvSettings
actionConfig *action.Configuration
actionInstall *action.Install
actionUninstall *action.Uninstall
valuesOpts *values.Options
logger Printer
}
tests := []struct {
name string
fields fields
wantErr bool
}{
{
name: "shouldSetup",
fields: fields{
chartName: "mychart",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pt := &PackageTool{
chartName: tt.fields.chartName,
envSettings: tt.fields.envSettings,
actionConfig: tt.fields.actionConfig,
actionInstall: tt.fields.actionInstall,
actionUninstall: tt.fields.actionUninstall,
valuesOpts: tt.fields.valuesOpts,
logger: tt.fields.logger,
}
if err := pt.Setup(); (err != nil) != tt.wantErr {
t.Errorf("Setup() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestPackageTool_setInstallOptions(t *testing.T) {
type fields struct {
chartName string
envSettings *cli.EnvSettings
actionConfig *action.Configuration
actionInstall *action.Install
actionUninstall *action.Uninstall
valuesOpts *values.Options
logger Printer
}
type args struct {
opts *PackageOptions
}
tests := []struct {
name string
fields fields
args args
}{
{
name: "shouldSetInstallOptions",
fields: fields{
chartName: "mychart",
},
args: args{
opts: &PackageOptions{
Version: "1.0.2",
Timeout: 1 * time.Second,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pt := &PackageTool{
chartName: tt.fields.chartName,
envSettings: tt.fields.envSettings,
actionConfig: tt.fields.actionConfig,
actionInstall: tt.fields.actionInstall,
actionUninstall: tt.fields.actionUninstall,
valuesOpts: tt.fields.valuesOpts,
logger: tt.fields.logger,
}
if err := pt.Setup(); err != nil {
t.Errorf("Setup() error = %v", err)
}
pt.setInstallOptions(tt.args.opts)
})
}
}
70 changes: 0 additions & 70 deletions test/e2e/base/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -664,26 +664,6 @@ spec:
targetPort: 8000
---
apiVersion: v1
kind: Namespace
metadata:
name: gateway-upgrade-infra
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ha-gateway
namespace: gateway-upgrade-infra
spec:
gatewayClassName: upgrade
listeners:
- allowedRoutes:
namespaces:
from: Same
name: http1
port: 80
protocol: HTTP
---
apiVersion: v1
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURPVENDQWlHZ0F3SUJBZ0lVUWNxbnZtQXlkRUtuOEdqWTdjZzVDb3A2QWp3d0RRWUpLb1pJaHZjTkFRRUwKQlFBd1JURUxNQWtHQTFVRUJoTUNRVlV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BBdlRMdmlab1FnK0tqdTZ4Mkxzd3NKNUJBb0dCQUxFcApDUzcxZFd5dkZ1NUxCdGltdWpJdDVhV0o4WkFDVUcyTVpWU1o0Y0VXcmNocENsdi8yMTM1bmFhbVFVRjNLalEyCm9ER0JOSG1JWmRvSkVBS25pSHliSmdwSGRvRFd2SlBVeXVZWXY1M29IdHRxcW0wOWJTcG45eXNFVjB1NWg1UWUKVUhFUHRiQWgyNUtLNzgycG0wQlRhajc2Y0s2aDZIUEdLNTg4UEhZaEFvR0FILzJMS044WnJ3c1R6Nmx6T2c3ZApzdUFuaDVFTUp0TEhTSDJHeFJ5aFcrYVFHdGNxdDZYK1dkNDZnd1BMQjRjd2QzL01nQkFvcFhGazhYV3pTVUlhCnI5SG9SQzZJT2tzQ0lOallCd2h2TjArcm5oN3JzTm5XZVd5Z2tWQ2tERDN5NlNTa2RTZjliOUZzWUJtOHY0VkcKYzFqdmVjWVF6S243QzFRU2FtUnAzRUk9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
Expand All @@ -692,56 +672,6 @@ metadata:
name: my-tls-secret
namespace: envoy-gateway-system
type: kubernetes.io/tls
---
apiVersion: v1
kind: Service
metadata:
name: infra-backend
namespace: gateway-upgrade-infra
spec:
selector:
app: infra-backend
ports:
- protocol: TCP
port: 8080
targetPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: infra-backend
namespace: gateway-upgrade-infra
labels:
app: infra-backend
spec:
replicas: 2
selector:
matchLabels:
app: infra-backend
template:
metadata:
labels:
app: infra-backend
spec:
containers:
- name: infra-backend
# From https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/echo-basic/echo-basic.go
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SERVICE_NAME
value: infra-backend
resources:
requests:
cpu: 10m

---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
//go:embed testdata/*.yaml base/*
var Manifests embed.FS

//go:embed testdata/*.yaml upgrade/*
var UpgradeManifests embed.FS

func CheckInstallScheme(t *testing.T, c client.Client) {
require.NoError(t, gwapiv1a3.Install(c.Scheme()))
require.NoError(t, gwapiv1a2.Install(c.Scheme()))
Expand Down
Loading

0 comments on commit cd51ad3

Please sign in to comment.