-
Notifications
You must be signed in to change notification settings - Fork 52
CASSSIDECAR-204: Improve integration test stability #188
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
Conversation
b1a32c6 to
41a6fa9
Compare
Patch by Yifan Cai; Reviewed by TBD for CASSSIDECAR-204
41a6fa9 to
d8782aa
Compare
| Vertx vertx = sidecarServerInjector.getInstance(Vertx.class); | ||
| vertx.eventBus() | ||
| .localConsumer(SidecarServerEvents.ON_SIDECAR_SCHEMA_INITIALIZED.address(), msg -> sidecarSchemaReadyLatch.countDown()); |
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.
register the event consumer at the earliest. The original setup misses the event occasionally.
| import static org.apache.cassandra.testing.utils.AssertionUtils.getBlocking; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class SchemaHandlerIntegrationTest extends SharedClusterSidecarIntegrationTestBase |
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.
migrated, to speed up and to avoid flakiness.
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.
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
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 with you.
| @Override | ||
| protected void beforeServerStart() | ||
| { | ||
| vertx.eventBus().localConsumer(ON_ALL_CASSANDRA_CQL_READY.address(), allCassandraCqlReadyMessage::set); |
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.
Register the event consumer at the earliest to avoid missing events
| else if (upInstanceCount == 3) | ||
| { | ||
| assertThat(jmxConnectedInstances).containsExactly(1, 2, 3); | ||
| context.verify(() -> assertThat(jmxConnectedInstances).containsExactly(1, 2, 3)); |
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.
must wrap in the verify block to correctly fail the test if assertion fails. Otherwise, context/flag are not closed, and test gets stuck until timeout.
| CountDownLatch testStart = new CountDownLatch(1); | ||
| IUpgradeableInstance node = cluster.get(1); | ||
| AtomicReference<Throwable> nodetoolError = new AtomicReference<>(); | ||
| startAsync("Repairing node" + node.config().num(), |
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.
Changed the stream trigger from decommission to repair. The test also does not need bytebuddy to intercept, hence removing it.
We should avoid bytebuddy at the best, to avoid dependency on Cassandra's implementation details.
| * Note: Some related test classes are broken down to have a single test case to parallelize test execution and | ||
| * therefore limit the instance size required to run the tests from CircleCI as the in-jvm-dtests tests are memory bound | ||
| */ | ||
| @Tag("heavy") |
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 test is actually quite heavy.
| // array of nodeNums that are 1-based | ||
| private int[] instancesToManage = null; |
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.
it makes the Cassandra instances flexible. Now, one can choose to manage, instance 1 and 3.
| private Path serverKeystorePath(CertificateBundle ca, Path path, int totalNodes) throws Exception | ||
| { | ||
| CertificateBundle keystore = new CertificateBuilder() | ||
| .subject("CN=Apache Cassandra, OU=ssl_test, O=Unknown, L=Unknown, ST=Unknown, C=Unknown") | ||
| .addSanDnsName("localhost") | ||
| .addSanIpAddress("127.0.0.1") | ||
| .buildIssuedBy(ca); | ||
| CertificateBuilder builder = new CertificateBuilder(); | ||
| builder.subject("CN=Apache Cassandra, OU=ssl_test, O=Unknown, L=Unknown, ST=Unknown, C=Unknown") | ||
| .addSanDnsName("localhost"); | ||
| for (int i = 1; i <= totalNodes; i++) | ||
| { | ||
| builder.addSanIpAddress("127.0.0." + i); | ||
| } | ||
| CertificateBundle keystore = builder.buildIssuedBy(ca); |
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.
Allow contacting other hosts rather than 127.0.0.1 only.
| public ClusterLease clusterLease() | ||
| { | ||
| return new ClusterLease(ClusterLease.Ownership.CLAIMED); | ||
| } | ||
|
|
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.
remove the fake lease. It now runs the actual lease competition in every integration test.
frankgh
left a comment
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.
+1 Looks good to me. Left a minor comment
| import static org.apache.cassandra.testing.utils.AssertionUtils.getBlocking; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class SchemaHandlerIntegrationTest extends SharedClusterSidecarIntegrationTestBase |
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.
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
|
|
||
| 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 |
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.
tests should try to use cluster.schemaChange instead, but I think we should make an effort to migrate integration tests.
Patch by Yifan Cai; Reviewed by TBD for CASSSIDECAR-204