npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

synthetics-canaries-e2e-tests-runner

v0.0.7

Published

> The APIs of higher level constructs in this module are experimental and under active development. > They are subject to non-backward compatible changes or removal in any future version.

Downloads

11

Readme

CDK End to End (E2E) tests runner

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version.

Overview

This construct parallelise and check the results of end to end tests.

Pipeline integration

pipelineInteg

Usage

Check API doc for more details.

Integrate to CDK Pipelines

Assuming you have declared your pipeline in your CDK app using cdk pipelines (which imply having "newStyleStackSynthesis" cdk context key to true in your cdk.json):

class MyPipelineStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const pipeline = new cdkpipeline.CodePipeline(this, 'Pipeline', {
      ...
    });
    ...
    const myAppStage = new MyApplicationStage(this, 'Demo', {});
    const demoStage = pipeline.addStage(myAppStage);
    ...

then you can:

  1. Add some Cloudwatch synthetics canary declaration in your pipeline stack constructor (MyPipelineStack in above example):

    const testAPI = new synthetics.Canary(this, 'Dummy Test', {
      canaryName: 'pass-test',
      schedule: synthetics.Schedule.once(),
      test: synthetics.Test.custom({
        code: synthetics.Code.fromInline('exports.handler = (event, context) => {console.log("hello")}'),
        handler: 'index.handler',
      }),
      runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_1,
    });
  2. Then let's create a custom step using the e2e tests Step provided by this construct and pass the canaries to run as e2e test as well as potention cfnOutput that your synthetic canary test might need (the api url to test for instance).

    const e2eTestsRunnerStep = new E2ETestsStep('E2ETestsRunner', {
      scope: this,
      canaries: [testAPI],
      inputsFromDeployedStack: [myApp.demoApiUrlCfnOutput],
    });

    PS: you can access your stack outputs (Cfn Output) from your synthetics canary runtime through SSM parameter store. The construct will store all outputs given in inputsFromDeployedStack as parameters (under the output's ExportName key) in the account hosting the canary.

    // In your canary
    const AWS = require('aws-sdk');
    const ssmClient = new AWS.SSM();
    const url = await ssmClient.getParameter({Name: 'DemoApiUrl'}).promise();
  3. Add your step E2E step to your stage

    demoStage.addPost(e2eTestsRunnerStep);
  4. Add a ShellStep with the same outputs to workaround https://github.com/aws/aws-cdk/issues/16036

     demoStage.addPost(new cdkpipeline.ShellStep('Force namespace setup', {
     envFromCfnOutputs: {
       URL: myApp.demoApiUrlCfnOutput,
     },
     commands: ['echo "CDK issue workaround"'],
    }));
  5. Commit and deploy your pipeline

  6. Check your pipeline for the e2e test step pipeline

  7. Check the step function execution

sfn

Check src/integrationTests for a full example.

Integrate to your stack

TODO

Additional Notes

  • If one test fail other still run till ends.

Roadmap

  • Support stack auto rollback integration
  • Support Other type of test runner (Synthetics canary only for now)
  • Support Github Action integration

Use Cases

Here are some examples of use cases for this construct:

  • Black box e2e testing and pipelines integration
  • Add a step to run e2e tests after a stage deployment to block your pipeline
  • Stack e2e test to auto rollback
  • This "resource" can be integrated directly in the main stack to make profite of auto rollback in case of failure.

Inspiration

AWS re:Invent 2020: Canaries in the code mines: Monitoring deployment pipelines

License

This project is licensed under the Apache-2.0 License.