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

Changes to have ddl and count profiles #785

Merged
merged 4 commits into from
Jan 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ public Uni<AsyncResultSet> executeRead(
.completionStage(cqlSessionCache.getSession().executeAsync(simpleStatement));
}

/**
* Execute count query with bound statement.
*
* @param simpleStatement - Simple statement with query and parameters. The table name used in the
* query must have keyspace prefixed.
* @return AsyncResultSet
*/
public Uni<AsyncResultSet> executeCount(SimpleStatement simpleStatement) {
simpleStatement =
simpleStatement
.setExecutionProfileName("count")
.setConsistencyLevel(operationsConfig.queriesConfig().consistency().reads());
return Uni.createFrom()
.completionStage(cqlSessionCache.getSession().executeAsync(simpleStatement));
}

/**
* Execute vector search query with bound statement.
*
Expand Down Expand Up @@ -117,6 +133,7 @@ public Uni<AsyncResultSet> executeSchemaChange(SimpleStatement boundStatement) {
.getSession()
.executeAsync(
boundStatement
.setExecutionProfileName("ddl")
.setIdempotent(true)
.setSerialConsistencyLevel(
operationsConfig.queriesConfig().consistency().schemaChanges())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private String extractPageStateFromResultSet(AsyncResultSet rSet) {
default Uni<CountResponse> countDocuments(
QueryExecutor queryExecutor, SimpleStatement simpleStatement) {
return queryExecutor
.executeRead(simpleStatement, Optional.empty(), 1)
.executeCount(simpleStatement)
.onItem()
.transform(
rSet -> {
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ datastax-java-driver {
show-stack-traces = true
}
}
basic.request.timeout = 10 seconds
basic.request.timeout = 20 seconds
profiles {
slow {
basic.request.timeout = 30 seconds
}

ddl {
basic.request.timeout = 30 seconds
}

count {
basic.request.timeout = 60 seconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds bit high (as does basic request timeout of 20 secs), but easy enough to change later on I suppose.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,10 @@ public void orderedDuplicateDocumentNoNamespace() {
"_id": "doc5",
"username": "user5"
}
]
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side effect of a previous merged PR. Need to refactor the test case.

"options" : {
"ordered" : true
}
}
}
""";
Expand Down Expand Up @@ -1188,8 +1191,7 @@ public void unordered() {
"_id": "doc5",
"username": "user5"
}
],
"options": { "ordered": false }
]
}
}
""";
Expand Down Expand Up @@ -1312,7 +1314,7 @@ public void withDifferentTypes() {
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.then()
.statusCode(200)
.body("status.insertedIds", contains("5", 5))
.body("status.insertedIds", containsInAnyOrder("5", 5))
.body("data", is(nullValue()))
.body("errors", is(nullValue()));

Expand Down Expand Up @@ -1398,7 +1400,7 @@ public void emptyOptionsAllowed() {
.post(CollectionResource.BASE_PATH, namespaceName, collectionName)
.then()
.statusCode(200)
.body("status.insertedIds", contains("doc4", "doc5"))
.body("status.insertedIds", containsInAnyOrder("doc4", "doc5"))
.body("data", is(nullValue()))
.body("errors", is(nullValue()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.stargate.sgv2.jsonapi.service.operation.model.impl;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -50,7 +48,7 @@ public void countWithNoFilter() {
AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null);
final AtomicInteger callCount = new AtomicInteger();
QueryExecutor queryExecutor = mock(QueryExecutor.class);
when(queryExecutor.executeRead(eq(stmt), any(), anyInt()))
when(queryExecutor.executeCount(eq(stmt)))
.then(
invocation -> {
callCount.incrementAndGet();
Expand Down Expand Up @@ -91,7 +89,7 @@ public void countWithDynamic() {
AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null);
final AtomicInteger callCount = new AtomicInteger();
QueryExecutor queryExecutor = mock(QueryExecutor.class);
when(queryExecutor.executeRead(eq(stmt), any(), anyInt()))
when(queryExecutor.executeCount(eq(stmt)))
.then(
invocation -> {
callCount.incrementAndGet();
Expand Down Expand Up @@ -141,7 +139,7 @@ public void countWithDynamicNoMatch() {
AsyncResultSet mockResults = new MockAsyncResultSet(COUNT_RESULT_COLUMNS, rows, null);
final AtomicInteger callCount = new AtomicInteger();
QueryExecutor queryExecutor = mock(QueryExecutor.class);
when(queryExecutor.executeRead(eq(stmt), any(), anyInt()))
when(queryExecutor.executeCount(eq(stmt)))
.then(
invocation -> {
callCount.incrementAndGet();
Expand Down Expand Up @@ -189,7 +187,7 @@ public void error() {
SimpleStatement stmt = SimpleStatement.newInstance(collectionReadCql);
final AtomicInteger callCount = new AtomicInteger();
QueryExecutor queryExecutor = mock(QueryExecutor.class);
when(queryExecutor.executeRead(eq(stmt), any(), anyInt()))
when(queryExecutor.executeCount(eq(stmt)))
.then(
invocation -> {
callCount.incrementAndGet();
Expand Down