Skip to content

Commit

Permalink
Breaking changes for type removal (#132)
Browse files Browse the repository at this point in the history
* Adding support to test against unreleased OpenSearch

Signed-off-by: Vacha Shah <[email protected]>

* Upgrading OpenSearch version to 2.0.0-SNAPSHOT and Java version

Signed-off-by: Vacha Shah <[email protected]>

* Remove type mapping

Signed-off-by: Vacha Shah <[email protected]>

* Using snapshots from sonatype for 2.0 OpenSearch snapshot

Signed-off-by: Vacha Shah <[email protected]>

* Updating workflows and removing exists_type

Signed-off-by: Vacha Shah <[email protected]>

* Fixing integration tests

Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah authored Apr 1, 2022
1 parent 9348be9 commit 02a313f
Show file tree
Hide file tree
Showing 47 changed files with 77 additions and 2,546 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test-integration-unreleased.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Integration with Unreleased OpenSearch

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

env:
OPENSEARCH_VERSION: '2.0'

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 11 ]
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: opensearch-project/opensearch
ref: ${{ env.OPENSEARCH_VERSION }}
path: opensearch

- name: Assemble OpenSearch
run: |
cd opensearch
./gradlew assemble
# This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test.
# Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190
- name: Run Docker Image
run: |
docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test
sleep 90
- name: Checkout Java Client
uses: actions/checkout@v2
with:
path: opensearch-java

- name: Run Integration Test
run: |
cd opensearch-java
./gradlew clean integrationTest -Dhttps=false
22 changes: 9 additions & 13 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration
name: Integration with Released OpenSearch

on:
push:
Expand All @@ -15,33 +15,29 @@ jobs:
fail-fast: false
matrix:
entry:
- { opensearch_version: 1.0.0, java: 11 }
- { opensearch_version: 1.0.1, java: 11 }
- { opensearch_version: 1.1.0, java: 11 }
- { opensearch_version: 1.2.0, java: 11 }
- { opensearch_version: 1.2.1, java: 11 }
- { opensearch_version: 1.2.2, java: 11 }
- { opensearch_version: 1.2.3, java: 11 }
- { opensearch_version: 1.2.4, java: 11 }
- { opensearch_version: 1.3.0, java: 11 }
- { opensearch_version: "", java: 11 }
steps:
- name: Set up JDK ${{ matrix.entry.java }}
- name: Set up JDK ${{ matrix.java }}
if: ${{ matrix.entry.opensearch_version != ''}}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.entry.java }}

- name: Checkout Branch
if: ${{ matrix.entry.opensearch_version != ''}}
uses: actions/checkout@v2

- name: Run Docker
if: ${{ matrix.entry.opensearch_version != ''}}
run: |
docker-compose --project-directory .ci/opensearch build --build-arg OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }}
docker-compose --project-directory .ci/opensearch up -d
sleep 60
- name: Run Integration Test
if: ${{ matrix.entry.opensearch_version != ''}}
run: ./gradlew clean integrationTest

