Skip to content

Commit

Permalink
chore: integration test stability (#432)
Browse files Browse the repository at this point in the history
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- Absorbs test module changes (using symbolic links for integration
tests)

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

Fixes #425 

### Notes
<!-- any additional notes for this PR -->

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->

### How to test
<!-- if applicable, add testing instructions under this section -->

---------

Signed-off-by: Skye Gill <[email protected]>
  • Loading branch information
skyerus authored Feb 24, 2023
1 parent 6192ac8 commit 5a6a5d5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
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

0 comments on commit 5a6a5d5

Please sign in to comment.