Skip to content

Commit

Permalink
Merge pull request #222 from ydb-platform/grpc_upgrade
Browse files Browse the repository at this point in the history
Upgrade YDB proto library to use grpc-java 1.59.x
  • Loading branch information
alex268 authored Jan 24, 2024
2 parents e55364b + 3592878 commit 9b42969
Show file tree
Hide file tree
Showing 16 changed files with 800 additions and 886 deletions.
4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<properties>
<ydb-auth-api.version>1.0.0</ydb-auth-api.version>
<ydb-proto-api.version>1.5.2</ydb-proto-api.version>
<ydb-proto-api.version>1.6.0</ydb-proto-api.version>
<yc-auth.version>2.1.1</yc-auth.version>
</properties>

Expand Down Expand Up @@ -115,7 +115,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.1</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
Expand Down
7 changes: 4 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- <dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
Expand All @@ -64,7 +64,8 @@
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-proto-extension</artifactId>
<scope>test</scope>
</dependency>
</dependency>-->

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
Expand All @@ -91,7 +92,7 @@
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<!-- Depends of grpc-netty version -->
<version>2.0.38.Final</version>
<version>2.0.61.Final</version>
</dependency>
</dependencies>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor,
applier.fail(Status.INTERNAL.withDescription("get token exception").withCause(ex));
}
}

@Override
public void thisUsesUnstableApi() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.time.Instant;
import java.util.concurrent.CompletableFuture;

import com.google.common.truth.Truth;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.Any;
import org.junit.Assert;
Expand Down Expand Up @@ -68,8 +67,8 @@ public void credentialsTest() {

// With correct credentitals
try (tech.ydb.auth.AuthIdentity identity = createAuth("user", "pass1")) {
Truth.assertThat(identity.getToken()).isEqualTo(token);
Truth.assertThat(identity.getToken()).isEqualTo(token);
Assert.assertEquals(token, identity.getToken());
Assert.assertEquals(token, identity.getToken());
}

// With incorrect password
Expand All @@ -78,13 +77,13 @@ public void credentialsTest() {
UnexpectedResultException.class,
() -> identity.getToken()
);
Truth.assertThat(ex.getStatus()).isEqualTo(unauthorized);
Assert.assertEquals(unauthorized, ex.getStatus());

UnexpectedResultException ex2 = Assert.assertThrows(
UnexpectedResultException.class,
() -> identity.getToken()
);
Truth.assertThat(ex2).isEqualTo(ex);
Assert.assertEquals(ex, ex2);
}
}

