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

Fix var tests dev #2650

Merged
merged 7 commits into from
Mar 29, 2022
Merged

Fix var tests dev #2650

merged 7 commits into from
Mar 29, 2022

Conversation

conker84
Copy link
Collaborator

@conker84 conker84 commented Mar 18, 2022

Fix var tests dev.

  • Updated com.fasterxml.jackson.dataformat to fix some ExportCsvTest java.
  • Fixed trigger tests (see background-operations/triggers.adoc note)
  • Fixed Schemas enterprise tests (due to SHOW CONSTRAINTS YIELD createStatement instead of db. constraints(), with a different resutl)
  • Fixed Metric test
  • Removed unused jackson-databind

same as #2647 as @vga91 doesn't have the rights to push on neo4j-contrib repo

@conker84 conker84 requested a review from ncordon March 18, 2022 17:12
@conker84 conker84 mentioned this pull request Mar 18, 2022
@conker84
Copy link
Collaborator Author

@ncordon I pushed the code because @vga91 doesn't have the rights to push on neo4j-contrib repo

@conker84
Copy link
Collaborator Author

@ncordon the CI is green

@conker84
Copy link
Collaborator Author

@ncordon the CI is green after enabling the ignored test

Comment on lines -165 to +167
"FOR (galileo:`Galileo`) REQUIRE (galileo.`newton`, galileo.`tesla`) IS NODE KEY",
"FOR ( galileo:`Galileo` ) REQUIRE (galileo.`curie`) IS UNIQUE");
"FOR (n:`Galileo`) REQUIRE (n.`newton`, n.`tesla`) IS NODE KEY",
"FOR (n:`Galileo`) REQUIRE (n.`curie`) IS UNIQUE");
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why we had to change this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Because previously there was call db.constraints (), now there is SHOW CONSTRAINTS YIELD createStatement (line 160). The latter returns a different result.

Comment on lines +140 to +141
return (long) node.getProperty("txId", -1L) > -1L
&& (long) node.getProperty("txTime") > start;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between checking this and that the properties are not null (and have been assigned)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, in this case I left the previous assertions on lines 154 and 155:

assertEquals (true, (Long) ((Node) row.get ("f")). getProperty ("txId")> -1L);
assertEquals (true, (Long) ((Node) row.get ("f")). getProperty ("txTime")> start);

I just changed the test from "after" to "afterAsync" (by adding assertEventually as well).

I think that verifying only the existence of txId and txTime is not enough, I could get wrong results because, for example, the txTime is lower than the start one, or am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

But the node was created without properties in the first place, so if they are present, that should be enough to know the trigger was fired, isn't it?

Anyway, this is not a biggie

@@ -63,6 +63,17 @@ You can use these helper functions to extract nodes or relationships by label/re
| apoc.trigger.propertiesByKey($assignedNodeProperties,'key') | function to filter propertyEntries by property-key, to be used within a trigger statement with $assignedNode/RelationshipProperties and $removedNode/RelationshipProperties. Returns [{old,[new],key,node,relationship}]
|===

[WARNING]
====
Unlike Neo4j up to 4, with Neo4j 5 it's not possible to modify an entity created in phase: "after".
Copy link
Contributor

@ncordon ncordon Mar 25, 2022

Choose a reason for hiding this comment

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

The wording of this can be improved. I think here we mean we cannot modify the same node the trigger gets its information from? Cause otherwise I cannot explain this:

https://github.com/neo4j-contrib/neo4j-apoc-procedures/pull/2650/files#r835190507

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, maybe I should write this clearer. I mean entities "just" created (present in $createdNode or $createdRelationships)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy to approve provided we amend the wording (can be in another PR if we are in a rush to merge this one)

@Test
public void testMetaDataAfter() {
testMetaData("after");
db.executeTransactionally("CREATE (n:Another)");
db.executeTransactionally("CALL apoc.trigger.add('txinfo', 'UNWIND $createdNodes AS n MATCH (a:Another) SET a.label = labels(n)[0], a += $metaData', {phase: 'after'})");
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we can modify the node here adding things if it is phase after?

Copy link
Collaborator

Choose a reason for hiding this comment

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

As above, because the node (a:Another) is not present in $createdNodes, but is created before the triggered query.

@Lojjs Lojjs added the 5.0 label Mar 25, 2022
@conker84 conker84 merged commit ff70d0c into dev Mar 29, 2022
@conker84 conker84 deleted the fix_var_tests_dev branch March 29, 2022 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants