Skip to content

Commit

Permalink
fixed test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Feb 4, 2025
1 parent 503df12 commit c7293c6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/commands/cluster/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const setupConfigBuilder = async function (argv, ctx, task) {

ctx.config = {
chartDir: configManager.getFlag(flags.chartDirectory) as string,
clusterSetupNamespace: configManager.getFlag(flags.clusterSetupNamespace) as string,
clusterSetupNamespace: configManager.getFlag(flags.clusterSetupNamespace) as NamespaceName,
deployCertManager: configManager.getFlag(flags.deployCertManager) as boolean,
deployCertManagerCrds: configManager.getFlag(flags.deployCertManagerCrds) as boolean,
deployMinio: configManager.getFlag(flags.deployMinio) as boolean,
Expand Down Expand Up @@ -99,7 +99,7 @@ export interface ClusterConnectConfigClass {

export interface ClusterSetupConfigClass {
chartDir: string;
clusterSetupNamespace: string;
clusterSetupNamespace: NamespaceName;
deployCertManager: boolean;
deployCertManagerCrds: boolean;
deployMinio: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cluster/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const USE_FLAGS = {
flags.quiet,
flags.clusterName,
flags.context,
flags.namespace, // TODO should we be using cluster setup namespace?
flags.namespace,
flags.userEmailAddress,
],
};
2 changes: 1 addition & 1 deletion src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SOLO_HOME_DIR = process.env.SOLO_HOME || path.join(process.env.HOME
export const SOLO_LOGS_DIR = path.join(SOLO_HOME_DIR, 'logs');
export const SOLO_CACHE_DIR = path.join(SOLO_HOME_DIR, 'cache');
export const SOLO_VALUES_DIR = path.join(SOLO_CACHE_DIR, 'values-files');
export const DEFAULT_NAMESPACE = 'default';
export const DEFAULT_NAMESPACE = NamespaceName.of('default');
export const DEFAULT_CERT_MANAGER_NAMESPACE = NamespaceName.of('cert-manager');
export const HELM = 'helm';
export const RESOURCES_DIR = normalize(path.join(ROOT_DIR, 'resources'));
Expand Down
7 changes: 2 additions & 5 deletions test/e2e/commands/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {sleep} from '../../../src/core/helpers.js';
import * as version from '../../../version.js';
import {Duration} from '../../../src/core/time/duration.js';
import {NamespaceName} from '../../../src/core/kube/namespace_name.js';
import {NamespaceNameInvalidError} from '../../../src/core/kube/kube_errors.js';

describe('ClusterCommand', () => {
// mock showUser and showJSON to silent logging during tests
Expand All @@ -32,6 +33,7 @@ describe('ClusterCommand', () => {
const namespace = NamespaceName.of(testName);
const argv = getDefaultArgv();
argv[flags.namespace.name] = namespace.name;
argv[flags.clusterSetupNamespace.name] = constants.SOLO_SETUP_NAMESPACE.name;
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG;
argv[flags.nodeAliasesUnparsed.name] = 'node1';
argv[flags.generateGossipKeys.name] = true;
Expand Down Expand Up @@ -65,7 +67,6 @@ describe('ClusterCommand', () => {

beforeEach(() => {
configManager.reset();
configManager.update(argv);
});

// give a few ticks so that connections can close
Expand All @@ -79,13 +80,11 @@ describe('ClusterCommand', () => {

it('solo cluster setup should fail with invalid cluster name', async () => {
argv[flags.clusterSetupNamespace.name] = 'INVALID';
configManager.update(argv);
await expect(clusterCmd.handlers.setup(argv)).to.be.rejectedWith('Error on cluster setup');
}).timeout(Duration.ofMinutes(1).toMillis());

it('solo cluster setup should work with valid args', async () => {
argv[flags.clusterSetupNamespace.name] = namespace.name;
configManager.update(argv);
expect(await clusterCmd.handlers.setup(argv)).to.be.true;
}).timeout(Duration.ofMinutes(1).toMillis());

Expand All @@ -105,7 +104,6 @@ describe('ClusterCommand', () => {
// helm list would return an empty list if given invalid namespace
it('solo cluster reset should fail with invalid cluster name', async () => {
argv[flags.clusterSetupNamespace.name] = 'INVALID';
configManager.update(argv);

try {
await expect(clusterCmd.handlers.reset(argv)).to.be.rejectedWith('Error on cluster reset');
Expand All @@ -117,7 +115,6 @@ describe('ClusterCommand', () => {

it('solo cluster reset should work with valid args', async () => {
argv[flags.clusterSetupNamespace.name] = namespace.name;
configManager.update(argv);
expect(await clusterCmd.handlers.reset(argv)).to.be.true;
}).timeout(Duration.ofMinutes(1).toMillis());
});
3 changes: 2 additions & 1 deletion test/e2e/integration/core/k8_e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ describe('K8', () => {
it('should be able to list namespaces', async () => {
const namespaces = await k8.getNamespaces();
expect(namespaces).not.to.have.lengthOf(0);
expect(namespaces).to.contain(constants.DEFAULT_NAMESPACE);
const match = namespaces.filter(n => n.name === constants.DEFAULT_NAMESPACE.name);
expect(match).to.have.lengthOf(1);
}).timeout(defaultTimeout);

it('should be able to list context names', () => {
Expand Down

0 comments on commit c7293c6

Please sign in to comment.