Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update e2e tests #1452

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,9 @@ jobs:
-f file:${{ github.workspace }}/test-harness/flags/zero-flags.json \
-f file:${{ github.workspace }}/test-harness/flags/edge-case-flags.json &
- name: Run envoy proxy in background
run: |
envoy -c ./test/integration/config/envoy.yaml &
- name: Run evaluation test suite
run: go clean -testcache && go test -cover ./test/integration
2 changes: 1 addition & 1 deletion schemas
2 changes: 1 addition & 1 deletion test-harness
49 changes: 49 additions & 0 deletions test/integration/config/envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
static_resources:
listeners:
- name: local-envoy
address:
socket_address:
address: 0.0.0.0
port_value: 9211
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
access_log:
- name: envoy.access_loggers.stdout
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains:
- "flagd-sync.service"
routes:
- match:
prefix: "/"
grpc: {}
route:
cluster: local-sync-service

clusters:
- name: local-sync-service
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
http2_protocol_options: {}
load_assignment:
cluster_name: local-sync-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: sync-service
port_value: 8015
31 changes: 31 additions & 0 deletions test/integration/evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,34 @@ func TestEvaluation(t *testing.T) {
t.Fatal("non-zero status returned, failed to run evaluation tests")
}
}

func TestEvaluationUsingEnvoy(t *testing.T) {
if testing.Short() {
t.Skip()
}

flag.Parse()

name := "evaluation_envoy.feature"
providerOptions := []flagd.ProviderOption{
flagd.WithTargetUri("envoy://localhost:9211/flagd-sync.service"),
}

testSuite := godog.TestSuite{
Name: name,
TestSuiteInitializer: integration.InitializeTestSuite(func() openfeature.FeatureProvider {
return flagd.NewProvider(providerOptions...)
}),
ScenarioInitializer: integration.InitializeEvaluationScenario,
Options: &godog.Options{
Format: "pretty",
Paths: []string{"../../spec/specification/assets/gherkin/evaluation.feature"},
TestingT: t, // Testing instance that will run subtests.
Strict: true,
},
}

if testSuite.Run() != 0 {
t.Fatal("non-zero status returned, failed to run evaluation tests")
}
}
2 changes: 1 addition & 1 deletion test/integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.4
require (
github.com/cucumber/godog v0.14.0
github.com/open-feature/go-sdk v1.10.0
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.22
github.com/open-feature/go-sdk-contrib/providers/flagd v0.2.3
github.com/open-feature/go-sdk-contrib/tests/flagd v1.4.1
)

Expand Down
31 changes: 31 additions & 0 deletions test/integration/json_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,34 @@ func TestJsonEvaluator(t *testing.T) {
t.Fatal("non-zero status returned, failed to run evaluation tests")
}
}

func TestJsonEvaluatorUsingEnvoy(t *testing.T) {
if testing.Short() {
t.Skip()
}

flag.Parse()

name := "flagd-json-evaluator-envoy.feature"
providerOptions := []flagd.ProviderOption{
flagd.WithTargetUri("envoy://localhost:9211/flagd-sync.service"),
}

testSuite := godog.TestSuite{
Name: name,
TestSuiteInitializer: integration.InitializeFlagdJsonTestSuite(func() openfeature.FeatureProvider {
return flagd.NewProvider(providerOptions...)
}),
ScenarioInitializer: integration.InitializeFlagdJsonScenario,
Options: &godog.Options{
Format: "pretty",
Paths: []string{"../../test-harness/gherkin/flagd-json-evaluator.feature"},
TestingT: t, // Testing instance that will run subtests.
Strict: true,
},
}

if testSuite.Run() != 0 {
t.Fatal("non-zero status returned, failed to run evaluation tests")
}
}
Loading