-
Notifications
You must be signed in to change notification settings - Fork 163
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
Convert GraphQL v2 to Quarkus #1980
Conversation
5f2aac7
to
feddbc0
Compare
apis/sgv2-graphqlapi/src/main/java/io/stargate/sgv2/graphql/web/resources/GraphqlCache.java
Show resolved
Hide resolved
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
||
public abstract class GraphqlIntegrationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, this relies on inheritance, which is a bit underwhelming. Requests are executed through the bridge.
I would prefer to port CqlSessionExtension
from the v1 codebase, but it's not yet clear to me if/how a Junit extension can interact with a Quarkus test extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should be able to have the CqlSessionExtension
here as well, that communicates over the bridge or maybe even directly over the CQL port.. For this to happen, we need to expose host
and port
of the target CQL port in the integration tests.. Then you can use Cassandra driver to push needed cql statements..
I might be working on this while you are on holiday.. Let's sync once you are back..
518cb1c
to
908e72c
Compare
79ada51
to
688e18e
Compare
e7836c0
to
5d23b3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried my best to give as much feedback as possible.. I think we should bring to the merging state as soon as possible and then have tickets for future improvements..
General notes:
- the api CI workflow was not extended to include
sgv2-graphql
for the integration tests.. If you disable fixed token in the int-tests, then you can to add your service to be docker-based tested - can we get the set of tickets for improvements, for example removing
StargateBridgeClient
, async fetchers if possible and going into reactive programming model, etc (you know better) - nit: banner setup is missing
returns raw JSON responses. See [GraphqlClient] and its subclasses. | ||
|
||
If you add new tests, please favor the lightweight approach. | ||
<!-- TODO integration tests --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to introduce a similar guides for building the app, building the docker, int tests, etc as we do for the docs-api.. I guess it would be more a copy & paste.. I think the readme should provide all the information possible.. What about configuration guide as in the docs api?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of copy-pasting, maybe it should move to the top-level readme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me, we can even move this to a separate task to speed merging this in. It's low priority anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should prioritize merging to the v.2.0.0
branch. That will make it easier to work on the documentation across all 3 of the APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #2052.
apis/sgv2-graphqlapi/src/main/java/io/stargate/sgv2/graphql/schema/FileSupport.java
Show resolved
Hide resolved
return DEFAULT_PARAMETERS.toBuilder() | ||
.setConsistency(consistencyLevel) | ||
.setSerialConsistency(serialConsistencyLevel) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be read from the configuration now? at least the default values? I am talking about consistency:
stargate/apis/sgv2-quarkus-common/CONFIGURATION.md
Lines 54 to 61 in 03d2bde
### Queries configuration | |
*Configuration mapping for the query properties, defined by [QueriesConfig.java](src/main/java/io/stargate/sgv2/api/common/config/QueriesConfig.java).* | |
| Property | Type | Default | Description | | |
|-----------------------------------------------|----------|----------------|----------------------------------------------------------------------------------| | |
| `stargate.queries.consistency.schema-changes` | `String` | `LOCAL_QUORUM` | Consistency level to use for C* queries that are performing the schema changes. | | |
| `stargate.queries.consistency.writes` | `String` | `LOCAL_QUORUM` | Consistency level to use for C* queries that are inserting or updating the data. | | |
| `stargate.queries.consistency.reads` | `String` | `LOCAL_QUORUM` | Consistency level to use for C* queries that are reading the data. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up ticket: #2053
apis/sgv2-graphqlapi/src/main/java/io/stargate/sgv2/graphql/web/resources/AdminResource.java
Show resolved
Hide resolved
apis/sgv2-graphqlapi/src/main/java/io/stargate/sgv2/graphql/web/resources/AdminResource.java
Show resolved
Hide resolved
* <p>Subclasses must be annotated with {@link io.quarkus.test.junit.QuarkusIntegrationTest}. | ||
*/ | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public abstract class CqlEnabledIntegrationTestBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool stuff, can be used in docs api as well.. Do you think in future having CqlSession
like stuff as annotation would make sense? Or this is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be turned into a test resource, now that the contact point info is passed as system properties. The only requirement is that StargateTestResource
needs to execute first, do you know if there is a way to enforce a reliable order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok apparently there is QuarkusTestResourceLifecycleManager.order()
, I'll give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrmm actually a test resource might not be the best fit:
These resources are started before the first test is run, and are closed at the end of the test suite.
There's no class-level lifecycle that would allow us to create the session and a dedicated keyspace before each test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I was more thinking about Junit5 extension..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up ticket: #2054
...qlapi/src/test/java/io/stargate/sgv2/graphql/integration/cqlfirst/ApolloIntegrationTest.java
Outdated
Show resolved
Hide resolved
...aphqlapi/src/test/java/io/stargate/sgv2/graphql/integration/util/GraphqlIntegrationTest.java
Show resolved
Hide resolved
apis/sgv2-graphqlapi/src/test/java/io/stargate/sgv2/graphql/integration/util/GraphqlClient.java
Outdated
Show resolved
Hide resolved
Tried to answer to all the comments.. I'll do a final review on Thursday and we can hopefully merge then. Since all the unit tests are green now, we should enable the int tests:
|
@@ -10,6 +10,7 @@ | |||
<properties> | |||
<quarkus.container-image.group>stargateio</quarkus.container-image.group> | |||
<quarkus.container-image.name>graphqlapi</quarkus.container-image.name> | |||
<quarkus.container-image.tag>v${project.version}</quarkus.container-image.tag> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our existing code prepends a "v" before the version, whereas Quarkus doesn't. I don't mind either way but if we drop it we'll have to adapt the coordinator and docker-compose scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this to docs as well.. the release process correctly sets the tag with v
, so this would be only for local builds and keeping that docker-compose stuff working
mem_limit: 2G | ||
environment: | ||
- STARGATE_BRIDGE_HOST=coordinator | ||
- STARGATE_BRIDGE_PORT=8091 | ||
- STARGATE_GRAPHQL_PORT=9080 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't need to customize the port since the API is in its own container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can still set the exposed port with -Dquarkus.http.port
if needed..
@@ -75,11 +75,10 @@ services: | |||
networks: | |||
- stargate | |||
ports: | |||
- 9080:9080 | |||
- 8085:8080 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the host port because I happen to have something already running on 9080 on my laptop.
Also it aligns better with what is used in the rest of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had one more look, I would say I have no more comments.. Open discussions should be resolved, tests should be green and we can merge this when @olim7t decides to do it.
Great work +1
- STARGATE_BRIDGE_HOST=coordinator | ||
- STARGATE_BRIDGE_PORT=8091 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can also just set QUARKUS_GRPC_CLIENTS_BRIDGE_HOST
here and remove those env vars from docker compose completely..
Main changes:
GraphqlResourceBase
and subclasses: use injection to pass the bridge and GraphqlCache, adapt multipart handling code for Quarkus.GraphqlCache
: use Quarkus config for enableDefaultKeyspaceEverything else is pretty much a copy-paste of the existing
sgv2-graphqlapi
, with a few changes to the imports. Note that fetcher implementations still rely on the synchronous methods ofStargateBridgeClient
; with the async/reactive bridge it would now be possible to make all fetchers async, but I consider this beyond the scope of this PR, see #421.TODO:
stargate.graphql.enable-playground
to the config (how do we condition the inclusion of a REST resource at runtime?)testing
sgv2-graphqlapi
at the root of the repoGraphqlResourceBase.executeAsync
)