frankgh commented on code in PR #188: URL: https://github.com/apache/cassandra-sidecar/pull/188#discussion_r1947915667
########## integration-tests/src/integrationTest/org/apache/cassandra/sidecar/routes/SchemaHandlerIntegrationTest.java: ########## @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.sidecar.routes; + +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import io.vertx.ext.web.client.predicate.ResponsePredicate; +import org.apache.cassandra.sidecar.common.response.SchemaResponse; +import org.apache.cassandra.sidecar.testing.SharedClusterSidecarIntegrationTestBase; + +import static org.apache.cassandra.testing.utils.AssertionUtils.getBlocking; +import static org.assertj.core.api.Assertions.assertThat; + +class SchemaHandlerIntegrationTest extends SharedClusterSidecarIntegrationTestBase Review Comment: what a difference! This will help with CI, we should find more opportunities to migrate **Before:** ``` $ ./gradlew --stacktrace :server:integrationTestLightWeight --tests org.apache.cassandra.sidecar.routes.SchemaHandlerIntegrationTest > Task :server:integrationTestLightWeight SchemaHandlerIntegrationTest > schemaHandlerWithReservedKeywordKeyspace(VertxTestContext) > schemaHandlerWithReservedKeywordKeyspace(VertxTestContext): 5.1 STARTED SchemaHandlerIntegrationTest > schemaHandlerWithReservedKeywordKeyspace(VertxTestContext) > schemaHandlerWithReservedKeywordKeyspace(VertxTestContext): 5.1 PASSED SchemaHandlerIntegrationTest > schemaHandlerNoKeyspace(VertxTestContext) > schemaHandlerNoKeyspace(VertxTestContext): 5.1 STARTED SchemaHandlerIntegrationTest > schemaHandlerNoKeyspace(VertxTestContext) > schemaHandlerNoKeyspace(VertxTestContext): 5.1 PASSED SchemaHandlerIntegrationTest > schemaHandlerWithCaseSensitiveKeyspace(VertxTestContext) > schemaHandlerWithCaseSensitiveKeyspace(VertxTestContext): 5.1 STARTED SchemaHandlerIntegrationTest > schemaHandlerWithCaseSensitiveKeyspace(VertxTestContext) > schemaHandlerWithCaseSensitiveKeyspace(VertxTestContext): 5.1 PASSED SchemaHandlerIntegrationTest > schemaHandlerKeyspaceDoesNotExist(VertxTestContext) > schemaHandlerKeyspaceDoesNotExist(VertxTestContext): 5.1 STARTED SchemaHandlerIntegrationTest > schemaHandlerKeyspaceDoesNotExist(VertxTestContext) > schemaHandlerKeyspaceDoesNotExist(VertxTestContext): 5.1 PASSED SchemaHandlerIntegrationTest > schemaHandlerWithKeyspace(VertxTestContext) > schemaHandlerWithKeyspace(VertxTestContext): 5.1 STARTED SchemaHandlerIntegrationTest > schemaHandlerWithKeyspace(VertxTestContext) > schemaHandlerWithKeyspace(VertxTestContext): 5.1 PASSED BUILD SUCCESSFUL in 1m 16s 28 actionable tasks: 1 executed, 27 up-to-date ``` **After:** ``` $ ./gradlew --stacktrace :integration-tests:integrationTestLightWeight --tests org.apache.cassandra.sidecar.routes.SchemaHandlerIntegrationTest > Task :integration-tests:integrationTestLightWeight SchemaHandlerIntegrationTest > testSchemaHandlerWithReservedKeywordKeyspace() STARTED SchemaHandlerIntegrationTest > testSchemaHandlerWithReservedKeywordKeyspace() PASSED SchemaHandlerIntegrationTest > testSchemaHandlerWithCaseSensitiveKeyspace() STARTED SchemaHandlerIntegrationTest > testSchemaHandlerWithCaseSensitiveKeyspace() PASSED SchemaHandlerIntegrationTest > testListKeyspaces() STARTED SchemaHandlerIntegrationTest > testListKeyspaces() PASSED SchemaHandlerIntegrationTest > testSchemaHandlerWithKeyspace() STARTED SchemaHandlerIntegrationTest > testSchemaHandlerWithKeyspace() PASSED SchemaHandlerIntegrationTest > testSchemaHandlerKeyspaceDoesNotExist() STARTED SchemaHandlerIntegrationTest > testSchemaHandlerKeyspaceDoesNotExist() PASSED BUILD SUCCESSFUL in 19s 21 actionable tasks: 10 executed, 11 up-to-date ``` ########## server/src/test/integration/org/apache/cassandra/sidecar/testing/IntegrationTestBase.java: ########## @@ -274,49 +286,31 @@ protected void testWithClient(boolean waitForCluster, } } - protected void testWithClientBlocking(boolean waitForCluster, - Consumer<WebClient> tester) - { - CassandraAdapterDelegate delegate = sidecarTestContext.instancesMetadata() - .instanceFromId(1) - .delegate(); - - assertThat(delegate).isNotNull(); - if (delegate.isNativeUp() || !waitForCluster) - { - tester.accept(client); - } - else - { - vertx.eventBus().localConsumer(ON_CASSANDRA_CQL_READY.address(), (Message<JsonObject> message) -> { - if (message.body().getInteger("cassandraInstanceId") == 1) - { - tester.accept(client); - } - }); - } - - } - protected void createTestKeyspace() { createTestKeyspace(ImmutableMap.of(DATA_CENTER_PREFIX + 1, 1)); } protected void createTestKeyspace(Map<String, Integer> rf) + { + createKeyspace(TEST_KEYSPACE, rf); + } + + protected void createKeyspace(String keyspaceName, Map<String, Integer> rf) { int attempts = 1; ArrayList<Throwable> thrown = new ArrayList<>(5); while (attempts <= 5) { try { - sidecarTestContext.refreshInstancesMetadata(); - Session session = maybeGetSession(); - session.execute("CREATE KEYSPACE " + IF_NOT_EXISTS + " " + TEST_KEYSPACE - + " WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', " + generateRfString(rf) + " };"); + ResultSet rs = session.execute("CREATE KEYSPACE " + IF_NOT_EXISTS + " " + keyspaceName Review Comment: tests should try to use `cluster.schemaChange` instead, but I think we should make an effort to migrate integration tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

