Skip to content

Commit 65bf635

Browse files
authored
test: update e2e tests (#1452)
Signed-off-by: Pradeep <[email protected]>
1 parent 8c6d91d commit 65bf635

File tree

8 files changed

+119
-4
lines changed

8 files changed

+119
-4
lines changed

.github/workflows/build.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,9 @@ jobs:
147147
-f file:${{ github.workspace }}/test-harness/flags/zero-flags.json \
148148
-f file:${{ github.workspace }}/test-harness/flags/edge-case-flags.json &
149149
150+
- name: Run envoy proxy in background
151+
run: |
152+
envoy -c ./test/integration/config/envoy.yaml &
153+
150154
- name: Run evaluation test suite
151155
run: go clean -testcache && go test -cover ./test/integration

schemas

test-harness

test/integration/config/envoy.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
static_resources:
2+
listeners:
3+
- name: local-envoy
4+
address:
5+
socket_address:
6+
address: 0.0.0.0
7+
port_value: 9211
8+
filter_chains:
9+
- filters:
10+
- name: envoy.filters.network.http_connection_manager
11+
typed_config:
12+
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
13+
stat_prefix: ingress_http
14+
access_log:
15+
- name: envoy.access_loggers.stdout
16+
typed_config:
17+
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
18+
http_filters:
19+
- name: envoy.filters.http.router
20+
typed_config:
21+
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
22+
route_config:
23+
name: local_route
24+
virtual_hosts:
25+
- name: local_service
26+
domains:
27+
- "flagd-sync.service"
28+
routes:
29+
- match:
30+
prefix: "/"
31+
grpc: {}
32+
route:
33+
cluster: local-sync-service
34+
35+
clusters:
36+
- name: local-sync-service
37+
type: LOGICAL_DNS
38+
# Comment out the following line to test on v6 networks
39+
dns_lookup_family: V4_ONLY
40+
http2_protocol_options: {}
41+
load_assignment:
42+
cluster_name: local-sync-service
43+
endpoints:
44+
- lb_endpoints:
45+
- endpoint:
46+
address:
47+
socket_address:
48+
address: sync-service
49+
port_value: 8015

test/integration/evaluation_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,34 @@ func TestEvaluation(t *testing.T) {
4343
t.Fatal("non-zero status returned, failed to run evaluation tests")
4444
}
4545
}
46+
47+
func TestEvaluationUsingEnvoy(t *testing.T) {
48+
if testing.Short() {
49+
t.Skip()
50+
}
51+
52+
flag.Parse()
53+
54+
name := "evaluation_envoy.feature"
55+
providerOptions := []flagd.ProviderOption{
56+
flagd.WithTargetUri("envoy://localhost:9211/flagd-sync.service"),
57+
}
58+
59+
testSuite := godog.TestSuite{
60+
Name: name,
61+
TestSuiteInitializer: integration.InitializeTestSuite(func() openfeature.FeatureProvider {
62+
return flagd.NewProvider(providerOptions...)
63+
}),
64+
ScenarioInitializer: integration.InitializeEvaluationScenario,
65+
Options: &godog.Options{
66+
Format: "pretty",
67+
Paths: []string{"../../spec/specification/assets/gherkin/evaluation.feature"},
68+
TestingT: t, // Testing instance that will run subtests.
69+
Strict: true,
70+
},
71+
}
72+
73+
if testSuite.Run() != 0 {
74+
t.Fatal("non-zero status returned, failed to run evaluation tests")
75+
}
76+
}

test/integration/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.21.4
77
require (
88
github.com/cucumber/godog v0.14.0
99
github.com/open-feature/go-sdk v1.10.0
10-
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.22
10+
github.com/open-feature/go-sdk-contrib/providers/flagd v0.2.3
1111
github.com/open-feature/go-sdk-contrib/tests/flagd v1.4.1
1212
)
1313

test/integration/json_evaluator_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,34 @@ func TestJsonEvaluator(t *testing.T) {
3838
t.Fatal("non-zero status returned, failed to run evaluation tests")
3939
}
4040
}
41+
42+
func TestJsonEvaluatorUsingEnvoy(t *testing.T) {
43+
if testing.Short() {
44+
t.Skip()
45+
}
46+
47+
flag.Parse()
48+
49+
name := "flagd-json-evaluator-envoy.feature"
50+
providerOptions := []flagd.ProviderOption{
51+
flagd.WithTargetUri("envoy://localhost:9211/flagd-sync.service"),
52+
}
53+
54+
testSuite := godog.TestSuite{
55+
Name: name,
56+
TestSuiteInitializer: integration.InitializeFlagdJsonTestSuite(func() openfeature.FeatureProvider {
57+
return flagd.NewProvider(providerOptions...)
58+
}),
59+
ScenarioInitializer: integration.InitializeFlagdJsonScenario,
60+
Options: &godog.Options{
61+
Format: "pretty",
62+
Paths: []string{"../../test-harness/gherkin/flagd-json-evaluator.feature"},
63+
TestingT: t, // Testing instance that will run subtests.
64+
Strict: true,
65+
},
66+
}
67+
68+
if testSuite.Run() != 0 {
69+
t.Fatal("non-zero status returned, failed to run evaluation tests")
70+
}
71+
}

0 commit comments

Comments
 (0)