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

Integration test with multiple aca-py agents #13

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ianco
Copy link
Contributor

@ianco ianco commented Dec 14, 2021

Test connection process between 2 agents.

New base class for integration testing with multiple agents.

Parametrize agent startup to allow different tests to start agents with different settings.

Add test with author/endorser flow.

@ianco ianco marked this pull request as ready for review December 14, 2021 20:42
@ianco ianco requested a review from etschelp December 21, 2021 17:34
assertTrue(conn2_updated.isPresent());

// pause to allow the agent chatter to complete
Thread.sleep(4000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thread.sleep() is something that is never good in any test. As it slows down each test execution and is not portable between machines. If there is really no other way it is better to have a waiting condition with a callback that checks for the expected change and fails if the change does not happen in a certain amount of time.

import static org.junit.jupiter.api.Assertions.*;

@Slf4j
public class MultiConnectionRecordTest extends MultiIntegrationTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

As these tests are integration tests they should not run together with the other tests. To achieve that I would recommend using the @Tag("IntegrationTest") annotation together with a filter in the surefire plugin:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <excludedGroups>IntegrationTest</excludedGroups>
            </configuration>
        </plugin>

To run the integration tests only one can either add a profile to the pom or do this via the command line e.g. mvn test -Dgroups=IntegrationTest

@Slf4j
public class EndorserConnectionRecordTest extends MultiIntegrationTestBase {

public static final String INDY_LEDGER_URL = "https://indy-test.bosch-digital.de";
Copy link
Contributor

Choose a reason for hiding this comment

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

How complicated is it to start a indy node via a test container? This would probably be the best solution instead of relying to an external service that we wanted to turn off a while ago.

.withLogConsumer(new Slf4jLogConsumer(log))
;

protected String extraAgentArgs(int agentNum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The api is a bit confusing, I would also make that method abstract.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I would split this up into two abstract methods like agentOneArgs() and agentTwoArgs, then you do not have to use switches all the time

.post(jsonBody(gson.toJson(body)))
.build();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Dead code below

.alias(alias_1)
.did(localDid1.getDid())
.verkey(localDid1.getVerkey())
.build());
Copy link
Contributor

Choose a reason for hiding this comment

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

I like using orElseThrow() in these cases, makes it cleaner to read.

@lombok.NoArgsConstructor
@lombok.Builder
public class LedgerDIDCreate {
public static final String SERIALIZED_NAME_ALIAS = "alias";
Copy link
Contributor

Choose a reason for hiding this comment

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

using @SerialisedName here is redundant

@lombok.AllArgsConstructor
@lombok.NoArgsConstructor
@lombok.Builder
public class LedgerDIDCreate {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make these two inner classes of the LedgerClient?

*/
@Slf4j
@SuppressWarnings("unused")
public class LedgerClient extends BaseClient {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be useful to have this in the main package

@lombok.Builder
public class LedgerDIDResponse {
public static final String SERIALIZED_NAME_DID = "did";
@SerializedName(SERIALIZED_NAME_DID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@ianco ianco marked this pull request as draft January 13, 2022 16:38
Signed-off-by: Ian Costanzo <[email protected]>
@ianco
Copy link
Contributor Author

ianco commented Jan 19, 2022

@etschelp the build for this PR is failing with a license check, however it look like I've included the license header in each of these files, any suggestions?

[INFO] --- license-maven-plugin:4.1:check (default) @ aries-client-python ---
[INFO] Checking licenses...
Warning:  Missing header in: /home/runner/work/acapy-java-client/acapy-java-client/src/test/java/org/hyperledger/aries/api/connection/EndorserConnectionRecordTest.java
Warning:  Missing header in: /home/runner/work/acapy-java-client/acapy-java-client/src/test/java/org/hyperledger/aries/api/connection/MultiConnectionRecordTest.java
Warning:  Missing header in: /home/runner/work/acapy-java-client/acapy-java-client/src/test/java/org/hyperledger/aries/LedgerClient.java
Warning:  Missing header in: /home/runner/work/acapy-java-client/acapy-java-client/src/test/java/org/hyperledger/aries/MultiIntegrationTestBase.java
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:17 min
[INFO] Finished at: 2022-01-13T17:08:11Z
[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal com.mycila:license-maven-plugin:4.1:check (default) on project aries-client-python: Some files do not have the expected license header -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:  
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.

@etschelp
Copy link
Contributor

@ianco simply run mvn license:format once and then push the changes.

Signed-off-by: Ian Costanzo <[email protected]>
@ianco
Copy link
Contributor Author

ianco commented Jan 19, 2022

@ianco simply run mvn license:format once and then push the changes.

Awesome thanks for the tip!

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.

2 participants