Skip to content

Commit e6b3cfb

Browse files
Swopxvzf
authored andcommitted
fix: add DelayLeaseAssignmentBy management in e2e tests
1 parent 9022d61 commit e6b3cfb

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

e2e/config_test.go

+14-12
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ var _ = Describe("Config", Ordered, func() {
2020
cfg, _ = configHelper.LoadDefaultConfig()
2121
Expect(cfg).To(Equal(&latest.ServerConfig{Repositories: []*latest.GithubRepositoryConfig{
2222
{
23-
Owner: config.DefaultConfigRepoOwner,
24-
Name: config.DefaultConfigRepoName,
25-
BaseRef: config.DefaultConfigRepoBaseRef,
26-
StabilizeDuration: config.DefaultConfigRepoStabilizeDurationSeconds,
27-
ExpectedRequestCount: config.DefaultConfigRepoExpectedRequestCount,
28-
TTL: config.DefaultConfigRepoTTLSeconds,
23+
Owner: config.DefaultConfigRepoOwner,
24+
Name: config.DefaultConfigRepoName,
25+
BaseRef: config.DefaultConfigRepoBaseRef,
26+
StabilizeDuration: config.DefaultConfigRepoStabilizeDurationSeconds,
27+
ExpectedRequestCount: config.DefaultConfigRepoExpectedRequestCount,
28+
TTL: config.DefaultConfigRepoTTLSeconds,
29+
DelayLeaseAssignmentBy: config.DefaultConfigRepoDelayAssignmentCount,
2930
},
3031
}}))
3132

@@ -36,12 +37,13 @@ var _ = Describe("Config", Ordered, func() {
3637
)
3738
Expect(cfg).To(Equal(&latest.ServerConfig{Repositories: []*latest.GithubRepositoryConfig{
3839
{
39-
Owner: config.DefaultConfigRepoOwner,
40-
Name: "another-repo",
41-
BaseRef: "develop",
42-
StabilizeDuration: 3,
43-
ExpectedRequestCount: config.DefaultConfigRepoExpectedRequestCount,
44-
TTL: config.DefaultConfigRepoTTLSeconds,
40+
Owner: config.DefaultConfigRepoOwner,
41+
Name: "another-repo",
42+
BaseRef: "develop",
43+
StabilizeDuration: 3,
44+
ExpectedRequestCount: config.DefaultConfigRepoExpectedRequestCount,
45+
TTL: config.DefaultConfigRepoTTLSeconds,
46+
DelayLeaseAssignmentBy: config.DefaultConfigRepoDelayAssignmentCount,
4547
},
4648
}}))
4749
})

e2e/helpers/config/config.go

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
DefaultConfigRepoStabilizeDurationSeconds = 30
1717
DefaultConfigRepoExpectedRequestCount = 4
1818
DefaultConfigRepoTTLSeconds = 200
19+
DefaultConfigRepoDelayAssignmentCount = 0
1920
)
2021

2122
// baseConfigContent default YAML configuration used in GenerateDefaultConfig method
@@ -27,6 +28,7 @@ repositories:
2728
stabilize_duration_seconds: ${E2E_CONFIG_REPO_STABILIZE_DURATION_SECONDS}
2829
expected_request_count: ${E2E_CONFIG_REPO_EXPECTED_REQUEST_COUNT}
2930
ttl_seconds: ${E2E_CONFIG_REPO_TTL_SECONDS}
31+
delay_lease_assignment_by: ${E2E_CONFIG_REPO_DELAY_ASSIGNMENT_COUNT}
3032
`
3133

3234
type HelperOption func() map[string]string
@@ -85,6 +87,15 @@ func WithTTLSeconds(duration int) HelperOption {
8587
}
8688
}
8789

90+
// WithDelayAssignmentCount override the DelayAssignmentCount value used in base configuration YAML (i.e. don't use the default one)
91+
func WithDelayAssignmentCount(count int) HelperOption {
92+
return func() map[string]string {
93+
return map[string]string{
94+
"E2E_CONFIG_REPO_DELAY_ASSIGNMENT_COUNT": strconv.Itoa(count),
95+
}
96+
}
97+
}
98+
8899
type Helper struct {
89100
baseDir string
90101
setupEnvVars map[string]struct{}
@@ -156,6 +167,7 @@ func (h *Helper) LoadDefaultConfig(options ...HelperOption) (*latest.ServerConfi
156167
"E2E_CONFIG_REPO_STABILIZE_DURATION_SECONDS": strconv.Itoa(DefaultConfigRepoStabilizeDurationSeconds),
157168
"E2E_CONFIG_REPO_EXPECTED_REQUEST_COUNT": strconv.Itoa(DefaultConfigRepoExpectedRequestCount),
158169
"E2E_CONFIG_REPO_TTL_SECONDS": strconv.Itoa(DefaultConfigRepoTTLSeconds),
170+
"E2E_CONFIG_REPO_DELAY_ASSIGNMENT_COUNT": strconv.Itoa(DefaultConfigRepoDelayAssignmentCount),
159171
}
160172
}
161173

0 commit comments

Comments
 (0)