Skip to content

Commit 78f0ffd

Browse files
committed
e2e: Use Helm chart from the commit
1 parent 2e181b2 commit 78f0ffd

File tree

9 files changed

+39
-30
lines changed

9 files changed

+39
-30
lines changed

scripts/ci_e2e_test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ CLUSTER_INSTANCE_TYPE="m5.xlarge"
3636
CLUSTER_NODE_COUNT="4"
3737
CLUSTER_KUBECONFIG=${CLUSTER_KUBECONFIG:-"/tmp/lb-controller-e2e/clusters/${CLUSTER_NAME}.kubeconfig"}
3838

39+
HELM_DIR="$(cd $(dirname "${BASH_SOURCE[0]}")/../helm ; pwd)"
40+
3941
#######################################
4042
# Build and push ECR image for AWS Load Balancer Controller
4143
#
@@ -227,6 +229,7 @@ test_controller_image() {
227229
--cluster-name=${CLUSTER_NAME} \
228230
--aws-region=${AWS_REGION} \
229231
--aws-vpc-id=${cluster_vpc_id} \
232+
--helm-dir=${HELM_DIR} \
230233
--controller-image=${CONTROLLER_IMAGE_NAME} \
231234
--s3-bucket-name=${S3_BUCKET} \
232235
--certificate-arns=${CERTIFICATE_ARNS}

test/e2e/ingress/multi_path_backend_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package ingress
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
. "github.com/onsi/ginkgo"
79
. "github.com/onsi/gomega"
810
"sigs.k8s.io/aws-load-balancer-controller/pkg/k8s"
911
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2"
1012
"sigs.k8s.io/aws-load-balancer-controller/test/framework"
1113
"sigs.k8s.io/aws-load-balancer-controller/test/framework/http"
1214
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
13-
"time"
1415
)
1516

1617
var _ = Describe("test ingresses with multiple path and backends", func() {
@@ -23,7 +24,8 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
2324

2425
if tf.Options.ControllerImage != "" {
2526
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
26-
tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
27+
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
28+
Expect(err).NotTo(HaveOccurred())
2729
time.Sleep(60 * time.Second)
2830
})
2931
}

