Skip to content

Commit 6308d38

Browse files
Rest-java k6 tests in CI (#12243)
Add rest-java k6 tests execution as part of the workflow in order to verify the end-to-end functionality. This will be helpful to catch some issues earlier in the testing cycle. The goal is not a complete coverage of all rest-java k6 tests, so the failing ones are excluded for now. --------- Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
1 parent 1991e40 commit 6308d38

7 files changed

Lines changed: 59 additions & 14 deletions

File tree

.github/workflows/acceptance.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ jobs:
4141
- BLOCK
4242
timeout-minutes: 40
4343
env:
44+
BASE_URL: "http://127.0.0.1:8081"
4445
BLOCK_NODE_CHART_VERSION: v0.20.1
4546
CONSENSUS_VERSION: v0.67.0
47+
DEFAULT_DURATION: "3s"
48+
DEFAULT_GRACEFUL_STOP: "1s"
49+
DEFAULT_VUS: 2
4650
HELM_RELEASE_NAME: mirror-1
4751
MIRROR_NODE_VERSION: v0.141.0-rc1
4852
SOLO_CLUSTER_NAME: test
@@ -152,7 +156,7 @@ jobs:
152156
EOF
153157
fi
154158
155-
solo mirror node add --deployment "${SOLO_DEPLOYMENT}" -f mirror.yaml --cluster-ref kind-"${SOLO_CLUSTER_NAME}" --mirror-node-version "${MIRROR_NODE_VERSION}" --pinger
159+
solo mirror node add --deployment "${SOLO_DEPLOYMENT}" -f mirror.yaml --cluster-ref kind-"${SOLO_CLUSTER_NAME}" --mirror-node-version "${MIRROR_NODE_VERSION}" --pinger --enable-ingress
156160
157161
echo "Solo cluster setup completed successfully!"
158162
@@ -182,25 +186,38 @@ jobs:
182186
echo "${k6}=${value}" >> $GITHUB_ENV
183187
done
184188
189+
declare -A k6MapRestJava
190+
k6MapRestJava["DEFAULT_TOPIC"]="DEFAULT_TOPIC_WITH_FEE_ID"
191+
k6MapRestJava["PRECOMPILE"]="DEFAULT_ACCOUNT_ID_NFTS_ALLOWANCE_SPENDER"
192+
k6MapRestJava["DEFAULT_ACCOUNT_ID_BOB"]="DEFAULT_ACCOUNT_ID_AIRDROP_RECEIVER"
193+
194+
for key in "${!k6MapRestJava[@]}"; do
195+
k6="${k6MapRestJava[$key]}"
196+
value=$(grep -oP "^${key}=(\K.+)$" "$LOG_FILE" | tail -n 1 || true)
197+
echo "${k6}=${value}" >> $GITHUB_ENV
198+
done
199+
185200
- name: Install k6
186201
if: ${{ matrix.stream-type != 'BLOCK' }}
187202
uses: grafana/setup-k6-action@ffe7d7290dfa715e48c2ccc924d068444c94bde2 # v1
188203

189-
- name: Port forward web3
204+
- name: Run rest-java tests
190205
if: ${{ matrix.stream-type != 'BLOCK' }}
191-
run: |
192-
echo "Port forwarding 8080:80"
193-
kubectl port-forward "service/${HELM_RELEASE_NAME}-web3" -n "${SOLO_NAMESPACE}" 8080:80 &
206+
uses: grafana/run-k6-action@a15e2072ede004e8d46141e33d7f7dad8ad08d9d # v1
207+
env:
208+
DEFAULT_ACCOUNT_ID_NFTS_ALLOWANCE_OWNER: "0.0.1003"
209+
DEFAULT_ACCOUNT_ID_AIRDROP_SENDER: "0.0.1003"
210+
with:
211+
path: |
212+
./tools/k6/src/rest-java/apis.js
213+
debug: false
214+
flags: --quiet
194215

195216
- name: Run k6 web3 tests
196217
if: ${{ matrix.stream-type != 'BLOCK' }}
197218
uses: grafana/run-k6-action@a15e2072ede004e8d46141e33d7f7dad8ad08d9d # v1
198219
env:
199220
AMOUNT: "0000000000000000000000000000000000000000000000000000000000000001"
200-
BASE_URL: "http://127.0.0.1:8080"
201-
DEFAULT_DURATION: "3s"
202-
DEFAULT_GRACEFUL_STOP: "1s"
203-
DEFAULT_VUS: 2
204221
KEY_TYPE: "0000000000000000000000000000000000000000000000000000000000000001"
205222
RUN_COMPLEX_TESTS: "false"
206223
RUN_ESTIMATE_TESTS: "false"

test/src/test/java/org/hiero/mirror/test/e2e/acceptance/client/AbstractNetworkClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,15 @@ public void validateAddress(final String actualAddress) {
211211
: account.getAccountId().toEvmAddress());
212212
}
213213

