-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add relay end to end test (#198)
Signed-off-by: Jeffrey Tang <jeffrey@swirldslabs.com>
- Loading branch information
1 parent
43bda68
commit 2a66fe9
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the ""License""); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an ""AS IS"" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { | ||
afterAll, afterEach, describe, | ||
expect, | ||
it | ||
} from '@jest/globals' | ||
import { flags } from '../../../src/commands/index.mjs' | ||
import { | ||
constants | ||
} from '../../../src/core/index.mjs' | ||
import { | ||
bootstrapNetwork, | ||
getDefaultArgv, | ||
TEST_CLUSTER | ||
} from '../../test_util.js' | ||
import * as version from '../../../version.mjs' | ||
import { sleep } from '../../../src/core/helpers.mjs' | ||
import { RelayCommand } from '../../../src/commands/relay.mjs' | ||
|
||
describe('RelayCommand', () => { | ||
const testName = 'relay-cmd-e2e' | ||
const namespace = testName | ||
const argv = getDefaultArgv() | ||
argv[flags.namespace.name] = namespace | ||
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0' | ||
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM | ||
|
||
argv[flags.nodeIDs.name] = 'node0,node1,node2' | ||
argv[flags.generateGossipKeys.name] = true | ||
argv[flags.generateTlsKeys.name] = true | ||
argv[flags.clusterName.name] = TEST_CLUSTER | ||
argv[flags.fstChartVersion.name] = version.FST_CHART_VERSION | ||
argv[flags.force.name] = true | ||
argv[flags.relayReleaseTag.name] = flags.relayReleaseTag.definition.defaultValue | ||
|
||
const bootstrapResp = bootstrapNetwork(testName, argv) | ||
const k8 = bootstrapResp.opts.k8 | ||
const configManager = bootstrapResp.opts.configManager | ||
const relayCmd = new RelayCommand(bootstrapResp.opts) | ||
|
||
afterAll(async () => { | ||
await k8.deleteNamespace(namespace) | ||
}) | ||
|
||
afterEach(async () => { | ||
await sleep(5) // give a few ticks so that connections can close | ||
}) | ||
|
||
it.each([ | ||
{ relayNodes: 'node0' }, | ||
{ relayNodes: 'node0,node1' }, | ||
{ relayNodes: 'node0,node1,node2' } | ||
])('relay deploy and destroy should work with different number of relay nodes', async (input) => { | ||
argv[flags.nodeIDs.name] = input.relayNodes | ||
configManager.update(argv) | ||
expect.assertions(2) | ||
|
||
// test relay deploy | ||
try { | ||
await expect(relayCmd.deploy(argv)).resolves.toBeTruthy() | ||
} catch (e) { | ||
relayCmd.logger.showUserError(e) | ||
expect(e).toBeNull() | ||
} | ||
|
||
await sleep(500) | ||
|
||
// test relay destroy | ||
try { | ||
await expect(relayCmd.destroy(argv)).resolves.toBeTruthy() | ||
} catch (e) { | ||
relayCmd.logger.showUserError(e) | ||
expect(e).toBeNull() | ||
} | ||
}, 60000) | ||
}) |