test/e2e/ingress/vanilla_ingress_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package ingress
33
import (
44
"context"
55
"fmt"
6+
"net/http"
7+
"time"
8+
69
awssdk "github.com/aws/aws-sdk-go/aws"
710
"github.com/gavv/httpexpect/v2"
811
. "github.com/onsi/ginkgo"
@@ -12,13 +15,11 @@ import (
1215
apierrs "k8s.io/apimachinery/pkg/api/errors"
1316
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1417
"k8s.io/apimachinery/pkg/util/intstr"
15-
"net/http"
1618
"sigs.k8s.io/aws-load-balancer-controller/pkg/k8s"
1719
"sigs.k8s.io/aws-load-balancer-controller/test/framework"
1820
"sigs.k8s.io/aws-load-balancer-controller/test/framework/fixture"
1921
"sigs.k8s.io/aws-load-balancer-controller/test/framework/manifest"
2022
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
21-
"time"
2223
)
2324

2425
var _ = Describe("vanilla ingress tests", func() {
@@ -32,7 +33,8 @@ var _ = Describe("vanilla ingress tests", func() {
3233
ctx = context.Background()
3334
if tf.Options.ControllerImage != "" {
3435
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
35-
tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
36+
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
37+
Expect(err).NotTo(HaveOccurred())
3638
time.Sleep(60 * time.Second)
3739
})
3840
}

test/e2e/run-canary-test.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,16 @@ eksctl create iamserviceaccount \
6262
--override-existing-serviceaccounts \
6363
--approve || true
6464

65-
echo "Update helm repo eks"
66-
helm repo add eks https://aws.github.io/eks-charts
67-
68-
helm repo update
69-
7065
echo "Install TargetGroupBinding CRDs"
7166
kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master"
7267

7368
echo "Install aws-load-balancer-controller"
74-
helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=$CLUSTER_NAME --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
69+
helm upgrade -i aws-load-balancer-controller $SCRIPT_DIR/../helm/aws-load-balancer-controller -n kube-system --set clusterName=$CLUSTER_NAME --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
7570

7671
#Start the test
7772
echo "Starting the ginkgo test suite"
7873

79-
(cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo -v -r --timeout 60m --failOnPending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID || true)
74+
(cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo -v -r --timeout 60m --failOnPending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --helm-dir=$SCRIPT_DIR/../helm || true)
8075

8176
echo "Delete aws-load-balancer-controller"
8277
helm delete aws-load-balancer-controller -n kube-system --timeout=10m || true

test/framework/controller/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package controller
33
import "time"
44

55
const (
6-
EKSHelmChartsRepo = "https://aws.github.io/eks-charts"
76
AWSLoadBalancerControllerHelmChart = "aws-load-balancer-controller"
87
AWSLoadBalancerControllerHelmRelease = "aws-load-balancer-controller"
98
AWSLoadBalancerControllerInstallationTimeout = 2 * time.Minute

test/framework/controller/installation_manager.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package controller
22

33
import (
4+
"path"
5+
"strings"
6+
47
"github.com/go-logr/logr"
58
"github.com/pkg/errors"
69
"k8s.io/apimachinery/pkg/util/uuid"
710
"sigs.k8s.io/aws-load-balancer-controller/test/framework/helm"
8-
"strings"
911
)
1012

1113
// InstallationManager is responsible for manage controller installation in cluster.
@@ -15,12 +17,13 @@ type InstallationManager interface {
1517
}
1618

1719
// NewDefaultInstallationManager constructs new defaultInstallationManager.
18-
func NewDefaultInstallationManager(helmReleaseManager helm.ReleaseManager, clusterName string, region string, vpcID string, logger logr.Logger) *defaultInstallationManager {
20+
func NewDefaultInstallationManager(helmReleaseManager helm.ReleaseManager, clusterName string, region string, vpcID string, helmDir string, logger logr.Logger) *defaultInstallationManager {
1921
return &defaultInstallationManager{
2022
helmReleaseManager: helmReleaseManager,
2123
clusterName: clusterName,
2224
region: region,
2325
vpcID: vpcID,
26+
helmDir: helmDir,
2427

2528
namespace: "kube-system",
2629
controllerSAName: "aws-load-balancer-controller",
@@ -36,6 +39,7 @@ type defaultInstallationManager struct {
3639
clusterName string
3740
region string
3841
vpcID string
42+
helmDir string
3943

4044
namespace string
4145
controllerSAName string
@@ -44,7 +48,7 @@ type defaultInstallationManager struct {
4448

4549
func (m *defaultInstallationManager) ResetController() error {
4650
vals := m.computeDefaultHelmVals()
47-
_, err := m.helmReleaseManager.InstallOrUpgradeRelease(EKSHelmChartsRepo, AWSLoadBalancerControllerHelmChart,
51+
_, err := m.helmReleaseManager.InstallOrUpgradeRelease(path.Join(m.helmDir, AWSLoadBalancerControllerHelmChart),
4852
m.namespace, AWSLoadBalancerControllerHelmRelease, vals,
4953
helm.WithTimeout(AWSLoadBalancerControllerInstallationTimeout))
5054
return err
@@ -63,7 +67,7 @@ func (m *defaultInstallationManager) UpgradeController(controllerImage string) e
6367
vals["podLabels"] = map[string]string{
6468
"revision": string(uuid.NewUUID()),
6569
}
66-
_, err = m.helmReleaseManager.InstallOrUpgradeRelease(EKSHelmChartsRepo, AWSLoadBalancerControllerHelmChart,
70+
_, err = m.helmReleaseManager.InstallOrUpgradeRelease(path.Join(m.helmDir, AWSLoadBalancerControllerHelmChart),
6771
m.namespace, AWSLoadBalancerControllerHelmRelease, vals,
6872
helm.WithTimeout(AWSLoadBalancerControllerInstallationTimeout))
6973
return err

test/framework/framework.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ func InitFramework() (*Framework, error) {
8989

9090
func buildControllerInstallationManager(options Options, logger logr.Logger) controller.InstallationManager {
9191
helmReleaseManager := helm.NewDefaultReleaseManager(options.KubeConfig, logger)
92-
ctrlInstallationManager := controller.NewDefaultInstallationManager(helmReleaseManager, options.ClusterName, options.AWSRegion, options.AWSVPCID, logger)
92+
ctrlInstallationManager := controller.NewDefaultInstallationManager(helmReleaseManager, options.ClusterName, options.AWSRegion, options.AWSVPCID, options.HelmDir, logger)
9393
return ctrlInstallationManager
9494
}

test/framework/helm/release_manager.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package helm
22

33
import (
44
"fmt"
5+
"time"
6+
57
"github.com/go-logr/logr"
68
"helm.sh/helm/v3/pkg/action"
79
"helm.sh/helm/v3/pkg/chart/loader"
810
"helm.sh/helm/v3/pkg/cli"
911
"helm.sh/helm/v3/pkg/release"
1012
"helm.sh/helm/v3/pkg/storage/driver"
1113
"k8s.io/cli-runtime/pkg/genericclioptions"
12-
"time"
1314
)
1415

1516
// ActionOptions contains general helm action options
@@ -38,15 +39,15 @@ func WithTimeout(timeout time.Duration) ActionOption {
3839
// ReleaseManager is responsible for manage helm releases
3940
type ReleaseManager interface {
4041
// InstallOrUpgradeRelease install or upgrade helm release
41-
InstallOrUpgradeRelease(chartRepo string, chartName string,
42+
InstallOrUpgradeRelease(chartName string,
4243
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error)
4344

4445
// InstallRelease install helm release
45-
InstallRelease(chartRepo string, chartName string,
46+
InstallRelease(chartName string,
4647
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error)
4748

4849
// UpgradeRelease upgrade helm release
49-
UpgradeRelease(chartRepo string, chartName string,
50+
UpgradeRelease(chartName string,
5051
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error)
5152
}
5253

@@ -66,24 +67,23 @@ type defaultReleaseManager struct {
6667
logger logr.Logger
6768
}
6869

69-
func (m *defaultReleaseManager) InstallOrUpgradeRelease(chartRepo string, chartName string,
70+
func (m *defaultReleaseManager) InstallOrUpgradeRelease(chartName string,
7071
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error) {
7172
actionCFG := m.obtainActionConfig(namespace)
7273
historyAction := action.NewHistory(actionCFG)
7374
historyAction.Max = 1
7475
if _, err := historyAction.Run(releaseName); err == driver.ErrReleaseNotFound {
75-
return m.InstallRelease(chartRepo, chartName, namespace, releaseName, vals, opts...)
76+
return m.InstallRelease(chartName, namespace, releaseName, vals, opts...)
7677
} else {
77-
return m.UpgradeRelease(chartRepo, chartName, namespace, releaseName, vals, opts...)
78+
return m.UpgradeRelease(chartName, namespace, releaseName, vals, opts...)
7879
}
7980
}
8081

81-
func (m *defaultReleaseManager) InstallRelease(chartRepo string, chartName string,
82+
func (m *defaultReleaseManager) InstallRelease(chartName string,
8283
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error) {
8384

8485
actionCFG := m.obtainActionConfig(namespace)
8586
installAction := action.NewInstall(actionCFG)
86-
installAction.ChartPathOptions.RepoURL = chartRepo
8787
installAction.Namespace = namespace
8888
installAction.SkipCRDs = false
8989
installAction.ReleaseName = releaseName
@@ -107,12 +107,11 @@ func (m *defaultReleaseManager) InstallRelease(chartRepo string, chartName strin
107107
return installAction.Run(chartRequested, vals)
108108
}
109109

110-
func (m *defaultReleaseManager) UpgradeRelease(chartRepo string, chartName string,
110+
func (m *defaultReleaseManager) UpgradeRelease(chartName string,
111111
namespace string, releaseName string, vals map[string]interface{}, opts ...ActionOption) (*release.Release, error) {
112112

113113
actionCFG := m.obtainActionConfig(namespace)
114114
upgradeAction := action.NewUpgrade(actionCFG)
115-
upgradeAction.ChartPathOptions.RepoURL = chartRepo
116115
upgradeAction.Namespace = namespace
117116
upgradeAction.ResetValues = true
118117

test/framework/options.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ func init() {
1212
globalOptions.BindFlags()
1313
}
1414

15-
// configuration options
15+
// Options are the configuration options.
1616
type Options struct {
1717
ClusterName string
1818
AWSRegion string
1919
AWSVPCID string
20+
HelmDir string
2021
KubeConfig string
2122

2223
// AWS Load Balancer Controller image. leave empty to use default one from helm chart.
@@ -31,6 +32,7 @@ func (options *Options) BindFlags() {
3132
flag.StringVar(&options.ClusterName, "cluster-name", "", `Kubernetes cluster name (required)`)
3233
flag.StringVar(&options.AWSRegion, "aws-region", "", `AWS Region for the kubernetes cluster`)
3334
flag.StringVar(&options.AWSVPCID, "aws-vpc-id", "", `ID of VPC to create load balancers in`)
35+
flag.StringVar(&options.HelmDir, "helm-dir", "", `directory containing Helm chart`)
3436

3537
flag.StringVar(&options.ControllerImage, "controller-image", "", `AWS Load Balancer Controller image`)
3638

@@ -51,6 +53,9 @@ func (options *Options) Validate() error {
5153
if len(options.AWSVPCID) == 0 {
5254
return errors.Errorf("%s must be set!", "aws-vpc-id")
5355
}
56+
if len(options.HelmDir) == 0 {
57+
return errors.Errorf("%s must be set!", "helm-dir")
58+
}
5459
return nil
5560
}
5661

0 commit comments

Comments
 (0)