- name: Stop Docker
if: ${{ matrix.entry.opensearch_version != ''}}
run: |
docker-compose --project-directory .ci/opensearch down
docker-compose --project-directory .ci/opensearch down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ allprojects {
(File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")

repositories {
mavenCentral()
mavenLocal()
maven(url = "https://aws.oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}

Expand Down
3 changes: 2 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ dependencies {
}

repositories {
mavenCentral()
mavenLocal()
maven(url = "https://aws.oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
10 changes: 6 additions & 4 deletions java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import java.io.FileWriter

buildscript {
repositories {
mavenCentral()
mavenLocal()
maven(url = "https://aws.oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
}
Expand All @@ -55,8 +56,8 @@ checkstyle {
}

java {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11

withJavadocJar()
withSourcesJar()
Expand Down Expand Up @@ -122,13 +123,14 @@ val integrationTest = task<Test>("integrationTest") {

dependencies {

val opensearchVersion = "1.2.4"
val opensearchVersion = "2.0.0-alpha1-SNAPSHOT"
val jacksonVersion = "2.12.6"
val jacksonDatabindVersion = "2.12.6.1"

// Apache 2.0
implementation("org.opensearch.client", "opensearch-rest-client", opensearchVersion)
testImplementation("org.opensearch.test", "framework", opensearchVersion)
implementation("org.apache.logging.log4j", "log4j-core", "2.17.2")

// Apache 2.0
// https://search.maven.org/artifact/com.google.code.findbugs/jsr305
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public abstract class WriteResponseBase implements JsonpSerializable {

private final ShardStatistics shards;

@Nullable
private final String type;

private final long version;

@Nullable
Expand All @@ -81,7 +78,6 @@ protected WriteResponseBase(AbstractBuilder<?> builder) {
this.result = ApiTypeHelper.requireNonNull(builder.result, this, "result");
this.seqNo = ApiTypeHelper.requireNonNull(builder.seqNo, this, "seqNo");
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
this.type = builder.type;
this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version");
this.forcedRefresh = builder.forcedRefresh;

Expand Down Expand Up @@ -129,14 +125,6 @@ public final ShardStatistics shards() {
return this.shards;
}

/**
* API name: {@code _type}
*/
@Nullable
public final String type() {
return this.type;
}

/**
* Required - API name: {@code _version}
*/
Expand Down Expand Up @@ -180,11 +168,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("_shards");
this.shards.serialize(generator, mapper);

if (this.type != null) {
generator.writeKey("_type");
generator.write(this.type);

}
generator.writeKey("_version");
generator.write(this.version);

Expand All @@ -211,9 +194,6 @@ protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder

private ShardStatistics shards;

@Nullable
private String type;

private Long version;

@Nullable
Expand Down Expand Up @@ -274,14 +254,6 @@ public final BuilderT shards(Function<ShardStatistics.Builder, ObjectBuilder<Sha
return this.shards(fn.apply(new ShardStatistics.Builder()).build());
}

/**
* API name: {@code _type}
*/
public final BuilderT type(@Nullable String value) {
this.type = value;
return self();
}

/**
* Required - API name: {@code _version}
*/
Expand Down Expand Up @@ -312,7 +284,6 @@ protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupWriteRes
op.add(AbstractBuilder::result, Result._DESERIALIZER, "result");
op.add(AbstractBuilder::seqNo, JsonpDeserializer.longDeserializer(), "_seq_no");
op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards");
op.add(AbstractBuilder::type, JsonpDeserializer.stringDeserializer(), "_type");
op.add(AbstractBuilder::version, JsonpDeserializer.longDeserializer(), "_version");
op.add(AbstractBuilder::forcedRefresh, JsonpDeserializer.booleanDeserializer(), "forced_refresh");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public class BulkRequest extends RequestBase implements NdJsonpSerializable, Jso
@Nullable
private final Time timeout;

@Nullable
private final String type;

@Nullable
private final WaitForActiveShards waitForActiveShards;

Expand All @@ -116,7 +113,6 @@ private BulkRequest(Builder builder) {
this.requireAlias = builder.requireAlias;
this.routing = builder.routing;
this.timeout = builder.timeout;
this.type = builder.type;
this.waitForActiveShards = builder.waitForActiveShards;
this.operations = ApiTypeHelper.unmodifiableRequired(builder.operations, this, "operations");

Expand Down Expand Up @@ -224,16 +220,6 @@ public final Time timeout() {
return this.timeout;
}

/**
* Default document type for items which don't provide one
* <p>
* API name: {@code type}
*/
@Nullable
public final String type() {
return this.type;
}

/**
* Sets the number of shard copies that must be active before proceeding with
* the bulk operation. Defaults to 1, meaning the primary shard only. Set to
Expand Down Expand Up @@ -304,9 +290,6 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<B
@Nullable
private Time timeout;

@Nullable
private String type;

@Nullable
private WaitForActiveShards waitForActiveShards;

Expand Down Expand Up @@ -457,16 +440,6 @@ public final Builder timeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.timeout(fn.apply(new Time.Builder()).build());
}

/**
* Default document type for items which don't provide one
* <p>
* API name: {@code type}
*/
public final Builder type(@Nullable String value) {
this.type = value;
return this;
}

/**
* Sets the number of shard copies that must be active before proceeding with
* the bulk operation. Defaults to 1, meaning the primary shard only. Set to
Expand Down Expand Up @@ -559,14 +532,11 @@ public BulkRequest build() {
// Request path
request -> {
final int _index = 1 << 0;
final int _type = 1 << 1;

int propsSet = 0;

if (request.index() != null)
propsSet |= _index;
if (request.type() != null)
propsSet |= _type;

if (propsSet == 0) {
StringBuilder buf = new StringBuilder();
Expand All @@ -580,15 +550,6 @@ public BulkRequest build() {
buf.append("/_bulk");
return buf.toString();
}
if (propsSet == (_index | _type)) {
StringBuilder buf = new StringBuilder();
buf.append("/");
SimpleEndpoint.pathEncode(request.index, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.type, buf);
buf.append("/_bulk");
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

},
Expand Down
Loading

0 comments on commit 02a313f

Please sign in to comment.