Skip to content

Commit 5477c6d

Browse files
committed
K16
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
1 parent 4031264 commit 5477c6d

25 files changed

+177
-114
lines changed

src/commands/node/configs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ export const KEYS_CONFIGS_NAME = 'keyConfigs';
2929
export const SETUP_CONFIGS_NAME = 'setupConfigs';
3030
export const START_CONFIGS_NAME = 'startConfigs';
3131

32-
const initializeSetup = async (config, K0016) => {
32+
const initializeSetup = async (config, k8Factory) => {
3333
// compute other config parameters
3434
config.keysDir = path.join(validatePath(config.cacheDir), 'keys');
3535
config.stagingDir = Templates.renderStagingDir(config.cacheDir, config.releaseTag);
3636
config.stagingKeysDir = path.join(validatePath(config.stagingDir), 'keys');
3737

38-
if (!(await K0016.namespaces().has(config.namespace))) {
38+
if (!(await k8Factory.default().namespaces().has(config.namespace))) {
3939
throw new SoloError(`namespace ${config.namespace} does not exist`);
4040
}
4141

src/commands/node/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class NodeCommand extends BaseCommand {
6969
/**
7070
* stops and closes the port forwards
7171
* - calls the accountManager.close()
72-
* - for all portForwards, calls K0016.pods().readByRef(null).stopPortForward(srv)
72+
* - for all portForwards, calls k8Factory.default().pods().readByRef(null).stopPortForward(srv)
7373
*/
7474
async close() {
7575
await this.accountManager.close();

src/core/config/local_config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class LocalConfig implements LocalConfigData {
179179

180180
if (!deploymentClusters) {
181181
if (isQuiet) {
182-
deploymentClusters = K0016.clusters().readCurrent();
182+
deploymentClusters = k8Factory.default().clusters().readCurrent();
183183
} else {
184184
deploymentClusters = await flags.deploymentClusters.prompt(task, deploymentClusters);
185185
}

src/core/lease/lease_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class LeaseManager {
2424
*
2525
* @param _renewalService - the lease renewal service.
2626
* @param _logger - the logger.
27-
* @param K0016 - the Kubernetes client.
27+
* @param k8Factory - the Kubernetes client.
2828
* @param configManager - the configuration manager.
2929
*/
3030
constructor(

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ export function main(argv: any) {
6666

6767
// set cluster and namespace in the global configManager from kubernetes context
6868
// so that we don't need to prompt the user
69-
const contextNamespace: NamespaceName = K0016.contexts().readCurrentNamespace();
70-
const currentClusterName: string = K0016.clusters().readCurrent();
71-
const contextName: string = K0016.contexts().readCurrent();
69+
const contextNamespace: NamespaceName = k8Factory.default().contexts().readCurrentNamespace();
70+
const currentClusterName: string = k8Factory.default().clusters().readCurrent();
71+
const contextName: string = k8Factory.default().contexts().readCurrent();
7272

7373
const opts: Opts = {
7474
logger,
7575
helm,
76-
K0016,
76+
k8Factory,
7777
downloader,
7878
platformInstaller,
7979
chartManager,

test/e2e/commands/account.test.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin
5959
before(() => {
6060
accountCmd = new AccountCommand(bootstrapResp.opts, testSystemAccounts);
6161
bootstrapResp.cmd.accountCmd = accountCmd;
62-
K0016 = bootstrapResp.opts.k8Factory;
62+
k8Factory = bootstrapResp.opts.k8Factory;
6363
accountManager = bootstrapResp.opts.accountManager;
6464
configManager = bootstrapResp.opts.configManager;
6565
nodeCmd = bootstrapResp.cmd.nodeCmd;
@@ -69,20 +69,23 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin
6969
this.timeout(Duration.ofMinutes(3).toMillis());
7070

7171
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
72-
await K0016.namespaces().delete(namespace);
72+
await k8Factory.default().namespaces().delete(namespace);
7373
await accountManager.close();
7474
await nodeCmd.close();
7575
});
7676

7777
describe('node proxies should be UP', () => {
7878
for (const nodeAlias of argv[flags.nodeAliasesUnparsed.name].split(',')) {
7979
it(`proxy should be UP: ${nodeAlias} `, async () => {
80-
await K0016.pods().waitForReadyStatus(
81-
namespace,
82-
[`app=haproxy-${nodeAlias}`, 'solo.hedera.com/type=haproxy'],
83-
300,
84-
Duration.ofSeconds(2).toMillis(),
85-
);
80+
await k8Factory
81+
.default()
82+
.pods()
83+
.waitForReadyStatus(
84+
namespace,
85+
[`app=haproxy-${nodeAlias}`, 'solo.hedera.com/type=haproxy'],
86+
300,
87+
Duration.ofSeconds(2).toMillis(),
88+
);
8689
}).timeout(Duration.ofSeconds(30).toMillis());
8790
}
8891
});

test/e2e/commands/cluster.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('ClusterCommand', () => {
4646
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined;
4747

4848
const bootstrapResp = bootstrapTestVariables(testName, argv);
49-
const K0016 = bootstrapResp.opts.k8Factory;
49+
const k8Factory = bootstrapResp.opts.k8Factory;
5050
const configManager = bootstrapResp.opts.configManager;
5151
const chartManager = bootstrapResp.opts.chartManager;
5252

@@ -55,7 +55,7 @@ describe('ClusterCommand', () => {
5555
after(async function () {
5656
this.timeout(Duration.ofMinutes(3).toMillis());
5757

58-
await K0016.namespaces().delete(namespace);
58+
await k8Factory.default().namespaces().delete(namespace);
5959
argv[flags.clusterSetupNamespace.name] = constants.SOLO_SETUP_NAMESPACE.name;
6060
configManager.update(argv);
6161
await clusterCmd.handlers.setup(argv); // restore solo-cluster-setup for other e2e tests to leverage

test/e2e/commands/mirror_node.test.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ argv[flags.pinger.name] = true;
5050
argv[flags.enableHederaExplorerTls.name] = true;
5151
e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, bootstrapResp => {
5252
describe('MirrorNodeCommand', async () => {
53-
const K0016 = bootstrapResp.opts.k8Factory;
53+
const k8Factory = bootstrapResp.opts.k8Factory;
5454
const mirrorNodeCmd = new MirrorNodeCommand(bootstrapResp.opts);
5555
const explorerCommand = new ExplorerCommand(bootstrapResp.opts);
5656
const downloader = new PackageDownloader(mirrorNodeCmd.logger);
@@ -68,7 +68,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin
6868
this.timeout(Duration.ofMinutes(3).toMillis());
6969

7070
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
71-
await K0016.namespaces().delete(namespace);
71+
await k8Factory.default().namespaces().delete(namespace);
7272
await accountManager.close();
7373

7474
bootstrapResp.opts.logger.showUser(`------------------------- END: ${testName} ----------------------------`);
@@ -112,10 +112,15 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin
112112
await accountManager.loadNodeClient(namespace);
113113
try {
114114
// find hedera explorer pod
115-
const pods: V1Pod[] = await K0016.pods().list(namespace, ['app.kubernetes.io/component=hedera-explorer']);
115+
const pods: V1Pod[] = await k8Factory
116+
.default()
117+
.pods()
118+
.list(namespace, ['app.kubernetes.io/component=hedera-explorer']);
116119
const explorerPod = pods[0];
117120

118-
portForwarder = await K0016.pods()
121+
portForwarder = await k8Factory
122+
.default()
123+
.pods()
119124
.readByRef(PodRef.of(namespace, PodName.of(explorerPod.metadata.name)))
120125
.portForward(8_080, 8_080);
121126
await sleep(Duration.ofSeconds(2));
@@ -201,7 +206,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin
201206
}
202207
await sleep(Duration.ofSeconds(1));
203208
expect(receivedMessage).to.equal(testMessage);
204-
await K0016.pods().readByRef(null).stopPortForward(portForwarder);
209+
await k8Factory.default().pods().readByRef(null).stopPortForward(portForwarder);
205210
} catch (e) {
206211
mirrorNodeCmd.logger.showUserError(e);
207212
expect.fail();

test/e2e/commands/network.test.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('NetworkCommand', () => {
4141
argv[flags.quiet.name] = true;
4242

4343
const bootstrapResp = bootstrapTestVariables(testName, argv);
44-
const K0016 = bootstrapResp.opts.k8Factory;
44+
const k8Factory = bootstrapResp.opts.k8Factory;
4545
const accountManager = bootstrapResp.opts.accountManager;
4646
const configManager = bootstrapResp.opts.configManager;
4747

@@ -54,7 +54,7 @@ describe('NetworkCommand', () => {
5454
this.timeout(Duration.ofMinutes(3).toMillis());
5555

5656
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
57-
await K0016.namespaces().delete(namespace);
57+
await k8Factory.default().namespaces().delete(namespace);
5858
await accountManager.close();
5959
});
6060

@@ -75,10 +75,13 @@ describe('NetworkCommand', () => {
7575

7676
// check pod names should match expected values
7777
await expect(
78-
K0016.pods().read(PodRef.of(namespace, PodName.of('network-node1-0'))),
78+
k8Factory
79+
.default()
80+
.pods()
81+
.read(PodRef.of(namespace, PodName.of('network-node1-0'))),
7982
).eventually.to.have.nested.property('metadata.name', 'network-node1-0');
8083
// get list of pvc using k8 pvcs list function and print to log
81-
const pvcs = await K0016.pvcs().list(namespace, []);
84+
const pvcs = await k8Factory.default().pvcs().list(namespace, []);
8285
networkCmd.logger.showList('PVCs', pvcs);
8386

8487
expect(networkCmd.getUnusedConfigs(NetworkCommand.DEPLOY_CONFIGS_NAME)).to.deep.equal([
@@ -125,12 +128,12 @@ describe('NetworkCommand', () => {
125128
const destroyResult = await networkCmd.destroy(argv);
126129
expect(destroyResult).to.be.true;
127130

128-
while ((await K0016.pods().list(namespace, ['solo.hedera.com/type=network-node'])).length > 0) {
131+
while ((await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node'])).length > 0) {
129132
networkCmd.logger.debug('Pods are still running. Waiting...');
130133
await sleep(Duration.ofSeconds(3));
131134
}
132135

133-
while ((await K0016.pods().list(namespace, ['app=minio'])).length > 0) {
136+
while ((await k8Factory.default().pods().list(namespace, ['app=minio'])).length > 0) {
134137
networkCmd.logger.showUser('Waiting for minio container to be deleted...');
135138
await sleep(Duration.ofSeconds(3));
136139
}

test/e2e/commands/node_delete.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ e2eTestSuite(
5454
describe('Node delete', async () => {
5555
const nodeCmd = bootstrapResp.cmd.nodeCmd;
5656
const accountCmd = bootstrapResp.cmd.accountCmd;
57-
const K0016 = bootstrapResp.opts.k8Factory;
57+
const k8Factory = bootstrapResp.opts.k8Factory;
5858

5959
after(async function () {
6060
this.timeout(Duration.ofMinutes(10).toMillis());
6161
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
62-
await K0016.namespaces().delete(namespace);
62+
await k8Factory.default().namespaces().delete(namespace);
6363
});
6464

6565
it('should succeed with init command', async () => {
@@ -84,10 +84,12 @@ e2eTestSuite(
8484

8585
it('config.txt should no longer contain removed node alias name', async () => {
8686
// read config.txt file from first node, read config.txt line by line, it should not contain value of nodeAlias
87-
const pods: V1Pod[] = await K0016.pods().list(namespace, ['solo.hedera.com/type=network-node']);
87+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
8888
const podName: PodName = PodName.of(pods[0].metadata.name);
8989
const tmpDir = getTmpDir();
90-
await K0016.containers()
90+
await k8Factory
91+
.default()
92+
.containers()
9193
.readByRef(ContainerRef.of(PodRef.of(namespace, podName), ROOT_CONTAINER))
9294
.copyFrom(`${HEDERA_HAPI_PATH}/config.txt`, tmpDir);
9395
const configTxt = fs.readFileSync(`${tmpDir}/config.txt`, 'utf8');

test/e2e/commands/node_update.test.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ e2eTestSuite(
6363
describe('Node update', async () => {
6464
const nodeCmd = bootstrapResp.cmd.nodeCmd;
6565
const accountCmd = bootstrapResp.cmd.accountCmd;
66-
const K0016 = bootstrapResp.opts.k8Factory;
66+
const k8Factory = bootstrapResp.opts.k8Factory;
6767
let existingServiceMap;
6868
let existingNodeIdsPrivateKeysHash;
6969

@@ -72,12 +72,16 @@ e2eTestSuite(
7272

7373
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
7474
await nodeCmd.handlers.stop(argv);
75-
await K0016.namespaces().delete(namespace);
75+
await k8Factory.default().namespaces().delete(namespace);
7676
});
7777

7878
it('cache current version of private keys', async () => {
7979
existingServiceMap = await bootstrapResp.opts.accountManager.getNodeServiceMap(namespace);
80-
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(existingServiceMap, K0016, getTmpDir());
80+
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
81+
existingServiceMap,
82+
k8Factory,
83+
getTmpDir(),
84+
);
8185
}).timeout(defaultTimeout);
8286

8387
it('should succeed with init command', async () => {
@@ -121,7 +125,7 @@ e2eTestSuite(
121125
it('signing key and tls key should not match previous one', async () => {
122126
const currentNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
123127
existingServiceMap,
124-
K0016,
128+
k8Factory,
125129
getTmpDir(),
126130
);
127131

@@ -147,10 +151,12 @@ e2eTestSuite(
147151

148152
it('config.txt should be changed with new account id', async () => {
149153
// read config.txt file from first node, read config.txt line by line, it should not contain value of newAccountId
150-
const pods: V1Pod[] = await K0016.pods().list(namespace, ['solo.hedera.com/type=network-node']);
154+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
151155
const podName: PodName = PodName.of(pods[0].metadata.name);
152156
const tmpDir = getTmpDir();
153-
await K0016.containers()
157+
await k8Factory
158+
.default()
159+
.containers()
154160
.readByRef(ContainerRef.of(PodRef.of(namespace, podName), ROOT_CONTAINER))
155161
.copyFrom(`${HEDERA_HAPI_PATH}/config.txt`, tmpDir);
156162
const configTxt = fs.readFileSync(`${tmpDir}/config.txt`, 'utf8');

test/e2e/commands/node_upgrade.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ e2eTestSuite(
4949
describe('Node upgrade', async () => {
5050
const nodeCmd = bootstrapResp.cmd.nodeCmd;
5151
const accountCmd = bootstrapResp.cmd.accountCmd;
52-
const K0016 = bootstrapResp.opts.k8Factory;
52+
const k8Factory = bootstrapResp.opts.k8Factory;
5353

5454
after(async function () {
5555
this.timeout(Duration.ofMinutes(10).toMillis());
5656

5757
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
58-
await K0016.namespaces().delete(namespace);
58+
await k8Factory.default().namespaces().delete(namespace);
5959
});
6060

6161
it('should succeed with init command', async () => {
@@ -90,9 +90,11 @@ e2eTestSuite(
9090
it('network nodes version file was upgraded', async () => {
9191
// copy the version.txt file from the pod data/upgrade/current directory
9292
const tmpDir = getTmpDir();
93-
const pods: V1Pod[] = await K0016.pods().list(namespace, ['solo.hedera.com/type=network-node']);
93+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
9494
const podName: PodName = PodName.of(pods[0].metadata.name);
95-
await K0016.containers()
95+
await k8Factory
96+
.default()
97+
.containers()
9698
.readByRef(ContainerRef.of(PodRef.of(namespace, podName), ROOT_CONTAINER))
9799
.copyFrom(`${HEDERA_HAPI_PATH}/data/upgrade/current/version.txt`, tmpDir);
98100

test/e2e/commands/relay.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ argv[flags.quiet.name] = true;
3232

3333
e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, bootstrapResp => {
3434
describe('RelayCommand', async () => {
35-
const K0016 = bootstrapResp.opts.k8Factory;
35+
const k8Factory = bootstrapResp.opts.k8Factory;
3636
const configManager = bootstrapResp.opts.configManager;
3737
const relayCmd = new RelayCommand(bootstrapResp.opts);
3838

3939
after(async () => {
4040
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
41-
await K0016.namespaces().delete(namespace);
41+
await k8Factory.default().namespaces().delete(namespace);
4242
});
4343

4444
afterEach(async () => await sleep(Duration.ofMillis(5)));

test/e2e/commands/separate_node_add.test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ e2eTestSuite(
6161
const nodeCmd = bootstrapResp.cmd.nodeCmd;
6262
const accountCmd = bootstrapResp.cmd.accountCmd;
6363
const networkCmd = bootstrapResp.cmd.networkCmd;
64-
const K0016 = bootstrapResp.opts.k8Factory;
64+
const k8Factory = bootstrapResp.opts.k8Factory;
6565
let existingServiceMap;
6666
let existingNodeIdsPrivateKeysHash;
6767

@@ -73,13 +73,17 @@ e2eTestSuite(
7373
await nodeCmd.accountManager.close();
7474
await nodeCmd.handlers.stop(argv);
7575
await networkCmd.destroy(argv);
76-
await K0016.namespaces().delete(namespace);
76+
await k8Factory.default().namespaces().delete(namespace);
7777
});
7878

7979
it('cache current version of private keys', async () => {
8080
// @ts-ignore
8181
existingServiceMap = await nodeCmd.accountManager.getNodeServiceMap(namespace);
82-
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(existingServiceMap, K0016, getTmpDir());
82+
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
83+
existingServiceMap,
84+
k8Factory,
85+
getTmpDir(),
86+
);
8387
}).timeout(defaultTimeout);
8488

8589
it('should succeed with init command', async () => {
@@ -112,7 +116,7 @@ e2eTestSuite(
112116
it('existing nodes private keys should not have changed', async () => {
113117
const currentNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
114118
existingServiceMap,
115-
K0016,
119+
k8Factory,
116120
getTmpDir(),
117121
);
118122

0 commit comments

Comments
 (0)