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

Test java provider before any release #586

Merged
merged 8 commits into from
Mar 21, 2023
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
28 changes: 19 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
time: "04:00"
open-pull-requests-limit: 30
labels:
- "dependencies"
- "automerge"
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
time: "04:00"
open-pull-requests-limit: 30
labels:
- "dependencies"
- "automerge"

- package-ecosystem: maven
directory: "/openfeature/provider_tests/java-integration-tests"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 30
labels:
- "dependencies"
- "automerge"
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@ on:
types: [ published ]

jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '^1.18.0'
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.8.2
- run: make vendor
- run: make provider-tests
goreleaser:
needs: integration-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ tmp/
# Local dev files
goff-proxy.yaml
flags.yaml

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ swagger: ## Build swagger documentation
test: ## Run the tests of the project
$(GOTEST) -v -race ./...

provider-tests:
./openfeature/provider_tests/integration_tests.sh

coverage: ## Run the tests of the project and export the coverage
$(GOTEST) -cover -covermode=count -coverprofile=coverage.cov.tmp ./... \
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov
Expand Down
6 changes: 6 additions & 0 deletions openfeature/provider_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!flags.yaml
!goff-proxy.yaml

# Java
*.class
target/
134 changes: 134 additions & 0 deletions openfeature/provider_tests/flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
bool_targeting_match:
variations:
Default: false
"False": false
"True": true
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
disabled_bool:
variations:
Default: false
"False": false
"True": true
defaultRule:
percentage:
"False": 0
"True": 100
disable: true
disabled_float:
variations:
Default: 103.25
"False": 101.25
"True": 100.25
defaultRule:
percentage:
"False": 0
"True": 100
disable: true
disabled_int:
variations:
Default: 103
"False": 101
"True": 100
defaultRule:
percentage:
"False": 0
"True": 100
disable: true
disabled_interface:
variations:
Default:
test: default
"False":
test: "false"
"True":
test: test1
test2: false
test3: 123.3
test4: 1
defaultRule:
percentage:
"False": 0
"True": 100
disable: true
disabled_string:
variations:
Default: CC0002
"False": CC0001
"True": CC0000
defaultRule:
percentage:
"False": 0
"True": 100
disable: true
double_key:
variations:
Default: 103.25
"False": 101.25
"True": 100.25
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
integer_key:
variations:
Default: 103
"False": 101
"True": 100
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
object_key:
variations:
Default:
test: default
"False":
test: "false"
"True":
test: test1
test2: false
test3: 123.3
test4: 1
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
string_key:
variations:
Default: CC0002
"False": CC0001
"True": CC0000
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
string_key_with_version:
variations:
Default: CC0002
"False": CC0001
"True": CC0000
targeting:
- query: email eq "[email protected]"
variation: "True"
defaultRule:
percentage:
"False": 0
"True": 100
9 changes: 9 additions & 0 deletions openfeature/provider_tests/goff-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
listen: 1031
pollingInterval: 1000
startWithRetrieverError: false
retriever:
kind: file
path: ./openfeature/provider_tests/flags.yaml
exporter:
kind: log
enableSwagger: true
18 changes: 18 additions & 0 deletions openfeature/provider_tests/integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

make build-relayproxy
./out/bin/relayproxy --config $(pwd)/openfeature/provider_tests/goff-proxy.yaml &

# Waiting for the relay proxy to be ready
NB_ITERATION=10
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:1031/health)" != "200" ]]; do
sleep 1
NB_ITERATION=$((NB_ITERATION - 1))
if [ ${NB_ITERATION} == "0" ]; then echo "ERROR: relay-proxy is not ready" && exit 123; fi
done

# Launch java integration tests
mvn -f $(pwd)/openfeature/provider_tests/java-integration-tests/pom.xml test

# Kill all process launched by the script (here the relay-proxy)
kill -KILL %1
45 changes: 45 additions & 0 deletions openfeature/provider_tests/java-integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>java-integration-tests</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.openfeature</groupId>
<artifactId>sdk</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>dev.openfeature.contrib.providers</groupId>
<artifactId>go-feature-flag</artifactId>
<version>0.2.3</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</project>
Loading