Skip to content

Commit

Permalink
Merge pull request #141 from soramitsu/scenarious/fix/query_batch_count
Browse files Browse the repository at this point in the history
Scenarious/fix/query_batch_count
  • Loading branch information
timofeevmd authored Aug 21, 2024
2 parents 46aa2a1 + 1602795 commit 4d61611
Show file tree
Hide file tree
Showing 9 changed files with 49,081 additions and 46,439 deletions.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<iroha-java.version>f908546812</iroha-java.version>
<!--iroha-java.version>f908546812</iroha-java.version-->
<iroha-java.version>e23b548</iroha-java.version>
<jackson.versaion>2.14.1</jackson.versaion>
<commons-codec.version>1.15</commons-codec.version>
<lombok.version>1.18.24</lombok.version>
Expand All @@ -40,6 +41,12 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-core-java</artifactId>
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/FunctionalTest/SendQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package FunctionalTest;

import jp.co.soramitsu.iroha2.CryptoUtils;
import jp.co.soramitsu.iroha2.ExtensionsKt;
import jp.co.soramitsu.iroha2.client.Iroha2AsyncClient;
import jp.co.soramitsu.iroha2.generated.Asset;
import jp.co.soramitsu.iroha2.model.IrohaUrls;
import jp.co.soramitsu.iroha2.query.QueryAndExtractor;
import jp.co.soramitsu.iroha2.query.QueryBuilder;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

public class SendQuery {
//@Test
public void findAllAssets() {
Iroha2AsyncClient client;
try {
client = builderAsyncClient("/peer-0");
QueryAndExtractor<List<Asset>> query = QueryBuilder
.findAllAssets()
.account(ExtensionsKt.asAccountId("63f15f9c0ab4c0ff4461d829d27a569305f424ffb75cafaf9c4ab23e073fe2cc@bulb_44e22b24-5da5-4e19-ba2c-44164c8d7672_2a3db748-bd58-459c-9ebe-c5eb96e28d2b"))
.buildSigned(CryptoUtils.keyPairFromHex("63f15f9c0ab4c0ff4461d829d27a569305f424ffb75cafaf9c4ab23e073fe2cc", "14ca5693b524dae42805d9250aea4a92278ae961c900b5d815b1915078588306"));
client.sendQueryAsCompletableFuture(query).get().size();
} catch (MalformedURLException | InterruptedException | ExecutionException e) {
System.out.println("EXEPTION: " + e.getMessage());
throw new RuntimeException(e);
}

}

private Iroha2AsyncClient builderAsyncClient(String targetPeer) throws MalformedURLException {
List<IrohaUrls> irohaUrls = new ArrayList<>();
irohaUrls.add(new IrohaUrls(
new URL("https://iroha2.test.tachi.soramitsu.co.jp" + targetPeer),
new URL("https://iroha2.test.tachi.soramitsu.co.jp"),
new URL("https://iroha2.test.tachi.soramitsu.co.jp" + targetPeer))
);

return new Iroha2AsyncClient(
irohaUrls,
true,
"iroha2-test:7kUHkgq30JBeVyJVZ4Z1wbGBP3vah3",
1000);

}
}
2 changes: 1 addition & 1 deletion src/test/java/requests/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class Constants {
public static final String URL_QUERY = "query";
public static final String URL_STATUS = "/peer-2/status";
public static final String URL_STATUS = "status";
public static final String URL_TRANSACTION = "api/transaction";
public static final String DEFAULT_DOMAIN = "wonderland";
public static final String ALICE_ACCOUNT = "alice";
Expand Down
1 change: 0 additions & 1 deletion src/test/java/requests/Queries.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public class Queries extends Constants {
}))
);


public static ChainBuilder queryPostFindAllAccounts = exec(feed(CSV_FEEDER)).exec(feed(PEERS_FEEDER))
.exec(
http("findAllAccounts")
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/requests/Transactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public class Transactions extends Constants {
}
)
)
).exec(http("tx_transfer_asset_status").get(Constants.URL_STATUS).check(status().is(200)));
).exec(http("tx_transfer_asset_status").get( session -> {return session.getString("peer") + Constants.URL_STATUS;}).check(status().is(200)));

