Skip to content

Commit

Permalink
fix allSettle for dump logs (#1891)
Browse files Browse the repository at this point in the history
* fix allSettle for dump logs

* ci
  • Loading branch information
pepoviola authored Oct 3, 2024
1 parent 76cbcb4 commit 6c56366
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
37 changes: 19 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ variables:
CACHE_COMPRESSION_LEVEL: "fastest"
FF_USE_FASTZIP: "true"
PUSHGATEWAY_URL: "http://zombienet-prometheus-pushgateway.managed-monitoring:9091/metrics/job/zombie-metrics"
DEBUG: "zombie,zombie::network-node,zombie::kube::client::logs"

cache:
- key:
Expand Down Expand Up @@ -249,26 +250,26 @@ zombienet-upgrade-node:
--local-dir="${LOCAL_DIR}"
--test="0001-upgrade-node.zndsl"

paras:
extends:
- .zombienet-common
variables:
GH_DIR: "https://github.com/paritytech/zombienet/tree/${CI_COMMIT_SHORT_SHA}/tests/paras"
# paras:
# extends:
# - .zombienet-common
# variables:
# GH_DIR: "https://github.com/paritytech/zombienet/tree/${CI_COMMIT_SHORT_SHA}/tests/paras"

before_script:
- echo "Zombienet Paras smoke test"
- echo "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/paritypr/polkadot-debug:master"
- export BIFROST_COL_IMAGE=docker.io/bifrostnetwork/bifrost:latest
- export MOONBEAM_COL_IMAGE=docker.io/purestake/moonbeam:v0.26
- export OAK_COL_IMAGE=docker.io/oaknetwork/turing:latest
# before_script:
# - echo "Zombienet Paras smoke test"
# - echo "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
# - echo "${GH_DIR}"
# - export DEBUG=zombie
# - export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/paritypr/polkadot-debug:master"
# - export BIFROST_COL_IMAGE=docker.io/bifrostnetwork/bifrost:latest
# - export MOONBEAM_COL_IMAGE=docker.io/purestake/moonbeam:v0.26
# - export OAK_COL_IMAGE=docker.io/oaknetwork/turing:latest

script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--test="paras.zndsl"
# script:
# - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
# --local-dir="${LOCAL_DIR}"
# --test="paras.zndsl"

# db-snapshot:
# extends:
Expand Down
15 changes: 11 additions & 4 deletions javascript/packages/orchestrator/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,24 @@ export class Network {
async dumpLogs(showLogPath = true): Promise<string> {
const logsPath = this.tmpDir + "/logs";
// create dump directory in local temp
if (!fs.existsSync(logsPath)) fs.mkdirSync(logsPath);
try {
await fs.promises.access(
logsPath,
fs.promises.constants.R_OK | fs.promises.constants.W_OK,
);
} catch {
// create dir
await fs.promises.mkdir(logsPath);
}

const paraNodes: NetworkNode[] = Object.values(this.paras).reduce(
(memo: NetworkNode[], value) => memo.concat(value.nodes),
[],
);

const dumpsNodes = this.relay.concat(paraNodes);
await Promise.allSettled(
dumpsNodes.map((node) => {
this.client.dumpLogs(this.tmpDir, node.name);
}),
dumpsNodes.map((node) => this.client.dumpLogs(this.tmpDir, node.name)),
);

if (showLogPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ export class KubeClient extends Client {
return result.stdout.split(",");
}

async dumpLogs(path: string, podName: string) {
async dumpLogs(path: string, podName: string): Promise<void> {
const dstFileName = `${path}/logs/${podName}.log`;
const logs = await this.getNodeLogs(podName);
await fs.writeFile(dstFileName, logs);
Expand Down

0 comments on commit 6c56366

Please sign in to comment.