UNPKG

@hashgraph/solo

Version:

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

142 lines 6.97 kB
// SPDX-License-Identifier: Apache-2.0 import { getTestCacheDirectory, getTestCluster, HEDERA_PLATFORM_VERSION_TAG } from '../test-utility.js'; import { InjectTokens } from '../../src/core/dependency-injection/inject-tokens.js'; import { container } from 'tsyringe-neo'; import { Suite } from 'mocha'; import { BaseCommandTest } from './commands/tests/base-command-test.js'; import * as constants from '../../src/core/constants.js'; export class EndToEndTestSuite extends Suite { testName; testSuiteName; namespace; deployment; clusterCount; consensusNodesCount; loadBalancerEnabled; pinger; realm; shard; serviceMonitor; podLog; minimalSetup; collectDiagnosticLogs; apiPermissionProperties; applicationEnvironment; applicationProperties; bootstrapProperties; logXml; settingsTxt; javaFlightRecorderConfiguration; testSuiteCallback; endToEndTestSuiteInstance; testCacheDirectory; contexts; testLogger; createdAccountIds = []; enableLocalBuildPathTesting = process.env.SOLO_LOCAL_BUILD_PATH_TESTING?.toLowerCase() === 'true'; localBuildPath = process.env.SOLO_LOCAL_BUILD_PATH || '../hiero-consensus-node/hedera-node/data'; localBuildReleaseTag = process.env.SOLO_LOCAL_BUILD_RELEASE_TAG || HEDERA_PLATFORM_VERSION_TAG; clusterReferenceNameArray = []; clusterReferences = new Map(); options; constructor(testName, testSuiteName, namespace, deployment, clusterCount, consensusNodesCount, loadBalancerEnabled, pinger, realm = 0, shard = 0, serviceMonitor = false, podLog = false, minimalSetup = false, collectDiagnosticLogs = true, apiPermissionProperties = 'api-permission.properties', applicationEnvironment = 'application.env', applicationProperties = constants.APPLICATION_PROPERTIES, bootstrapProperties = 'bootstrap.properties', logXml = 'log4j2.xml', settingsTxt = 'settings.txt', javaFlightRecorderConfiguration = '', testSuiteCallback) { super(testName); this.testName = testName; this.testSuiteName = testSuiteName; this.namespace = namespace; this.deployment = deployment; this.clusterCount = clusterCount; this.consensusNodesCount = consensusNodesCount; this.loadBalancerEnabled = loadBalancerEnabled; this.pinger = pinger; this.realm = realm; this.shard = shard; this.serviceMonitor = serviceMonitor; this.podLog = podLog; this.minimalSetup = minimalSetup; this.collectDiagnosticLogs = collectDiagnosticLogs; this.apiPermissionProperties = apiPermissionProperties; this.applicationEnvironment = applicationEnvironment; this.applicationProperties = applicationProperties; this.bootstrapProperties = bootstrapProperties; this.logXml = logXml; this.settingsTxt = settingsTxt; this.javaFlightRecorderConfiguration = javaFlightRecorderConfiguration; this.testSuiteCallback = testSuiteCallback; const soloTestClusterName = getTestCluster(); const testClusterName = soloTestClusterName.includes('c1') || soloTestClusterName.includes('c2') ? soloTestClusterName : `${soloTestClusterName}-c1`; const testClusterReferenceNames = ['e2e-cluster-alpha', 'e2e-cluster-beta']; if (clusterCount === 1) { this.clusterReferences.set(testClusterReferenceNames[0], testClusterName); this.contexts = [testClusterName]; this.clusterReferenceNameArray.push(testClusterReferenceNames[0]); } else if (clusterCount === 2) { this.clusterReferences.set(testClusterReferenceNames[0], testClusterName); const secondContext = testClusterName.includes('-c1') ? testClusterName.replace('-c1', '-c2') : testClusterName.replace('-c2', '-c1'); this.clusterReferences.set(testClusterReferenceNames[1], secondContext); this.clusterReferenceNameArray.push(testClusterReferenceNames[0], testClusterReferenceNames[1]); this.contexts = [testClusterName, secondContext]; } else { throw new Error(`Unsupported cluster count: ${clusterCount}. Only 1 or 2 clusters are supported.`); } const testClusterReferences = new Map(); for (let index = 0; index < clusterCount; index++) { testClusterReferences.set(testClusterReferenceNames[index], this.contexts[index]); } this.testCacheDirectory = getTestCacheDirectory(testName); this.testLogger = container.resolve(InjectTokens.SoloLogger); this.endToEndTestSuiteInstance = this; this.options = { testName, testLogger: this.testLogger, clusterReferences: this.clusterReferences, clusterReferenceNameArray: this.clusterReferenceNameArray, contexts: this.contexts, deployment, namespace, testCacheDirectory: this.testCacheDirectory, enableLocalBuildPathTesting: this.enableLocalBuildPathTesting, localBuildReleaseTag: this.localBuildReleaseTag, localBuildPath: this.localBuildPath, createdAccountIds: this.createdAccountIds, consensusNodesCount: this.consensusNodesCount, loadBalancerEnabled: this.loadBalancerEnabled, pinger: this.pinger, realm: this.realm, shard: this.shard, serviceMonitor: this.serviceMonitor, podLog: this.podLog, minimalSetup: this.minimalSetup, apiPermissionProperties: this.apiPermissionProperties, applicationEnvironment: this.applicationEnvironment, applicationProperties: this.applicationProperties, bootstrapProperties: this.bootstrapProperties, logXml: this.logXml, settingsTxt: this.settingsTxt, javaFlightRecorderConfiguration: this.javaFlightRecorderConfiguration, }; } runTestSuite() { const endToEndTestSuiteInstance = this.endToEndTestSuiteInstance; describe(endToEndTestSuiteInstance.testSuiteName, function endToEndTestSuiteCallback() { this.bail(true); endToEndTestSuiteInstance.testSuiteCallback(endToEndTestSuiteInstance.options, EndToEndTestSuite.preDestroy); }); } static async preDestroy(endToEndTestSuiteInstance) { // Automatically setup diagnostic log collection if enabled if (endToEndTestSuiteInstance.collectDiagnosticLogs) { await BaseCommandTest.setupDiagnosticLogCollection(endToEndTestSuiteInstance.options); } if (endToEndTestSuiteInstance.javaFlightRecorderConfiguration) { await BaseCommandTest.setupJavaFlightRecorderLogCollection(endToEndTestSuiteInstance.options); } } } //# sourceMappingURL=end-to-end-test-suite.js.map