public static ChainBuilder debuggingPostTransferAsset = exec(feed(CSV_FEEDER)).exec(feed(PEERS_FEEDER))
.exec(
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/scenarious/GeneralQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class GeneralQueries {

public static ScenarioBuilder findAllAccounts = scenario("query find all accounts")
.feed(csv("preconditionList.csv").circular())
.exec(Queries.queryPostFindAllAccounts);
//.exec(Queries.queryPostFindAllAccounts);
.exec(Queries.queryPostFindAllAssets);

public static ScenarioBuilder generalQueries = scenario("general queries")
.feed(csv("preconditionList.csv").circular())
Expand Down
76 changes: 76 additions & 0 deletions src/test/java/scenarious/irohaClient/BatchQueries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package scenarious.irohaClient;

import io.gatling.javaapi.core.CoreDsl;
import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Session;
import jp.co.soramitsu.iroha2.CryptoUtils;
import jp.co.soramitsu.iroha2.ExtensionsKt;
import jp.co.soramitsu.iroha2.client.Iroha2AsyncClient;
import jp.co.soramitsu.iroha2.generated.*;
import jp.co.soramitsu.iroha2.model.IrohaUrls;
import jp.co.soramitsu.iroha2.query.QueryAndExtractor;
import jp.co.soramitsu.iroha2.query.QueryBuilder;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

import static io.gatling.javaapi.core.CoreDsl.csv;
import static io.gatling.javaapi.core.CoreDsl.scenario;


public class BatchQueries {
private static Iroha2AsyncClient client;

public static ScenarioBuilder findAllAssetClientMode = scenario("findAllAssetClientMode")
.feed(csv("preconditionList.csv").circular()).feed(csv("peers.csv").circular())
.exec(session -> {
try {
client = builderAsyncClient(session.getString("peer"));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return session;
}
).repeat(10).on(
CoreDsl.exec(session -> {
try {
client.sendQueryAsCompletableFuture(buildFindAllAssetsQuery(session)).get();
return session;
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
e.getMessage();
throw new RuntimeException(e);
}
}
)
);

private static QueryAndExtractor<List<Asset>> buildFindAllAssetsQuery(Session session) {
return QueryBuilder
.findAllAssets()
.account(ExtensionsKt.asAccountId(session.getString("anotherDevAccountIdSender")))
.buildSigned(CryptoUtils.keyPairFromHex(session.getString("publicKeySender"), session.getString("privateKeySender")));
}

private static Iroha2AsyncClient builderAsyncClient(String targetPeer) throws MalformedURLException {
List<IrohaUrls> irohaUrls = new ArrayList<>();
irohaUrls.add(new IrohaUrls(
new URL("https://iroha2.test.tachi.soramitsu.co.jp" + targetPeer),
new URL("https://iroha2.test.tachi.soramitsu.co.jp"),
new URL("https://iroha2.test.tachi.soramitsu.co.jp" + targetPeer)
)
);
Iroha2AsyncClient client1 = new Iroha2AsyncClient(
irohaUrls,
true,
System.getProperty("remoteLogin") + ":" + System.getProperty("remotePassword"),
1000);

return client1;
}


}
4 changes: 3 additions & 1 deletion src/test/java/simulation/PerformanceSimulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

import static Configs.Protocol.httpProtocol;
import static scenarious.GeneralQueries.*;
import static scenarious.irohaClient.BatchQueries.*;
import static scenarious.GeneralTransaction.*;
import static scenarious.GeneralQueries.*;
import static scenarious.HealthCheck.*;
import static scenarious.DefinitionId.*;
import static scenarious.TransferAsset.*;

public class PerformanceSimulation extends Simulation {
{
setUp(txsMultiInstructions.injectOpen(LoadProfile.getMaxPerformance()).protocols(httpProtocol)).maxDuration(Long.parseLong(System.getProperty("maxDuration")));
setUp(findAllAssetClientMode.injectOpen(LoadProfile.getMaxPerformance()).protocols(httpProtocol)).maxDuration(Long.parseLong(System.getProperty("maxDuration")));
}
}
Loading

0 comments on commit 4d61611

Please sign in to comment.