Skip to content

Commit bc24feb

Browse files
authored
test(perfcheck): use compatible rolling upgrade source (#490)
Signed-off-by: Roel de Cort <roel.decort@adfinis.com>
1 parent 9552584 commit bc24feb

5 files changed

Lines changed: 119 additions & 14 deletions

File tree

hack/perfcheck/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ func defaultOptions(mode string) options {
140140
),
141141
OpenBaoVersion: envOrDefault("PERF_OPENBAO_VERSION", "2.5.4"),
142142
OpenBaoImage: envOrDefault("PERF_OPENBAO_IMAGE", "openbao/openbao:2.5.4"),
143-
UpgradeFromVersion: envOrDefault("PERF_UPGRADE_FROM_VERSION", "2.4.4"),
144-
UpgradeFromImage: envOrDefault("PERF_UPGRADE_FROM_IMAGE", "openbao/openbao:2.4.4"),
143+
UpgradeFromVersion: envOrDefault("PERF_UPGRADE_FROM_VERSION", "2.5.3"),
144+
UpgradeFromImage: envOrDefault("PERF_UPGRADE_FROM_IMAGE", "openbao/openbao:2.5.3"),
145145
UpgradeToVersion: envOrDefault("PERF_UPGRADE_TO_VERSION", "2.5.4"),
146146
UpgradeToImage: envOrDefault("PERF_UPGRADE_TO_IMAGE", "openbao/openbao:2.5.4"),
147147
APIServerCIDR: envOrDefault("PERF_API_SERVER_CIDR", "10.96.0.0/12"),

hack/perfcheck/main_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@ func TestFinalizeOptionsRejectsInvalidTenantChurnCount(t *testing.T) {
4949
t.Fatalf("expected tenant-churn-count validation error")
5050
}
5151
}
52+
53+
func TestDefaultRollingUpgradeSourceUsesPatchUpgrade(t *testing.T) {
54+
t.Setenv("PERF_UPGRADE_FROM_VERSION", "")
55+
t.Setenv("PERF_UPGRADE_FROM_IMAGE", "")
56+
57+
opts := defaultOptions("verify")
58+
if opts.UpgradeFromVersion != "2.5.3" {
59+
t.Fatalf("UpgradeFromVersion = %q, want 2.5.3", opts.UpgradeFromVersion)
60+
}
61+
if opts.UpgradeFromImage != "openbao/openbao:2.5.3" {
62+
t.Fatalf("UpgradeFromImage = %q, want openbao/openbao:2.5.3", opts.UpgradeFromImage)
63+
}
64+
}

mk/development.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ PERF_BACKUP_EXECUTOR_IMAGE ?= openbao-backup:dev
435435
PERF_UPGRADE_EXECUTOR_IMAGE ?= openbao-upgrade:dev
436436
PERF_OPENBAO_VERSION ?= 2.5.4
437437
PERF_OPENBAO_IMAGE ?= openbao/openbao:2.5.4
438-
PERF_UPGRADE_FROM_VERSION ?= 2.4.4
439-
PERF_UPGRADE_FROM_IMAGE ?= openbao/openbao:2.4.4
438+
PERF_UPGRADE_FROM_VERSION ?= 2.5.3
439+
PERF_UPGRADE_FROM_IMAGE ?= openbao/openbao:2.5.3
440440
PERF_UPGRADE_TO_VERSION ?= 2.5.4
441441
PERF_UPGRADE_TO_IMAGE ?= openbao/openbao:2.5.4
442442
PERF_API_SERVER_CIDR ?= 10.96.0.0/12

test/perf/native.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
openbaov1alpha1 "github.com/dc-tec/openbao-operator/api/v1alpha1"
3333
"github.com/dc-tec/openbao-operator/internal/platform/constants"
34+
platformsemver "github.com/dc-tec/openbao-operator/internal/platform/semver"
3435
portopenbao "github.com/dc-tec/openbao-operator/internal/port/openbao"
3536
)
3637

@@ -701,28 +702,36 @@ func (n *nativeScenarioContext) buildCluster(
701702
Network: &openbaov1alpha1.NetworkConfig{
702703
APIServerCIDR: n.opts.APIServerCIDR,
703704
},
704-
Observability: n.workloadObservability(),
705+
Observability: n.workloadObservability(version),
705706
DeletionPolicy: openbaov1alpha1.DeletionPolicyDeleteAll,
706707
},
707708
}
708709
}
709710

