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

[8n02RETv] Fixes the cluster setup for the trigger tests #322

Merged
merged 5 commits into from
Feb 10, 2023

Conversation

ncordon
Copy link
Collaborator

@ncordon ncordon commented Feb 8, 2023

What

Solves some cluster tests flakiness.

The setup we had was to wait for every instance to return 200 in the db/neo4j/cluster/available endpoint. But in 5.x neo4j is not allocated by default in every instance. This PR forces it to be allocated in every instance and reshapes the trigger tests so they test for what they are supposed to. This is a temporary hack, we should revisit the setup, because we never reshaped it from 4.x (causal clusters) to 5.x (autonomoous cluster).

Why

The cluster tests were broken in general and I had realized because there was some flakiness in the CI related to these tests. An instance was always succeeding to start, the one with neo4j allocated in it and if that instance happened to have a be a system leader as well, it was failing for the drop trigger (because we cannot drop something we have not created and drop would return empty results rather than something).

@@ -56,7 +56,7 @@ dependencies {
api group: 'org.hdrhistogram', name: 'HdrHistogram', version: '2.1.9'
api group: 'org.apache.commons', name: 'commons-collections4', version: '4.2'
// We need this to avoid seeing SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" on startup
api group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.36'
api group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.0'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this change the cluster containers complain the logger is too old and they don't log anything

@@ -31,7 +31,7 @@ public class TriggerClusterRoutingTest {
public static void setupCluster() {
cluster = TestContainerUtil
.createEnterpriseCluster( List.of(TestContainerUtil.ApocPackage.CORE),
3, 1,
3, 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't allocate a read replica. We weren't testing anything with the read replica anyway (because we were skipping it inside the tests) and read replicas have a different behaviour in 5.x anyway, so it was failing to start up

Comment on lines +61 to +67
final String addTrigger = "CALL apoc.trigger.add($name, 'RETURN 1', {})";
final String removeTrigger = "CALL apoc.trigger.remove($name)";
String triggerName = randomTriggerName();

succeedsInLeader(addTrigger, triggerName, DEFAULT_DATABASE_NAME);
succeedsInLeader(removeTrigger, triggerName, DEFAULT_DATABASE_NAME);
failsInFollowers(removeTrigger, triggerName, SYS_DB_NON_WRITER_ERROR, DEFAULT_DATABASE_NAME);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this reads much nicer than the previous tests, also checks that the remove does work in a LEADER, for what we need to actually add the trigger first.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it doesn't matter that it tries to remove an already removed trigger in the followers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, it would fail before actually doing that

@ncordon ncordon changed the title [NOID] Fixes the cluster setup for the trigger tests [8n02RETv] Fixes the cluster setup for the trigger tests Feb 8, 2023
@ncordon ncordon force-pushed the fixes-cluster-setup branch 3 times, most recently from 6c6dcd2 to 4011169 Compare February 8, 2023 15:43
Copy link
Contributor

@gem-neo4j gem-neo4j left a comment

Choose a reason for hiding this comment

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

LGTM, just a few comments, nothing major :) Looks like a nice tidy up as well!

Comment on lines +61 to +67
final String addTrigger = "CALL apoc.trigger.add($name, 'RETURN 1', {})";
final String removeTrigger = "CALL apoc.trigger.remove($name)";
String triggerName = randomTriggerName();

succeedsInLeader(addTrigger, triggerName, DEFAULT_DATABASE_NAME);
succeedsInLeader(removeTrigger, triggerName, DEFAULT_DATABASE_NAME);
failsInFollowers(removeTrigger, triggerName, SYS_DB_NON_WRITER_ERROR, DEFAULT_DATABASE_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it doesn't matter that it tries to remove an already removed trigger in the followers?

@ncordon ncordon merged commit 6e1f5e3 into dev Feb 10, 2023
@ncordon ncordon deleted the fixes-cluster-setup branch February 10, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dev team-cypher-surface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants