// SPDX-License-Identifier: Apache-2.0
import { BaseCommandTest } from './base-command-test.js';
import { Flags } from '../../../../src/commands/flags.js';
import { main } from '../../../../src/index.js';
import { Duration } from '../../../../src/core/time/duration.js';
import { InjectTokens } from '../../../../src/core/dependency-injection/inject-tokens.js';
import { expect } from 'chai';
import { container } from 'tsyringe-neo';
export class RelayTest extends BaseCommandTest {
    static soloRelayDeployArgv(testName, deployment, clusterReference) {
        const { newArgv, argvPushGlobalFlags, optionFromFlag } = RelayTest;
        const argv = newArgv();
        argv.push('relay', 'deploy', optionFromFlag(Flags.deployment), deployment, optionFromFlag(Flags.nodeAliasesUnparsed), 'node2');
        argvPushGlobalFlags(argv, testName, true, false);
        return argv;
    }
    static async verifyRelayDeployWasSuccessful(contexts, namespace) {
        const k8Factory = container.resolve(InjectTokens.K8Factory);
        const k8 = k8Factory.getK8(contexts[1]);
        const relayPods = await k8.pods().list(namespace, ['app.kubernetes.io/name=relay']);
        expect(relayPods).to.have.lengthOf(1);
    }
    static deploy(options) {
        const { testName, deployment, namespace, contexts, clusterReferenceNameArray, testLogger } = options;
        const { soloRelayDeployArgv, verifyRelayDeployWasSuccessful } = RelayTest;
        it(`${testName}: JSON-RPC relay deploy`, async () => {
            await main(soloRelayDeployArgv(testName, deployment, clusterReferenceNameArray[1]));
            await verifyRelayDeployWasSuccessful(contexts, namespace);
        }).timeout(Duration.ofMinutes(5).toMillis());
    }
}
//# sourceMappingURL=relay-test.js.map