Skip to content

Commit adf5384

Browse files
Refactor k6 env vars parsing from logs
Signed-off-by: Bilyana Gospodinova <[email protected]>
1 parent dc0530d commit adf5384

File tree

4 files changed

+29
-69
lines changed

4 files changed

+29
-69
lines changed

.github/workflows/acceptance.yaml

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -162,72 +162,26 @@ jobs:
162162
if: ${{ matrix.stream-type != 'BLOCK' }}
163163
id: log-variables
164164
run: |
165+
set -ex
165166
LOG_FILE="${{ github.workspace }}/output_log.txt"
166-
ERC_CONTRACT_ADDRESS=$(grep "Skipping cleanup of contract \[ERC\]" "$LOG_FILE" | \
167-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
168-
tail -n 1 | \
169-
tr -d '[:space:]')
170-
171-
echo "ERC_CONTRACT_ADDRESS=$ERC_CONTRACT_ADDRESS"
172-
echo "ERC_CONTRACT_ADDRESS=$ERC_CONTRACT_ADDRESS" >> $GITHUB_OUTPUT
173-
174-
DEFAULT_CONTRACT_ADDRESS=$(grep "Skipping cleanup of contract \[PARENT\]" "$LOG_FILE" | \
175-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
176-
tail -n 1 | \
177-
tr -d '[:space:]')
178-
179-
echo "DEFAULT_CONTRACT_ADDRESS=$DEFAULT_CONTRACT_ADDRESS"
180-
echo "DEFAULT_CONTRACT_ADDRESS=$DEFAULT_CONTRACT_ADDRESS" >> $GITHUB_OUTPUT
181-
182-
ESTIMATE_PRECOMPILE_CONTRACT=$(grep "Skipping cleanup of contract \[ESTIMATE_PRECOMPILE\]" "$LOG_FILE" | \
183-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
184-
tail -n 1 | \
185-
tr -d '[:space:]')
186-
187-
echo "ESTIMATE_PRECOMPILE_CONTRACT=$ESTIMATE_PRECOMPILE_CONTRACT"
188-
echo "ESTIMATE_PRECOMPILE_CONTRACT=$ESTIMATE_PRECOMPILE_CONTRACT" >> $GITHUB_OUTPUT
189-
190-
PRECOMPILE_CONTRACT=$(grep "Skipping cleanup of contract \[PRECOMPILE\]" "$LOG_FILE" | \
191-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
192-
tail -n 1 | \
193-
tr -d '[:space:]')
194167
195-
echo "PRECOMPILE_CONTRACT=$PRECOMPILE_CONTRACT"
196-
echo "PRECOMPILE_CONTRACT=$PRECOMPILE_CONTRACT" >> $GITHUB_OUTPUT
197-
198-
RAW_NON_FUNGIBLE_TOKEN_ADDRESS=$(grep "Skipping cleanup of token \[non_fungible\]" "$LOG_FILE" | \
199-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
200-
tail -n 1 | \
201-
tr -d '[:space:]')
202-
NON_FUNGIBLE_TOKEN_ADDRESS=$(printf "%064s" "$RAW_NON_FUNGIBLE_TOKEN_ADDRESS" | tr ' ' '0')
203-
204-
echo "NON_FUNGIBLE_TOKEN_ADDRESS=$NON_FUNGIBLE_TOKEN_ADDRESS"
205-
echo "NON_FUNGIBLE_TOKEN_ADDRESS=$NON_FUNGIBLE_TOKEN_ADDRESS" >> $GITHUB_OUTPUT
206-
207-
RAW_TOKEN_ADDRESS=$(grep "Skipping cleanup of token \[fungible\]" "$LOG_FILE" | \
208-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
168+
declare -A k6Map
169+
k6Map["PARENT"]="DEFAULT_CONTRACT_ADDRESS"
170+
k6Map["ERC"]="ERC_CONTRACT_ADDRESS"
171+
k6Map["ESTIMATE_PRECOMPILE"]="ESTIMATE_PRECOMPILE_CONTRACT"
172+
k6Map["PRECOMPILE"]="PRECOMPILE_CONTRACT"
173+
k6Map["BOB"]="PAYER_ACCOUNT"
174+
k6Map["ALICE"]="ACCOUNT_ADDRESS"
175+
k6Map["fungible"]="TOKEN_ADDRESS"
176+
k6Map["non_fungible"]="NON_FUNGIBLE_TOKEN_ADDRESS"
177+
178+
for key in "${!k6Map[@]}"; do
179+
value=$(grep " ${key}=" "$LOG_FILE" | \
180+
awk -F'=' '{print $NF}' | \
209181
tail -n 1 | \
210182
tr -d '[:space:]')
211-
TOKEN_ADDRESS=$(printf "%064s" "$RAW_TOKEN_ADDRESS" | tr ' ' '0')
212-
213-
echo "TOKEN_ADDRESS=$TOKEN_ADDRESS"
214-
echo "TOKEN_ADDRESS=$TOKEN_ADDRESS" >> $GITHUB_OUTPUT
215-
216-
PAYER_ACCOUNT=$(grep "Skipping cleanup of account \[BOB\]" "$LOG_FILE" | \
217-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
218-
tail -n 1 | \
219-
tr -d '[:space:]')
220-
221-
echo "PAYER_ACCOUNT=$PAYER_ACCOUNT"
222-
echo "PAYER_ACCOUNT=$PAYER_ACCOUNT" >> $GITHUB_OUTPUT
223-
224-
ACCOUNT_ADDRESS=$(grep "Skipping cleanup of account \[ALICE\]" "$LOG_FILE" | \
225-
sed -E 's/.*at address ([0-9a-fA-F]{40})/\1/' | \
226-
tail -n 1 | \
227-
tr -d '[:space:]')
228-
229-
echo "ACCOUNT_ADDRESS=$ACCOUNT_ADDRESS"
230-
echo "ACCOUNT_ADDRESS=$ACCOUNT_ADDRESS" >> $GITHUB_OUTPUT
183+
echo "${key}=${value}" >> $GITHUB_OUTPUT
184+
done
231185
232186
- name: Install k6
233187
if: ${{ matrix.stream-type != 'BLOCK' }}
@@ -261,7 +215,7 @@ jobs:
261215
RUN_WITH_VARIABLES: "true"
262216
SERIAL_NUMBER: "0000000000000000000000000000000000000000000000000000000000000001"
263217
TOKEN_ADDRESS: ${{ steps.log-variables.outputs.TOKEN_ADDRESS }}
264-
WEB3_TEST_INCLUDE: "^(contractCall(RampUp|Approved|Balance|Decimals|FungibleTokenInfo|Identifier|IsToken|Multiply|Name|NonFungibleTokenInfo|OwnerOf|Sender|Symbol|TokenCustomFees|TokenDefaultFreezeStatus|TokenDefaultKycStatus|TokenExpiryInfo|TokenInfo|TokenKey|TokenType|TokenURI|TotalSupply).js)$"
218+
WEB3_TEST_INCLUDE: "^(./tools/k6/src/web3/test/contractCall(RampUp|Approved|Balance|Decimals|FungibleTokenInfo|Identifier|IsToken|Multiply|Name|NonFungibleTokenInfo|OwnerOf|Sender|Symbol|TokenCustomFees|TokenDefaultFreezeStatus|TokenDefaultKycStatus|TokenExpiryInfo|TokenInfo|TokenKey|TokenType|TokenURI|TotalSupply).js)$"
265219
with:
266220
path: ./tools/k6/src/web3/apis.js
267221
debug: false

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ public AccountClient(
6464
@Override
6565
public void clean() {
6666
if (acceptanceTestProperties.isSkipEntitiesCleanup()) {
67-
// In CI we don't want to cleanup as the entities are needed in the k6 test in the next step.
68-
log.warn("Acceptance tests running in CI -> skip cleanup.");
6967
for (var accountName : accountMap.keySet()) {
7068
log.info("Skipping cleanup of account [" + accountName + "] at address "
7169
+ accountMap.get(accountName).getAccountId().toEvmAddress());
70+
// Log the values so that it can be parsed in CI and passed to the k6 tests as input.
71+
System.out.println(accountName + "="
72+
+ accountMap.get(accountName).getAccountId().toEvmAddress());
7273
}
7374
return;
7475
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ public ContractClient(
3939
@Override
4040
public void clean() {
4141
if (acceptanceTestProperties.isSkipEntitiesCleanup()) {
42-
// In CI we don't want to cleanup as the entities are needed in the k6 test in the next step.
43-
log.warn("Acceptance tests running in CI -> skip cleanup.");
4442
for (var contractName : contractIds.keySet()) {
4543
log.info("Skipping cleanup of contract [" + contractName + "] at address "
4644
+ contractIds.get(contractName).toEvmAddress());
45+
// Log the values so that it can be parsed in CI and passed to the k6 tests as input.
46+
System.out.println(
47+
contractName + "=" + contractIds.get(contractName).toEvmAddress());
4748
}
4849
return;
4950
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,15 @@ public TokenClient(
7474
@Override
7575
public void clean() {
7676
if (acceptanceTestProperties.isSkipEntitiesCleanup()) {
77-
// In CI we don't want to cleanup as the entities are needed in the k6 test in the next step.
78-
log.warn("Acceptance tests running in CI -> skip cleanup.");
7977
for (var tokenName : tokenMap.keySet()) {
8078
log.info("Skipping cleanup of token [" + tokenName.getSymbol() + "] at address "
8179
+ tokenMap.get(tokenName).tokenId().toEvmAddress());
80+
// Log the values so that it can be parsed in CI and passed to the k6 tests as input.
81+
System.out.println(tokenName.getSymbol() + "="
82+
+ String.format(
83+
"%s%s",
84+
"0".repeat(24),
85+
tokenMap.get(tokenName).tokenId().toEvmAddress()));
8286
}
8387
return;
8488
}

0 commit comments

Comments
 (0)