214-
protected final <T> void deleteOrLogEntities(Collection<T> ids, Consumer<T> deleteAction) {
214+
// Returns "true" if the entities should be deleted
215+
protected final <T> boolean deleteOrLogEntities(Collection<T> ids, Consumer<T> deleteAction) {
215216
if (acceptanceTestProperties.isSkipEntitiesCleanup()) {
216217
logEntities();
217-
return;
218+
return false;
218219
}
219220

220221
deleteAll(ids, deleteAction);
222+
return true;
221223
}
222224

223225
protected void logEntities() {}

test/src/test/java/org/hiero/mirror/test/e2e/acceptance/client/AccountClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ protected void logEntities() {
9393
// Log the values so that they can be parsed in CI and passed to the k6 tests as input.
9494
System.out.println(accountName + "="
9595
+ accountMap.get(accountName).getAccountId().toEvmAddress());
96+
System.out.println("DEFAULT_ACCOUNT_ID_" + accountName + "="
97+
+ accountMap.get(accountName).getAccountId());
9698
}
9799
}
98100

test/src/test/java/org/hiero/mirror/test/e2e/acceptance/client/TokenClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public TokenClient(
7575
public void clean() {
7676
var admin = sdkClient.getExpandedOperatorAccountId();
7777
log.info("Deleting {} tokens and dissociating {} token relationships", tokenIds.size(), associations.size());
78-
deleteOrLogEntities(tokenIds, tokenId -> delete(admin, tokenId));
79-
deleteAll(associations.keySet(), association -> dissociate(association.accountId, association.tokenId));
78+
var entitiesShouldBeDeleted = deleteOrLogEntities(tokenIds, tokenId -> delete(admin, tokenId));
79+
if (entitiesShouldBeDeleted) {
80+
deleteAll(associations.keySet(), association -> dissociate(association.accountId, association.tokenId));
81+
}
8082
}
8183

8284
@Override

test/src/test/java/org/hiero/mirror/test/e2e/acceptance/client/TopicClient.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ public TopicClient(
4949
@Override
5050
public void clean() {
5151
log.info("Deleting {} topics", topicIds.size());
52-
deleteAll(topicIds, this::deleteTopic);
52+
deleteOrLogEntities(topicIds, this::deleteTopic);
53+
}
54+
55+
@Override
56+
protected void logEntities() {
57+
for (var topicId : topicIds) {
58+
// Log the values so that they can be parsed in CI and passed to the k6 tests as input.
59+
System.out.println("DEFAULT_TOPIC=" + topicId.num);
60+
}
5361
}
5462

5563
public NetworkTransactionResponse createTopic(ExpandedAccountId adminAccount, PublicKey submitKey) {

test/src/test/java/org/hiero/mirror/test/e2e/acceptance/steps/TokenFeature.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,18 @@ public void deleteFirstNonFungibleTokenAllowance(
830830
accountClient.deleteAllowanceForNft(reExpandedAccountId, new NftId(tokenId, nftInfo.serialNumber)));
831831
}
832832

833+
@Then("I airdrop {int} token to {account}")
834+
public void airdropToken(int amount, AccountNameEnum accountName) {
835+
// This method is needed only for the k6 tests in CI.
836+
if (!properties.isSkipEntitiesCleanup()) {
837+
return;
838+
}
839+
var receiver = accountClient.getAccount(accountName);
840+
var sender = accountClient.getSdkClient().getExpandedOperatorAccountId();
841+
networkTransactionResponse =
842+
verify(tokenClient.executeFungibleTokenAirdrop(tokenId, sender, receiver.getAccountId(), amount));
843+
}
844+
833845
@Then("I airdrop {int} tokens to {account}")
834846
public void airdropTokens(int amount, AccountNameEnum accountName) {
835847
var receiver = accountClient.getAccount(accountName);

test/src/test/resources/features/token/token.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Feature: HTS Base Coverage Feature
150150
Then DAVE claims the airdrop
151151
Then the mirror node REST API should return the transaction and get transaction detail
152152
And I verify "successful" airdrop of <amount> tokens to DAVE
153+
Then I airdrop 1 token to BOB
154+
Then the mirror node REST API should return the transaction
153155

154156
Examples:
155157
| amount | freezeStatus | kycStatus | modifySupplyAmount |

0 commit comments

Comments
 (0)