Skip to content

Commit

Permalink
Add debug log level as extra install argument
Browse files Browse the repository at this point in the history
  • Loading branch information
bjee19 committed Sep 3, 2024
1 parent 7cd5a5c commit fb9a17f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 47 deletions.
25 changes: 0 additions & 25 deletions tests/framework/ngf.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,6 @@ func UninstallGatewayAPI(apiVersion string) ([]byte, error) {
return nil, nil
}

// InstallNGFDebugLevel installs NGF with debug log level.
func InstallNGFDebugLevel(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",
"--set", "nginxGateway.config.logging.level=debug",
}
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()
}

// InstallNGF installs NGF.
func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
args := []string{
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/nginxgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("NginxGateway", Ordered, Label("functional", "nginxGateway"), f
teardown(releaseName)

cfg := getDefaultSetupCfg()
cfg.infoLogLevel = true
cfg.debugLogLevel = false
setup(cfg)

ngfPodName, err := getNGFPodName()
Expand Down
35 changes: 19 additions & 16 deletions tests/suite/system_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ const (
)

type setupConfig struct {
releaseName string
chartPath string
gwAPIVersion string
deploy bool
nfr bool
infoLogLevel bool
releaseName string
chartPath string
gwAPIVersion string
deploy bool
nfr bool
debugLogLevel bool
}

func setup(cfg setupConfig, extraInstallArgs ...string) {
Expand Down Expand Up @@ -213,14 +213,16 @@ func setupNGF(cfg setupConfig, extraInstallArgs ...string) framework.Installatio
output, err := framework.InstallGatewayAPI(cfg.gwAPIVersion)
Expect(err).ToNot(HaveOccurred(), string(output))

if cfg.infoLogLevel {
output, err = framework.InstallNGF(installCfg, extraInstallArgs...)
Expect(err).ToNot(HaveOccurred(), string(output))
} else {
output, err = framework.InstallNGFDebugLevel(installCfg, extraInstallArgs...)
Expect(err).ToNot(HaveOccurred(), string(output))
if cfg.debugLogLevel {
extraInstallArgs = append(
extraInstallArgs,
"--set", "nginxGateway.config.logging.level=debug",
)
}

output, err = framework.InstallNGF(installCfg, extraInstallArgs...)
Expect(err).ToNot(HaveOccurred(), string(output))

return installCfg
}

Expand Down Expand Up @@ -267,10 +269,11 @@ func getDefaultSetupCfg() setupConfig {
localChartPath = filepath.Join(basepath, "charts/nginx-gateway-fabric")

return setupConfig{
releaseName: releaseName,
chartPath: localChartPath,
gwAPIVersion: *gatewayAPIVersion,
deploy: true,
releaseName: releaseName,
chartPath: localChartPath,
gwAPIVersion: *gatewayAPIVersion,
deploy: true,
debugLogLevel: true,
}
}

Expand Down
11 changes: 6 additions & 5 deletions tests/suite/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() {
teardown(releaseName)

cfg := setupConfig{
releaseName: releaseName,
chartPath: "oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric",
gwAPIVersion: *gatewayAPIPrevVersion,
deploy: true,
nfr: true,
releaseName: releaseName,
chartPath: "oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric",
gwAPIVersion: *gatewayAPIPrevVersion,
deploy: true,
nfr: true,
debugLogLevel: true,
}
setup(cfg, "--values", valuesFile)

Expand Down

0 comments on commit fb9a17f

Please sign in to comment.