From 044dd766ada349cb4d835fa6334e65d48ee938ae Mon Sep 17 00:00:00 2001 From: Michael Sambol Date: Sat, 23 Dec 2023 14:50:37 -0600 Subject: [PATCH] lets try this --- .../@aws-cdk-testing/cli-integ/lib/index.ts | 1 - .../cli-integ/lib/with-cli-lib-no-stacks.ts | 136 ------------------ .../tests/cli-integ-tests/cli.integtest.ts | 2 +- 3 files changed, 1 insertion(+), 138 deletions(-) delete mode 100644 packages/@aws-cdk-testing/cli-integ/lib/with-cli-lib-no-stacks.ts diff --git a/packages/@aws-cdk-testing/cli-integ/lib/index.ts b/packages/@aws-cdk-testing/cli-integ/lib/index.ts index b5f7cd4548893..cabb094e65c00 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/index.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/index.ts @@ -4,7 +4,6 @@ export * from './integ-test'; export * from './memoize'; export * from './resource-pool'; export * from './with-cli-lib'; -export * from './with-cli-lib-no-stacks'; export * from './with-sam'; export * from './shell'; export * from './with-aws'; diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cli-lib-no-stacks.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cli-lib-no-stacks.ts deleted file mode 100644 index abf0096cad60d..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cli-lib-no-stacks.ts +++ /dev/null @@ -1,136 +0,0 @@ -import * as os from 'os'; -import * as path from 'path'; -import { TestContext } from './integ-test'; -import { RESOURCES_DIR } from './resources'; -import { AwsContext, withAws } from './with-aws'; -import { cloneDirectory, installNpmPackages, TestFixture, DEFAULT_TEST_TIMEOUT_S, CdkCliOptions } from './with-cdk-app'; -import { withTimeout } from './with-timeout'; - -/** - * Higher order function to execute a block with a CliLib Integration CDK app fixture - */ -export function withCliLibNoStacksIntegrationCdkApp -(block: (context:CliLibNoStacksIntegrationTestFixture) => Promise) { - return async (context: A) => { - const randy = context.randomString; - const stackNamePrefix = `cdktest-${randy}`; - const integTestDir = path.join(os.tmpdir(), `cdk-integ-${randy}`); - - context.log(` Stack prefix: ${stackNamePrefix}\n`); - context.log(` Test directory: ${integTestDir}\n`); - context.log(` Region: ${context.aws.region}\n`); - - await cloneDirectory(path.join(RESOURCES_DIR, 'cdk-apps', 'no-stack-app'), integTestDir, context.output); - const fixture = new CliLibNoStacksIntegrationTestFixture( - integTestDir, - stackNamePrefix, - context.output, - context.aws, - context.randomString); - - let success = true; - try { - const installationVersion = fixture.packages.requestedFrameworkVersion(); - - if (fixture.packages.majorVersion() === '1') { - throw new Error('This test suite is only compatible with AWS CDK v2'); - } - - const alphaInstallationVersion = fixture.packages.requestedAlphaVersion(); - await installNpmPackages(fixture, { - 'aws-cdk-lib': installationVersion, - '@aws-cdk/cli-lib-alpha': alphaInstallationVersion, - '@aws-cdk/aws-lambda-go-alpha': alphaInstallationVersion, - '@aws-cdk/aws-lambda-python-alpha': alphaInstallationVersion, - 'constructs': '^10', - }); - - await block(fixture); - } catch (e: any) { - // We survive certain cases involving gopkg.in - if (errorCausedByGoPkg(e.message)) { - return; - } - success = false; - throw e; - } finally { - if (process.env.INTEG_NO_CLEAN) { - context.log(`Left test directory in '${integTestDir}' ($INTEG_NO_CLEAN)\n`); - } else { - await fixture.dispose(success); - } - } - }; -} - -/** - * Return whether or not the error is being caused by gopkg.in being down - * - * Our Go build depends on https://gopkg.in/, which has errors pretty often - * (every couple of days). It is run by a single volunteer. - */ -function errorCausedByGoPkg(error: string) { - // The error is different depending on what request fails. Messages recognized: - //////////////////////////////////////////////////////////////////// - // go: github.com/aws/aws-lambda-go@v1.28.0 requires - // gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776: invalid version: git ls-remote -q origin in /go/pkg/mod/cache/vcs/0901dc1ef67fcce1c9b3ae51078740de4a0e2dc673e720584ac302973af82f36: exit status 128: - // remote: Cannot obtain refs from GitHub: cannot talk to GitHub: Get https://github.com/go-yaml/yaml.git/info/refs?service=git-upload-pack: net/http: request canceled (Client.Timeout exceeded while awaiting headers) - // fatal: unable to access 'https://gopkg.in/yaml.v3/': The requested URL returned error: 502 - //////////////////////////////////////////////////////////////////// - // go: downloading github.com/aws/aws-lambda-go v1.28.0 - // go: github.com/aws/aws-lambda-go@v1.28.0 requires - // gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776: unrecognized import path "gopkg.in/yaml.v3": reading https://gopkg.in/yaml.v3?go-get=1: 502 Bad Gateway - // server response: Cannot obtain refs from GitHub: cannot talk to GitHub: Get https://github.com/go-yaml/yaml.git/info/refs?service=git-upload-pack: net/http: request canceled (Client.Timeout exceeded while awaiting headers) - //////////////////////////////////////////////////////////////////// - // go: github.com/aws/aws-lambda-go@v1.28.0 requires - // gopkg.in/yaml.v3@v3.0.0-20200615113413-eeeca48fe776: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/0901dc1ef67fcce1c9b3ae51078740de4a0e2dc673e720584ac302973af82f36: exit status 128: - // error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 - // fatal: the remote end hung up unexpectedly - //////////////////////////////////////////////////////////////////// - - return (error.includes('gopkg\.in.*invalid version.*exit status 128') - || error.match(/unrecognized import path[^\n]gopkg\.in/)); -} - -/** - * SAM Integration test fixture for CDK - SAM integration test cases - */ -export function withCliLibNoStacksFixture(block: (context: CliLibNoStacksIntegrationTestFixture) => Promise) { - return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCliLibNoStacksIntegrationCdkApp(block))); -} - -export class CliLibNoStacksIntegrationTestFixture extends TestFixture { - /** - * - */ - public async cdk(args: string[], options: CdkCliOptions = {}) { - const action = args[0]; - const ignoreNoStacks = args[1]; - - const cliOpts: Record = {}; - - if (action === 'deploy') { - cliOpts.requireApproval = options.neverRequireApproval ? 'never' : 'broadening'; - } - - if (ignoreNoStacks == '--ignore-no-stacks') { - cliOpts.ignoreNoStacks = true; - } - - return this.shell(['node', '--input-type=module', `<<__EOS__ - import { AwsCdkCli } from '@aws-cdk/cli-lib-alpha'; - const cli = AwsCdkCli.fromCdkAppDirectory(); - - await cli.${action}(${JSON.stringify(cliOpts)}); -__EOS__`], { - ...options, - modEnv: { - AWS_REGION: this.aws.region, - AWS_DEFAULT_REGION: this.aws.region, - PACKAGE_LAYOUT_VERSION: this.packages.majorVersion(), - ...options.modEnv, - }, - }); - } - -} diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index ad6a5f6ed9ad2..f8d0b0f0809de 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture, withCliLibNoStacksFixture } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime