Skip to content

Commit

Permalink
Add options for chart version and add command output (#2332)
Browse files Browse the repository at this point in the history
Problem: There's not a way to specify the version of the Chart and to
see the command used to install.

Solution: Add a parameter to specify the version of the Chart. When
installing from a registry if no version is specified the latest tag
will be installed. For now only the edge version will set the edge tag.
Also output the command used to install.
  • Loading branch information
lucacome authored Aug 7, 2024
1 parent 6295850 commit 5f8509a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ linters-settings:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
arguments:
- allowedPackages:
- github.com/onsi/gomega
- github.com/onsi/ginkgo/v2
- name: empty-block
- name: error-naming
- name: error-return
Expand Down Expand Up @@ -40,6 +45,10 @@ linters-settings:
dupword:
ignore:
- "test"
stylecheck:
dot-import-whitelist:
- github.com/onsi/gomega
- github.com/onsi/ginkgo/v2
linters:
enable:
- asasalint
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GW_API_VERSION ?= $(shell sed -n 's/.*ref=v\(.*\)/\1/p' ../config/crd/gateway-ap
GW_API_PREV_VERSION ?= 1.1.0## Supported Gateway API version from previous NGF release
GW_SERVICE_TYPE = NodePort## Service type to use for the gateway
GW_SVC_GKE_INTERNAL = false
NGF_VERSION ?= $(shell git describe --tags $(shell git rev-list --tags --max-count=1))## NGF version to be tested (defaults to latest tag)
NGF_VERSION ?= edge## NGF version to be tested
PULL_POLICY = Never## Pull policy for the images
PROVISIONER_MANIFEST = conformance/provisioner/provisioner.yaml
SUPPORTED_FEATURES = HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect,HTTPRouteHostRewrite,HTTPRoutePathRewrite,GatewayPort8080,HTTPRouteResponseHeaderModification,GRPCExactMethodMatching,GRPCRouteListenerHostnameMatching,GRPCRouteHeaderMatching
Expand Down
14 changes: 14 additions & 0 deletions tests/framework/ngf.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
core "k8s.io/api/core/v1"
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -22,6 +23,7 @@ type InstallationConfig struct {
ReleaseName string
Namespace string
ChartPath string
ChartVersion string
NgfImageRepository string
NginxImageRepository string
ImageTag string
Expand Down Expand Up @@ -58,17 +60,23 @@ func UninstallGatewayAPI(apiVersion string) ([]byte, error) {
func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
args := []string{
"install",
"--debug",
cfg.ReleaseName,
cfg.ChartPath,
"--create-namespace",
"--namespace", cfg.Namespace,
"--wait",
"--set", "nginxGateway.productTelemetry.enable=false",
}
if cfg.ChartVersion != "" {
args = append(args, "--version", cfg.ChartVersion)
}

args = append(args, setImageArgs(cfg)...)
fullArgs := append(args, extraArgs...)

GinkgoWriter.Printf("Installing NGF with command: helm %v\n", strings.Join(fullArgs, " "))

return exec.Command("helm", fullArgs...).CombinedOutput()
}

Expand All @@ -81,16 +89,22 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {

args := []string{
"upgrade",
"--debug",
cfg.ReleaseName,
cfg.ChartPath,
"--namespace", cfg.Namespace,
"--wait",
"--set", "nginxGateway.productTelemetry.enable=false",
}
if cfg.ChartVersion != "" {
args = append(args, "--version", cfg.ChartVersion)
}

args = append(args, setImageArgs(cfg)...)
fullArgs := append(args, extraArgs...)

GinkgoWriter.Printf("Upgrading NGF with command: helm %v\n", strings.Join(fullArgs, " "))

return exec.Command("helm", fullArgs...).CombinedOutput()
}

Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/sync-files-to-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -eo pipefail

source scripts/vars.env

NGF_DIR=$(dirname "$PWD")
NGF_DIR=$(dirname "$PWD")/

gcloud compute config-ssh --ssh-config-file ngf-gcp.ssh >/dev/null

rsync -ave 'ssh -F ngf-gcp.ssh' "${NGF_DIR}" username@"${RESOURCE_NAME}"."${GKE_CLUSTER_ZONE}"."${GKE_PROJECT}":~
rsync -ave 'ssh -F ngf-gcp.ssh' "${NGF_DIR}" username@"${RESOURCE_NAME}"."${GKE_CLUSTER_ZONE}"."${GKE_PROJECT}":~/nginx-gateway-fabric
6 changes: 6 additions & 0 deletions tests/suite/system_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var (
localChartPath string
address string
version string
chartVersion string
clusterInfo framework.ClusterInfo
skipNFRTests bool
)
Expand Down Expand Up @@ -173,6 +174,11 @@ func setup(cfg setupConfig, extraInstallArgs ...string) {
}
installCfg.ImageTag = *imageTag
installCfg.ImagePullPolicy = *imagePullPolicy
} else {
if version == "edge" {
chartVersion = "0.0.0-edge"
installCfg.ChartVersion = chartVersion
}
}

output, err := framework.InstallGatewayAPI(cfg.gwAPIVersion)
Expand Down
1 change: 1 addition & 0 deletions tests/suite/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() {
ReleaseName: releaseName,
Namespace: ngfNamespace,
ChartPath: localChartPath,
ChartVersion: chartVersion,
NgfImageRepository: *ngfImageRepository,
NginxImageRepository: nginxImage,
ImageTag: *imageTag,
Expand Down

0 comments on commit 5f8509a

Please sign in to comment.