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

chore: integration test stability #432

Merged
Merged
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
31 changes: 23 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ jobs:
outputs: type=docker,dest=${{ github.workspace }}/flagd-local.tar
tags: flagd-local:test

- name: Load & run flagd image
run: |
docker load --input ${{ github.workspace }}/flagd-local.tar
docker run -d -p 8013:8013 -v ${{ github.workspace }}/test-harness/testing-flags.json:/testing-flags.json flagd-local:test start -f file:/testing-flags.json

- name: Integration tests
run: make integration-test

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
Expand All @@ -140,3 +132,26 @@ jobs:
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2
with:
sarif_file: "trivy-results.sarif"

integration-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
submodules: recursive

- name: Setup go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Build flagd binary
run: make build

- name: Run flagd binary in background
run: ./flagd start -f file:${{ github.workspace }}/test-harness/symlink_testing-flags.json &

- name: Run tests
run: make integration-test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build:
go build -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o flagd
test:
go test -race -covermode=atomic -cover -short ./pkg/... -coverprofile=coverage.out
integration-test: # dependent on: docker run -p 8013:8013 -v $PWD/test-harness/testing-flags.json:/testing-flags.json ghcr.io/open-feature/flagd:latest start -f file:/testing-flags.json
integration-test: # dependent on: ./flagd start -f file:test-harness/symlink_testing-flags.json
go test -cover ./tests/integration $(ARGS)
cd test-harness; git restore testing-flags.json # reset testing-flags.json
run:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang/mock v1.6.0
github.com/mattn/go-colorable v0.1.13
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.7
github.com/open-feature/go-sdk-contrib/tests/flagd v1.1.0
github.com/open-feature/go-sdk-contrib/tests/flagd v1.2.0
github.com/open-feature/open-feature-operator v0.2.28
github.com/open-feature/schemas v0.2.8
github.com/prometheus/client_golang v1.14.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.7 h1:0s8reX/EfCNV37P
github.com/open-feature/go-sdk-contrib/providers/flagd v0.1.7/go.mod h1:dHB0hsYykZ1Un+CdnWErqLqUQswUADIvDg2VwDLx7gs=
github.com/open-feature/go-sdk-contrib/tests/flagd v1.1.0 h1:lM+7hfFVwUxQPOyJ9rXn2UR4sCAfOQJKtCU29pU/B+4=
github.com/open-feature/go-sdk-contrib/tests/flagd v1.1.0/go.mod h1:zw/xpuDy9ziBEKVA1t4VoQtzFc80btAAQCiZkX6y9oQ=
github.com/open-feature/go-sdk-contrib/tests/flagd v1.2.0 h1:PBCaJIK6fb5+27m+yBEmjIkLRJ+yZx72mHjcrcy73+Y=
github.com/open-feature/go-sdk-contrib/tests/flagd v1.2.0/go.mod h1:zw/xpuDy9ziBEKVA1t4VoQtzFc80btAAQCiZkX6y9oQ=
github.com/open-feature/open-feature-operator v0.2.28 h1:qzzVq8v9G7aXO7luocO/wQCGnTJjtcQh75mDOqjnFxo=
github.com/open-feature/open-feature-operator v0.2.28/go.mod h1:bQncVK7hvhj5QStPwexxQ1aArPwox2Y1vWrVei/qIFg=
github.com/open-feature/schemas v0.2.8 h1:oA75hJXpOd9SFgmNI2IAxWZkwzQPUDm7Jyyh3q489wM=
Expand Down
2 changes: 1 addition & 1 deletion test-harness
4 changes: 2 additions & 2 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ make build
```
then run the `flagd` binary
```
./flagd start -f file:test-harness/testing-flags.json
./flagd start -f file:test-harness/symlink_testing-flags.json
```
and finally run
```
Expand All @@ -35,7 +35,7 @@ make build
```
then run the `flagd` binary with tls configuration
```
./flagd start -f file:test-harness/testing-flags.json -c ./localhost.crt -k ./localhost.key
./flagd start -f file:test-harness/symlink_testing-flags.json -c ./localhost.crt -k ./localhost.key
```
finally, either run the tests with an explicit path to the certificate:
```
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/caching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
"github.com/cucumber/godog"
)

const flagConfigurationPath = "../../test-harness/testing-flags.json"
const (
flagConfigurationPath = "../../test-harness/symlink_testing-flags.json"
flagConfigurationTargetFilePath = "../../test-harness/testing-flags.json"
flagConfigurationMutatedPath = "../../test-harness/mutated-testing-flags.json"
)

func TestCaching(t *testing.T) {
if testing.Short() {
Expand All @@ -27,7 +31,8 @@ func TestCaching(t *testing.T) {
providerOptions = []flagd.ProviderOption{flagd.WithTLS(certPath)}
}

initializeCachingScenario, err := integration.InitializeCachingScenario(flagConfigurationPath, providerOptions...)
initializeCachingScenario, err := integration.InitializeCachingScenario(
flagConfigurationTargetFilePath, flagConfigurationPath, flagConfigurationMutatedPath, providerOptions...)
if err != nil {
t.Fatal(err)
}
Expand Down