710-
func (n *nativeScenarioContext) workloadObservability() *openbaov1alpha1.ObservabilityConfig {
711+
func (n *nativeScenarioContext) workloadObservability(version string) *openbaov1alpha1.ObservabilityConfig {
711712
if n.opts.ExistingClusterContext != "" {
712713
return nil
713714
}
715+
metrics := &openbaov1alpha1.MetricsConfig{
716+
Enabled: true,
717+
ScrapeProfile: "Active",
718+
}
719+
if metricsOnlyListenerSupported(version) {
720+
metrics.MetricsOnlyListener = &openbaov1alpha1.MetricsOnlyListenerConfig{
721+
Enabled: boolPtr(true),
722+
UnauthenticatedMetricsAccess: boolPtr(true),
723+
}
724+
}
714725
return &openbaov1alpha1.ObservabilityConfig{
715-
Metrics: &openbaov1alpha1.MetricsConfig{
716-
Enabled: true,
717-
ScrapeProfile: "Active",
718-
MetricsOnlyListener: &openbaov1alpha1.MetricsOnlyListenerConfig{
719-
Enabled: boolPtr(true),
720-
UnauthenticatedMetricsAccess: boolPtr(true),
721-
},
722-
},
726+
Metrics: metrics,
723727
}
724728
}
725729

730+
func metricsOnlyListenerSupported(version string) bool {
731+
ok, err := platformsemver.AtLeast(version, 2, 5, 0)
732+
return err == nil && ok
733+
}
734+
726735
func boolPtr(value bool) *bool {
727736
return &value
728737
}

test/perf/native_test.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,89 @@ func TestNativeSelfInitRequestsUseJSONPayload(t *testing.T) {
7676
}
7777
}
7878

79+
func TestWorkloadObservabilityMetricsOnlyListenerIsVersionAware(t *testing.T) {
80+
t.Parallel()
81+
82+
tests := []struct {
83+
name string
84+
version string
85+
existingContext string
86+
wantConfig bool
87+
wantListener bool
88+
}{
89+
{
90+
name: "pre 2.5 omits metrics only listener",
91+
version: "2.4.4",
92+
wantConfig: true,
93+
wantListener: false,
94+
},
95+
{
96+
name: "2.5 enables metrics only listener",
97+
version: "2.5.0",
98+
wantConfig: true,
99+
wantListener: true,
100+
},
101+
{
102+
name: "patch upgrade source keeps metrics only listener",
103+
version: "2.5.3",
104+
wantConfig: true,
105+
wantListener: true,
106+
},
107+
{
108+
name: "invalid version omits metrics only listener",
109+
version: "custom",
110+
wantConfig: true,
111+
wantListener: false,
112+
},
113+
{
114+
name: "existing cluster leaves observability unmanaged",
115+
version: "2.5.4",
116+
existingContext: "kind-existing",
117+
wantConfig: false,
118+
wantListener: false,
119+
},
120+
}
121+
122+
for _, tt := range tests {
123+
t.Run(tt.name, func(t *testing.T) {
124+
t.Parallel()
125+
126+
native := &nativeScenarioContext{
127+
opts: Config{ExistingClusterContext: tt.existingContext},
128+
}
129+
got := native.workloadObservability(tt.version)
130+
if !tt.wantConfig {
131+
if got != nil {
132+
t.Fatalf("workloadObservability(%q) = %#v, want nil", tt.version, got)
133+
}
134+
return
135+
}
136+
if got == nil || got.Metrics == nil {
137+
t.Fatalf("workloadObservability(%q) missing metrics config: %#v", tt.version, got)
138+
}
139+
if got.Metrics.Enabled != true {
140+
t.Fatalf("metrics enabled = %v, want true", got.Metrics.Enabled)
141+
}
142+
if got.Metrics.ScrapeProfile != "Active" {
143+
t.Fatalf("scrape profile = %q, want Active", got.Metrics.ScrapeProfile)
144+
}
145+
listener := got.Metrics.MetricsOnlyListener
146+
if !tt.wantListener {
147+
if listener != nil {
148+
t.Fatalf("metrics only listener = %#v, want nil", listener)
149+
}
150+
return
151+
}
152+
if listener == nil || listener.Enabled == nil || !*listener.Enabled {
153+
t.Fatalf("metrics only listener not enabled: %#v", listener)
154+
}
155+
if listener.UnauthenticatedMetricsAccess == nil || !*listener.UnauthenticatedMetricsAccess {
156+
t.Fatalf("unauthenticated metrics access not enabled: %#v", listener)
157+
}
158+
})
159+
}
160+
}
161+
79162
func TestPhaseMeasurements(t *testing.T) {
80163
t.Parallel()
81164

0 commit comments

Comments
 (0)