UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

106 lines 5.21 kB
// SPDX-License-Identifier: Apache-2.0 import { describe } from 'mocha'; import { resetForTest } from '../../test-container.js'; import { container } from 'tsyringe-neo'; import { InjectTokens } from '../../../src/core/dependency-injection/inject-tokens.js'; import fs from 'node:fs'; import { DEFAULT_LOCAL_CONFIG_FILE, RESOURCES_DIR } from '../../../src/core/constants.js'; import { Duration } from '../../../src/core/time/duration.js'; import { PathEx } from '../../../src/business/utils/path-ex.js'; import { EndToEndTestSuiteBuilder } from '../end-to-end-test-suite-builder.js'; import { InitTest } from './tests/init-test.js'; import { ClusterReferenceTest } from './tests/cluster-reference-test.js'; import { DeploymentTest } from './tests/deployment-test.js'; import { ConsensusNodeTest } from './tests/consensus-node-test.js'; import { NetworkTest } from './tests/network-test.js'; import { MirrorNodeTest } from './tests/mirror-node-test.js'; import { ExplorerTest } from './tests/explorer-test.js'; import { RelayTest } from './tests/relay-test.js'; import { MetricsServerImpl } from '../../../src/business/runtime-state/services/metrics-server-impl.js'; import * as constants from '../../../src/core/constants.js'; import { BlockNodeTest } from './tests/block-node-test.js'; import { destroyEnabled } from '../../test-utility.js'; const testName = 'dual-cluster-full'; // Use dual-cluster specific values file with higher memory limits to prevent OOM const dualClusterValuesFile = PathEx.joinWithRealPath(RESOURCES_DIR, 'mirror-node-values-dual-cluster-minimal.yaml'); const consensusNodesCount = process.env['SOLO_DUAL_CLUSTER_NODE_COUNT'] ? Number.parseInt(process.env['SOLO_DUAL_CLUSTER_NODE_COUNT'], 10) : 3; const endToEndTestSuite = new EndToEndTestSuiteBuilder() .withTestName(testName) .withTestSuiteName('Dual Cluster Full E2E Test Suite') .withNamespace(testName) .withDeployment(`${testName}-deployment`) .withClusterCount(2) .withConsensusNodesCount(consensusNodesCount) .withLoadBalancerEnabled(true) .withPinger(true) .withShard(3) .withRealm(2) .withServiceMonitor(true) .withPodLog(true) .withTestSuiteCallback((options, preDestroy) => { describe('Dual Cluster Full E2E Test', () => { const { testCacheDirectory, testLogger, namespace, contexts } = options; // TODO the kube config context causes issues if it isn't one of the selected clusters we are deploying to before(async () => { fs.rmSync(testCacheDirectory, { recursive: true, force: true }); try { fs.rmSync(PathEx.joinWithRealPath(testCacheDirectory, '..', DEFAULT_LOCAL_CONFIG_FILE), { force: true, }); } catch { // allowed to fail if the file doesn't exist } resetForTest(namespace.name, testCacheDirectory, false); for (const item of contexts) { const k8Client = container.resolve(InjectTokens.K8Factory).getK8(item); await k8Client.namespaces().delete(namespace); } testLogger.info(`${testName}: starting ${testName} e2e test`); }).timeout(Duration.ofMinutes(5).toMillis()); after(async () => { await preDestroy(endToEndTestSuite); }); beforeEach(async () => { testLogger.info(`${testName}: resetting containers for each test`); resetForTest(namespace.name, testCacheDirectory, false); testLogger.info(`${testName}: finished resetting containers for each test`); }); InitTest.init(options); ClusterReferenceTest.connect(options); DeploymentTest.create(options); DeploymentTest.addCluster(options); DeploymentTest.info(options); DeploymentTest.verifyDeploymentConfigInfo(options); ConsensusNodeTest.keys(options); BlockNodeTest.add(options); NetworkTest.deploy(options); ConsensusNodeTest.setup(options); ConsensusNodeTest.start(options, true); // Use dual-cluster specific values file with higher memory limits MirrorNodeTest.add({ ...options, valuesFile: dualClusterValuesFile }); MirrorNodeTest.pullAddressBook(options); ConsensusNodeTest.PemStop(options); ConsensusNodeTest.PemKill(options); ConsensusNodeTest.add(options); ConsensusNodeTest.update(options); ConsensusNodeTest.destroy(options); ExplorerTest.add(options); RelayTest.add(options); it('Should write log metrics', async () => { await new MetricsServerImpl().logMetrics(testName, PathEx.join(constants.SOLO_LOGS_DIR, `${testName}`), undefined, undefined, contexts); }); if (destroyEnabled()) { BlockNodeTest.destroy(options); RelayTest.destroy(options); ExplorerTest.destroy(options); MirrorNodeTest.destroy(options); NetworkTest.destroy(options); } }).timeout(Duration.ofMinutes(30).toMillis()); }) .build(); endToEndTestSuite.runTestSuite(); //# sourceMappingURL=dual-cluster-full.test.js.map