Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 929274e

Browse files
prepare 5.7.0 release (#257)
1 parent 0fe982c commit 929274e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3124
-108
lines changed

.circleci/config.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
default: false
6161
docker:
6262
- image: <<parameters.docker-image>>
63+
environment:
64+
TEST_HARNESS_PARAMS: -junit /home/circleci/junit/contract-tests-junit.xml
6365
steps:
6466
- checkout
6567
- run: cp gradle.properties.example gradle.properties
@@ -78,12 +80,18 @@ jobs:
7880
./gradlew jacocoTestReport
7981
mkdir -p coverage/
8082
cp -r build/reports/jacoco/test/* ./coverage
83+
- run: mkdir -p ~/junit/
8184
- run:
8285
name: Save test results
83-
command: |
84-
mkdir -p ~/junit/
85-
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
86+
command: find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
8687
when: always
88+
89+
- run: make build-contract-tests
90+
- run:
91+
command: make start-contract-test-service
92+
background: true
93+
- run: make run-contract-tests
94+
8795
- store_test_results:
8896
path: ~/junit
8997
- store_artifacts:

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ To build the SDK and run all unit tests:
4242
./gradlew test
4343
```
4444

45+
To run the SDK contract test suite in Linux (see [`contract-tests/README.md`](./contract-tests/README.md)):
46+
47+
```bash
48+
make contract-tests
49+
```
50+
4551
### Benchmarks
4652

4753
The project in the `benchmarks` subdirectory uses [JMH](https://openjdk.java.net/projects/code-tools/jmh/) to generate performance metrics for the SDK. This is run as a CI job, and can also be run manually by running `make` within `benchmarks` and then inspecting `build/reports/jmh`.

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
build:
3+
./gradlew jar
4+
5+
clean:
6+
./gradlew clean
7+
8+
test:
9+
./gradlew test
10+
11+
TEMP_TEST_OUTPUT=/tmp/sdk-test-service.log
12+
13+
build-contract-tests:
14+
@cd contract-tests && ../gradlew installDist
15+
16+
start-contract-test-service:
17+
@contract-tests/service/build/install/service/bin/service
18+
19+
start-contract-test-service-bg:
20+
@echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)"
21+
@make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &
22+
23+
run-contract-tests:
24+
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v1.0.0/downloader/run.sh \
25+
| VERSION=v1 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end $(TEST_HARNESS_PARAMS)" sh
26+
27+
contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests
28+
29+
.PHONY: build-contract-tests start-contract-test-service start-contract-test-service-bg run-contract-tests contract-tests

build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ext.versions = [
7272
"gson": "2.8.9",
7373
"guava": "30.1-jre",
7474
"jackson": "2.11.2",
75-
"launchdarklyJavaSdkCommon": "1.2.2",
75+
"launchdarklyJavaSdkCommon": "1.3.0",
7676
"okhttp": "4.8.1", // specify this for the SDK build instead of relying on the transitive dependency from okhttp-eventsource
7777
"okhttpEventsource": "2.3.2",
7878
"slf4j": "1.7.21",
@@ -108,7 +108,6 @@ ext.versions = [
108108
// Jackson in "libraries.optional" because we need to generate OSGi optional import
109109
// headers for it.
110110
libraries.internal = [
111-
"com.launchdarkly:launchdarkly-java-sdk-common:${versions.launchdarklyJavaSdkCommon}",
112111
"commons-codec:commons-codec:${versions.commonsCodec}",
113112
"com.google.code.gson:gson:${versions.gson}",
114113
"com.google.guava:guava:${versions.guava}",
@@ -117,6 +116,10 @@ libraries.internal = [
117116
"org.yaml:snakeyaml:${versions.snakeyaml}",
118117
]
119118

119+
libraries.common = [
120+
"com.launchdarkly:launchdarkly-java-sdk-common:${versions.launchdarklyJavaSdkCommon}",
121+
]
122+
120123
// Add dependencies to "libraries.external" that are exposed in our public API, or that have
121124
// global state that must be shared between the SDK and the caller. Putting dependencies
122125
// here has the following effects:
@@ -176,7 +179,7 @@ configurations {
176179

177180
dependencies {
178181
implementation libraries.internal
179-
api libraries.external
182+
api libraries.external, libraries.common
180183
testImplementation libraries.test, libraries.internal, libraries.external
181184
optional libraries.optional
182185

contract-tests/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SDK contract test service
2+
3+
This directory contains an implementation of the cross-platform SDK testing protocol defined by https://github.com/launchdarkly/sdk-test-harness. See that project's `README` for details of this protocol, and the kinds of SDK capabilities that are relevant to the contract tests. This code should not need to be updated unless the SDK has added or removed such capabilities.
4+
5+
To run these tests locally, run `make contract-tests` from the SDK project root directory. This downloads the correct version of the test harness tool automatically.
6+
7+
Or, to test against an in-progress local version of the test harness, run `make start-contract-test-service` from the SDK project root directory; then, in the root directory of the `sdk-test-harness` project, build the test harness and run it from the command line.

contract-tests/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gnsp.disableApplyOnlyOnRootProjectEnforcement=true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
plugins {
3+
id "java"
4+
id "application"
5+
}
6+
7+
repositories {
8+
mavenCentral()
9+
maven { url "https://oss.sonatype.org/content/groups/public/" }
10+
}
11+
12+
allprojects {
13+
sourceCompatibility = 1.8
14+
targetCompatibility = 1.8
15+
}
16+
17+
archivesBaseName = "java-sdk-test-service"
18+
19+
application {
20+
mainClassName = "sdktest.TestService"
21+
}
22+
23+
ext.versions = [
24+
"gson": "2.7",
25+
"logback": "1.1.3",
26+
"okhttp": "4.5.0",
27+
"testHelpers": "1.1.0"
28+
]
29+
30+
configurations {
31+
deps.extendsFrom(implementation)
32+
}
33+
34+
dependencies {
35+
implementation project(":sdk")
36+
implementation "ch.qos.logback:logback-classic:${versions.logback}"
37+
implementation "com.google.code.gson:gson:${versions.gson}"
38+
implementation "com.squareup.okhttp3:okhttp:${versions.okhttp}"
39+
implementation "com.launchdarkly:test-helpers:${versions.testHelpers}"
40+
}

contract-tests/service/settings.gradle

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package sdktest;
2+
3+
import com.launchdarkly.sdk.server.interfaces.BigSegmentStore;
4+
import com.launchdarkly.sdk.server.interfaces.BigSegmentStoreFactory;
5+
import com.launchdarkly.sdk.server.interfaces.BigSegmentStoreTypes.Membership;
6+
import com.launchdarkly.sdk.server.interfaces.BigSegmentStoreTypes.StoreMetadata;
7+
import com.launchdarkly.sdk.server.interfaces.ClientContext;
8+
9+
import java.io.IOException;
10+
11+
import sdktest.CallbackRepresentations.BigSegmentStoreGetMembershipParams;
12+
import sdktest.CallbackRepresentations.BigSegmentStoreGetMembershipResponse;
13+
import sdktest.CallbackRepresentations.BigSegmentStoreGetMetadataResponse;
14+
15+
public class BigSegmentStoreFixture implements BigSegmentStore, BigSegmentStoreFactory {
16+
private final CallbackService service;
17+
18+
public BigSegmentStoreFixture(CallbackService service) {
19+
this.service = service;
20+
}
21+
22+
@Override
23+
public void close() throws IOException {
24+
service.close();
25+
}
26+
27+
@Override
28+
public Membership getMembership(String userHash) {
29+
BigSegmentStoreGetMembershipParams params = new BigSegmentStoreGetMembershipParams();
30+
params.userHash = userHash;
31+
BigSegmentStoreGetMembershipResponse resp =
32+
service.post("/getMembership", params, BigSegmentStoreGetMembershipResponse.class);
33+
return new Membership() {
34+
@Override
35+
public Boolean checkMembership(String segmentRef) {
36+
return resp.values == null ? null : resp.values.get(segmentRef);
37+
}
38+
};
39+
}
40+
41+
@Override
42+
public StoreMetadata getMetadata() {
43+
BigSegmentStoreGetMetadataResponse resp =
44+
service.post("/getMetadata", null, BigSegmentStoreGetMetadataResponse.class);
45+
return new StoreMetadata(resp.lastUpToDate);
46+
}
47+
48+
@Override
49+
public BigSegmentStore createBigSegmentStore(ClientContext context) {
50+
return this;
51+
}
52+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package sdktest;
2+
3+
import java.util.Map;
4+
5+
public abstract class CallbackRepresentations {
6+
public static class BigSegmentStoreGetMetadataResponse {
7+
Long lastUpToDate;
8+
}
9+
10+
public static class BigSegmentStoreGetMembershipParams {
11+
String userHash;
12+
}
13+
14+
public static class BigSegmentStoreGetMembershipResponse {
15+
Map<String, Boolean> values;
16+
}
17+
}

0 commit comments

Comments
 (0)