Expand Down Expand Up @@ -112,8 +111,8 @@ public void retriesTest() {

// With any credentials
try (tech.ydb.auth.AuthIdentity identity = createAuth("user", null)) {
Truth.assertThat(identity.getToken()).isEqualTo(token);
Truth.assertThat(identity.getToken()).isEqualTo(token);
Assert.assertEquals(token, identity.getToken());
Assert.assertEquals(token, identity.getToken());
}

Mockito.when(transport.unaryCall(
Expand All @@ -131,7 +130,7 @@ public void retriesTest() {
UnexpectedResultException.class,
() -> identity.getToken()
);
Truth.assertThat(ex.getStatus()).isEqualTo(overloaded);
Assert.assertEquals(overloaded, ex.getStatus());
}
}

Expand Down Expand Up @@ -159,24 +158,24 @@ public void refreshTokenTest() {

tech.ydb.auth.AuthIdentity identity = createAuth("user", "password");

Truth.assertThat(identity.getToken()).isEqualTo(token1);
Assert.assertEquals(token1, identity.getToken());

// When now is firstHour - token1 doesn't need to update
Mockito.when(clock.instant()).thenReturn(firstHour);
Truth.assertThat(identity.getToken()).isEqualTo(token1);
Truth.assertThat(identity.getToken()).isEqualTo(token1);
Assert.assertEquals(token1, identity.getToken());
Assert.assertEquals(token1, identity.getToken());

Mockito.when(clock.instant()).thenReturn(firstHour.plusMillis(5));
Truth.assertThat(identity.getToken()).isEqualTo(token1);
Truth.assertThat(identity.getToken()).isEqualTo(token2);
Assert.assertEquals(token1, identity.getToken());
Assert.assertEquals(token2, identity.getToken());

Mockito.when(clock.instant()).thenReturn(secondHour);
Truth.assertThat(identity.getToken()).isEqualTo(token2);
Truth.assertThat(identity.getToken()).isEqualTo(token2);
Assert.assertEquals(token2, identity.getToken());
Assert.assertEquals(token2, identity.getToken());

Mockito.when(clock.instant()).thenReturn(secondHour.plusMillis(10));
Truth.assertThat(identity.getToken()).isEqualTo(token2);
Truth.assertThat(identity.getToken()).isEqualTo(token3);
Assert.assertEquals(token2, identity.getToken());
Assert.assertEquals(token3, identity.getToken());

identity.close();
}
Expand All @@ -198,11 +197,11 @@ public void syncRefreshTokenTest() {

tech.ydb.auth.AuthIdentity identity = createAuth("user", "password");

Truth.assertThat(identity.getToken()).isEqualTo(token1);
Assert.assertEquals(token1, identity.getToken());

Mockito.when(clock.instant()).thenReturn(secondHour.plusMillis(1));
// token1 is already expired, use sync request to new token
Truth.assertThat(identity.getToken()).isEqualTo(token2);
Assert.assertEquals(token2, identity.getToken());

identity.close();
}
Expand Down
18 changes: 0 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

<slf4j.version>1.7.36</slf4j.version>

<google.truth.version>1.1.3</google.truth.version>
<junit.version>4.13.2</junit.version>
<junit5.version>5.9.3</junit5.version>
<log4j2.version>2.17.2</log4j2.version>
Expand Down Expand Up @@ -114,23 +113,6 @@
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${google.truth.version}</version>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-proto-extension</artifactId>
<version>${google.truth.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
10 changes: 0 additions & 10 deletions table/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-proto-extension</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
32 changes: 13 additions & 19 deletions table/src/test/java/tech/ydb/table/impl/DataQueryImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.Map;

import com.google.common.collect.ImmutableMap;
import com.google.common.truth.extensions.proto.ProtoTruth;
import org.junit.Assert;
import org.junit.Test;

import tech.ydb.proto.ValueProtos;
import tech.ydb.proto.ValueProtos.TypedValue;
import tech.ydb.table.query.Params;
Expand All @@ -12,11 +14,6 @@
import tech.ydb.table.values.Type;
import tech.ydb.table.values.proto.ProtoType;
import tech.ydb.table.values.proto.ProtoValue;
import org.junit.Test;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;


/**
Expand All @@ -38,40 +35,37 @@ public void params() {
.put("name", PrimitiveValue.newText("Jamel"))
.put("age", PrimitiveValue.newUint8((byte) 99));

assertThat(params.isEmpty())
.isFalse();
Assert.assertFalse(params.isEmpty());

Map<String, TypedValue> pb = params.toPb();
assertThat(pb).isNotEmpty();
Assert.assertFalse(pb.isEmpty());

ProtoTruth.assertThat(pb.get("name"))
.isEqualTo(TypedValue.newBuilder()
Assert.assertEquals(TypedValue.newBuilder()
.setType(ProtoType.getText())
.setValue(ProtoValue.fromText("Jamel"))
.build());
.build(), pb.get("name"));

ProtoTruth.assertThat(pb.get("age"))
.isEqualTo(TypedValue.newBuilder()
Assert.assertEquals(TypedValue.newBuilder()
.setType(ProtoType.getUint8())
.setValue(ProtoValue.fromUint8((byte) 99))
.build());
.build(), pb.get("age"));

// duplicate parameter
try {
params.put("name", PrimitiveValue.newText("Another Name"));
fail("expected exception was not thrown");
Assert.fail("expected exception was not thrown");
} catch (IllegalArgumentException e) {
assertEquals("duplicate parameter: name", e.getMessage());
Assert.assertEquals("duplicate parameter: name", e.getMessage());
}

// wrong type
try {
params.put("name", PrimitiveValue.newUint32(1));
fail("expected exception was not thrown");
Assert.fail("expected exception was not thrown");
} catch (IllegalArgumentException e) {
// TODO: do not check types anymore
// assertEquals("types mismatch: expected Utf8, got Uint32", e.getMessage());
assertEquals("duplicate parameter: name", e.getMessage());
Assert.assertEquals("duplicate parameter: name", e.getMessage());
}
}
}
Loading

0 comments on commit 9b42969

Please sign in to comment.