-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cdk-graph): add pdk pipeline coverage
Ensure that PDKNag and PDKPipeline are handled by cdk graph and plugins.
- Loading branch information
1 parent
3ac998d
commit 982cff5
Showing
9 changed files
with
1,047 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+899 KB
...ugin-diagram/test/graphviz/__image_snapshots__/pdk-integ/pdk-integ-pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
898 changes: 898 additions & 0 deletions
898
packages/cdk-graph-plugin-diagram/test/graphviz/__snapshots__/pdk-integ.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
packages/cdk-graph-plugin-diagram/test/graphviz/pdk-integ.test.ts
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,59 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import { CdkGraph } from "@aws-prototyping-sdk/cdk-graph"; | ||
import { PDKPipelineIntegApp } from "@aws-prototyping-sdk/cdk-graph/test/__fixtures__/pdk-integ"; | ||
import * as fs from "fs-extra"; | ||
import * as testUtils from "./test-utils"; | ||
import { CdkGraphDiagramPlugin } from "../../src"; | ||
|
||
jest.setTimeout(90000); // CI tests timeout occasionally so increase to large timeout buffer | ||
|
||
const makeCdkOutdir = async (name: string) => | ||
testUtils.makeCdkOutDir("pdk-integ", name); | ||
|
||
describe("pdk-integ", () => { | ||
describe("pipeline", () => { | ||
let outdir: string; | ||
let app: PDKPipelineIntegApp; | ||
let graph: CdkGraph; | ||
let plugin: CdkGraphDiagramPlugin; | ||
|
||
beforeAll(async () => { | ||
outdir = await makeCdkOutdir("pipeline"); | ||
|
||
app = new PDKPipelineIntegApp({ outdir }); | ||
plugin = new CdkGraphDiagramPlugin(); | ||
graph = new CdkGraph(app, { | ||
plugins: [plugin], | ||
}); | ||
app.synth(); | ||
await graph.report(); | ||
}); | ||
|
||
it("should generate dot artifact", async () => { | ||
expect(plugin.defaultDotArtifact).toBeDefined(); | ||
expect( | ||
await fs.pathExists(plugin.defaultDotArtifact!.filepath) | ||
).toBeTruthy(); | ||
expect( | ||
testUtils.cleanseDotSnapshot( | ||
await fs.readFile(plugin.defaultDotArtifact!.filepath, { | ||
encoding: "utf-8", | ||
}) | ||
) | ||
).toMatchSnapshot(); | ||
}); | ||
|
||
it("should generate png artifact", async () => { | ||
expect(plugin.defaultPngArtifact).toBeDefined(); | ||
expect( | ||
await fs.pathExists(plugin.defaultPngArtifact!.filepath) | ||
).toBeTruthy(); | ||
|
||
await testUtils.expectToMatchImageSnapshot( | ||
plugin.defaultPngArtifact!.filepath, | ||
"pdk-integ-pipeline" | ||
); | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,35 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import { PDKNagApp } from "@aws-prototyping-sdk/pdk-nag"; | ||
import { PDKPipeline } from "@aws-prototyping-sdk/pipeline"; | ||
import { AppProps, Stack } from "aws-cdk-lib"; | ||
import { ENVIRONMENTS, TestStage } from "./apps"; | ||
|
||
export interface PDKIntegAppProps { | ||
outdir: string; | ||
} | ||
|
||
export class PDKPipelineIntegApp extends PDKNagApp { | ||
constructor(props: PDKIntegAppProps) { | ||
super({ outdir: props.outdir }); | ||
|
||
const pipelineStack = new Stack(this, "PipelineStack", { | ||
env: ENVIRONMENTS.DEFAULT, | ||
}); | ||
const pipeline = new PDKPipeline(pipelineStack, "Pipeline", { | ||
primarySynthDirectory: props.outdir, | ||
repositoryName: "monorepo", | ||
publishAssetsInParallel: false, | ||
crossAccountKeys: true, | ||
synth: {}, | ||
}); | ||
|
||
const devStage = new TestStage(this, "Dev", { env: ENVIRONMENTS.DEV }); | ||
pipeline.addStage(devStage); | ||
|
||
const prodStage = new TestStage(this, "Prod", { env: ENVIRONMENTS.PROD }); | ||
pipeline.addStage(prodStage); | ||
|
||
pipeline.buildPipeline(); // Needed for CDK Nag | ||
} | ||
} |
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,42 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import * as fs from "fs-extra"; | ||
import * as testUtils from "./test-utils"; | ||
import { CdkGraph, Graph } from "../../src"; | ||
import { PDKPipelineIntegApp } from "../__fixtures__/pdk-integ"; | ||
|
||
const makeCdkOutdir = async (name: string) => | ||
testUtils.makeCdkOutDir("pdk-integ", name); | ||
|
||
describe("cdk-graph/pdk-integ", () => { | ||
describe("pipeline", () => { | ||
let outdir: string; | ||
let graphJsonFile: string; | ||
let app: PDKPipelineIntegApp; | ||
let graph: CdkGraph; | ||
|
||
beforeAll(async () => { | ||
outdir = await makeCdkOutdir("pipeline"); | ||
|
||
app = new PDKPipelineIntegApp({ outdir }); | ||
graph = new CdkGraph(app); | ||
app.synth(); | ||
graphJsonFile = graph.graphContext!.graphJson.filepath; | ||
await graph.report(); | ||
}); | ||
|
||
it("should synthesize graph.json", async () => { | ||
expect(await fs.pathExists(graphJsonFile)).toBe(true); | ||
}); | ||
|
||
it("should serialize <-> deserialize to same", async () => { | ||
const serializedStore = await fs.readJSON(graphJsonFile, { | ||
encoding: "utf-8", | ||
}); | ||
const deserializedStore = | ||
Graph.Store.fromSerializedStore(serializedStore); | ||
const reserializedStore = deserializedStore.serialize(); | ||
expect(serializedStore).toEqual(reserializedStore); | ||
}); | ||
}); | ||
}); |
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