Skip to content

Commit 1359170

Browse files
committed
fixup: remove test and add gherkin tests - detected an issue
Signed-off-by: Simon Schrottner <[email protected]>
1 parent ec10de5 commit 1359170

File tree

8 files changed

+21
-115
lines changed

8 files changed

+21
-115
lines changed

providers/flagd/e2e/config_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e
22

33
import (
44
"context"
5+
"strings"
56
"testing"
67

78
"github.com/cucumber/godog"
@@ -18,21 +19,17 @@ type configTestCase struct {
1819
// TestConfiguration runs all configuration test scenarios using table-driven tests
1920
func TestConfiguration(t *testing.T) {
2021
testCases := []configTestCase{
21-
{
22-
name: "All",
23-
tags: "",
24-
},
2522
{
2623
name: "RPC",
27-
tags: "@rpc",
24+
tags: "@rpc && ~@forbidden",
2825
},
2926
{
3027
name: "InProcess",
31-
tags: "@in-process",
28+
tags: "@in-process && ~@forbidden",
3229
},
3330
{
3431
name: "File",
35-
tags: "@file",
32+
tags: "@file && ~@forbidden",
3633
},
3734
}
3835

@@ -44,6 +41,12 @@ func TestConfiguration(t *testing.T) {
4441

4542
testframework.InitializeConfigScenario(sc)
4643
sc.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
44+
options := make([]testframework.ProviderOption, 1)
45+
options[0] = testframework.ProviderOption{
46+
Option: "resolver",
47+
ValueType: "string",
48+
Value: strings.ToLower(tc.name),
49+
}
4750
state := &testframework.TestState{
4851
EnvVars: make(map[string]string),
4952
EvalContext: make(map[string]interface{}),

providers/flagd/e2e/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestFileProviderE2E(t *testing.T) {
4141

4242
// Run tests with file-specific tags, focusing on core evaluation scenarios
4343
// Skip complex connection-related and synchronization scenarios for file provider
44-
tags := "@file && ~@reconnect && ~@sync && ~@grace && ~@events && ~@unixsocket && ~@metadata"
44+
tags := "@file && ~@reconnect && ~@sync && ~@grace && ~@events && ~@unixsocket && ~@metadata && ~@forbidden"
4545

4646
if err := runner.RunGherkinTestsWithSubtests(t, featurePaths, tags); err != nil {
4747
t.Fatalf("Gherkin tests failed: %v", err)

providers/flagd/e2e/inprocess_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestInProcessProviderE2E(t *testing.T) {
2626
}
2727

2828
// Run tests with in-process specific tags
29-
tags := "@in-process && ~@unixsocket && ~@metadata && ~@customCert && ~@contextEnrichment && ~@sync-payload"
29+
tags := "@in-process && ~@unixsocket && ~@metadata && ~@customCert && ~@contextEnrichment && ~@sync-payload && ~@forbidden"
3030

3131
if err := runner.RunGherkinTestsWithSubtests(t, featurePaths, tags); err != nil {
3232
t.Fatalf("Gherkin tests failed: %v", err)

providers/flagd/e2e/rpc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestRPCProviderE2E(t *testing.T) {
2626
}
2727

2828
// Run tests with RPC-specific tags - exclude unimplemented scenarios
29-
tags := "@rpc && ~@unixsocket && ~@targetURI && ~@sync && ~@metadata && ~@grace && ~@customCert && ~@caching"
29+
tags := "@rpc && ~@unixsocket && ~@targetURI && ~@sync && ~@metadata && ~@grace && ~@customCert && ~@caching && ~@forbidden"
3030

3131
if err := runner.RunGherkinTestsWithSubtests(t, featurePaths, tags); err != nil {
3232
t.Fatalf("Gherkin tests failed: %v", err)

providers/flagd/pkg/configuration.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ func NewProviderConfiguration(opts []ProviderOption) (*ProviderConfiguration, er
9999
opt(providerConfiguration)
100100
}
101101

102+
providerConfiguration.updatePortFromEnvVar()
103+
102104
configureProviderConfiguration(providerConfiguration)
105+
103106
err := validateProviderConfiguration(providerConfiguration)
104107

105108
return providerConfiguration, err
@@ -199,9 +202,6 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() {
199202
}
200203
}
201204

202-
// Parse port after resolver is known to handle FLAGD_SYNC_PORT for in-process resolver
203-
cfg.updatePortFromEnvVar()
204-
205205
if offlinePath := os.Getenv(flagdOfflinePathEnvironmentVariableName); offlinePath != "" {
206206
cfg.OfflineFlagSourcePath = offlinePath
207207
}
@@ -232,6 +232,10 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() {
232232
// For in-process resolver, FLAGD_SYNC_PORT takes priority over FLAGD_PORT (backwards compatibility).
233233
// For rpc resolver, only FLAGD_PORT is used.
234234
func (cfg *ProviderConfiguration) updatePortFromEnvVar() {
235+
if cfg.Port != 0 {
236+
// Port is already set, no need to update from env var
237+
return
238+
}
235239
var portS string
236240
var envVarName string
237241

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package flagd
22

33
import (
4-
"os"
54
"testing"
6-
7-
"github.com/go-logr/logr"
85
)
96

107
func TestConfigureProviderConfigurationInProcessWithOfflineFile(t *testing.T) {
@@ -67,100 +64,3 @@ func TestValidateProviderConfigurationFileMissingData(t *testing.T) {
6764
t.Errorf("Error expected but check succeeded")
6865
}
6966
}
70-
71-
func TestUpdatePortFromEnvVarInProcessWithSyncPort(t *testing.T) {
72-
// given
73-
os.Setenv("FLAGD_SYNC_PORT", "9999")
74-
defer os.Unsetenv("FLAGD_SYNC_PORT")
75-
76-
providerConfiguration := &ProviderConfiguration{
77-
Resolver: inProcess,
78-
log: logr.Discard(),
79-
}
80-
81-
// when
82-
providerConfiguration.updatePortFromEnvVar()
83-
84-
// then
85-
if providerConfiguration.Port != 9999 {
86-
t.Errorf("incorrect Port, expected %v, got %v", 9999, providerConfiguration.Port)
87-
}
88-
}
89-
90-
func TestUpdatePortFromEnvVarInProcessWithLegacyPort(t *testing.T) {
91-
// given - for backwards compatibility, FLAGD_PORT should work for in-process
92-
os.Setenv("FLAGD_PORT", "8888")
93-
defer os.Unsetenv("FLAGD_PORT")
94-
95-
providerConfiguration := &ProviderConfiguration{
96-
Resolver: inProcess,
97-
log: logr.Discard(),
98-
}
99-
100-
// when
101-
providerConfiguration.updatePortFromEnvVar()
102-
103-
// then
104-
if providerConfiguration.Port != 8888 {
105-
t.Errorf("incorrect Port, expected %v, got %v", 8888, providerConfiguration.Port)
106-
}
107-
}
108-
109-
func TestUpdatePortFromEnvVarInProcessSyncPortPriority(t *testing.T) {
110-
// given - FLAGD_SYNC_PORT takes priority over FLAGD_PORT
111-
os.Setenv("FLAGD_SYNC_PORT", "9999")
112-
os.Setenv("FLAGD_PORT", "8888")
113-
defer os.Unsetenv("FLAGD_SYNC_PORT")
114-
defer os.Unsetenv("FLAGD_PORT")
115-
116-
providerConfiguration := &ProviderConfiguration{
117-
Resolver: inProcess,
118-
log: logr.Discard(),
119-
}
120-
121-
// when
122-
providerConfiguration.updatePortFromEnvVar()
123-
124-
// then
125-
if providerConfiguration.Port != 9999 {
126-
t.Errorf("incorrect Port, expected %v, got %v", 9999, providerConfiguration.Port)
127-
}
128-
}
129-
130-
func TestUpdatePortFromEnvVarRpcWithPort(t *testing.T) {
131-
// given - RPC resolver uses FLAGD_PORT
132-
os.Setenv("FLAGD_PORT", "8888")
133-
defer os.Unsetenv("FLAGD_PORT")
134-
135-
providerConfiguration := &ProviderConfiguration{
136-
Resolver: rpc,
137-
log: logr.Discard(),
138-
}
139-
140-
// when
141-
providerConfiguration.updatePortFromEnvVar()
142-
143-
// then
144-
if providerConfiguration.Port != 8888 {
145-
t.Errorf("incorrect Port, expected %v, got %v", 8888, providerConfiguration.Port)
146-
}
147-
}
148-
149-
func TestUpdatePortFromEnvVarRpcIgnoresSyncPort(t *testing.T) {
150-
// given - RPC resolver should NOT use FLAGD_SYNC_PORT
151-
os.Setenv("FLAGD_SYNC_PORT", "9999")
152-
defer os.Unsetenv("FLAGD_SYNC_PORT")
153-
154-
providerConfiguration := &ProviderConfiguration{
155-
Resolver: rpc,
156-
log: logr.Discard(),
157-
}
158-
159-
// when
160-
providerConfiguration.updatePortFromEnvVar()
161-
162-
// then - port should remain 0 (unset) since FLAGD_PORT is not set
163-
if providerConfiguration.Port != 0 {
164-
t.Errorf("incorrect Port, expected %v, got %v", 0, providerConfiguration.Port)
165-
}
166-
}

providers/flagd/pkg/service/in_process/service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ func (i *InProcess) processSyncData(data isync.DataSync) {
322322
return
323323
}
324324

325-
i.logger.Info("staletimer stop")
326325
// Stop stale timer - we've successfully received and processed data
327326
i.staleTimer.stop()
328327

0 commit comments

Comments
 (0)