Skip to content

Conversation

@timea-solid
Copy link
Contributor

@timea-solid timea-solid commented Jul 5, 2023

We saw lately too many CI problems. On investigation, it turned out that the problem occurs because the tests do not do a proper cleanup.
A solution here is to also clean up before starting the tests (making sure the containers are empty for example).

It still happens that some tests randomly fail, I am not sure if we can simply up the retry number...

@timea-solid timea-solid requested a review from a team as a code owner July 5, 2023 15:30
@timea-solid timea-solid marked this pull request as draft July 5, 2023 15:52
@timea-solid timea-solid marked this pull request as ready for review July 5, 2023 19:09
@timea-solid timea-solid marked this pull request as draft July 6, 2023 08:19
@timea-solid timea-solid marked this pull request as ready for review July 6, 2023 13:09
createContainer(publicContainerURI);
prepareACR(publicContainerURI);
//if a tests fails it can be that the cleanup was not properly done, so we do it here too
Utils.deleteContentsRecursively(localAuthClient, publicContainerURI);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned elsewhere, we can't delete this data here, because it will interfere with other concurrently-running tests.

privateContainerURI = URIBuilder.newBuilder(URI.create(podUrl))
.path(PRIVATE_RESOURCE_PATH + "/").build();
//if a tests fails it can be that the cleanup was not properly done, so we do it here too
Utils.deleteContentsRecursively(localAuthClient, privateContainerURI);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want to delete data in any setup phase, as it may interfere with other tests.

createContainer(publicContainerURI);
prepareACR(publicContainerURI);
//if a tests fails it can be that the cleanup was not properly done, so we do it here too
Utils.deleteContentsRecursively(localAuthClient, publicContainerURI);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

}
}

static void deleteRecursive(final SolidSyncClient client, final URI url, final AtomicInteger depth) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid the use of a shared AtomicInteger here; instead, you can just have a final int depth and perform arithmetic operations on that in the recursive calls

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the AtomicInteger was useful in an asynchronous context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, I cannot use it as final int depth but I do need a final in the lambda later. I did not find a better solution.

Copy link
Contributor

@edwardsph edwardsph left a comment

Choose a reason for hiding this comment

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

Taking a step back and looking at how you manage test containers, this is what I see:

If PUBLIC_RESOURCE_PATH doesn't exist then you have
publicTestContainerURI = podUrl/test-UUID/
and you rely on the ACR of the pod root being right.

If it does exist, then you have
publicTestContainerURI = podUrl/PUBLIC_RESOURCE_PATH/test-UUID/
Then you create podUrl/PUBLIC_RESOURCE_PATH/ and set up the ACR and either tear down this container at the end or try and ensure it is empty at the start. Since this is a fixed location, it will clash with other test runs.

Why not make that container unique too so you create podUrl/PUBLIC_RESOURCE_PATH-UUID/. That would isolate your tests but still use a defined prefix to make the test container identifiable (if that was the reason for allowing someone to set PUBLIC_RESOURCE_PATH. I may not have understood why you want someone to define the test container outside the tests.

The downside of my approach is that if something goes wrong with teardown, you can be left with old test containers but they will not interfere with anything and you can have a separate housekeeping process to clean them out. However, I think you will find that once the tests are more stable you will have less of a problem with this.

Comment on lines +452 to 457
final URI testRDFresourceURI = URIBuilder.newBuilder(privateContainerURI)
.path("resource-accessGrantGetRdfTest.ttl")
.build();

try (final SolidRDFSource resource = new SolidRDFSource(testRDFresourceURI, null, null)) {
assertDoesNotThrow(() -> resourceOwnerClient.create(resource));
Copy link
Contributor

Choose a reason for hiding this comment

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

A pattern I typically use with the JS client for such case, where the resource URI is irrelevant to the client (but still needs to be tracked) is to get the server to create the resource by POSTing to the parent container, which URL the client does care about (here that would be privateContainerURI). Is this a pattern that would be possible with the JCL, or does the target URL needs to be known before creating a resource?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the high-level client, we exclusively use PUT for create and update. POST and PATCH are usable directly in the low-level client.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's absolutely not critical for GA, but would something like createChild make sense in the SolidClient ?

@timea-solid timea-solid merged commit 1c7f1a2 into main Jul 10, 2023
@timea-solid timea-solid deleted the JCL-419 branch July 10, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants