Giter VIP home page Giter VIP logo

docker-extension's Introduction

Postman Docker extension

This Docker Desktop Extension runs Postman collections using Postman's open-source CLI, Newman image and Danny Dainton's HTMLextra reporter. Run your API tests or execute an API workflow in any server environment. Then review the results of the collection run.

Newman run results

How it works

Install the Docker Desktop Newman extension: https://hub.docker.com/extensions/joycelin79/newman-extension

  • Enter a Postman API key to retrieve your Postman data
  • Select a collection to run, and optionally select an environment to run with the collection
  • Run the collection, review the results of the API calls, and filter by failed tests

Read the blog announcement

Automate API Tests and Debug in Docker With Postman’s Newman Extension

Watch the demo

Postman Docker extension demo

For local development

Pre-requisites

  • Install Docker Desktop 4.10.0 or higher that includes the Docker extensions CLI.
  • Make sure that Docker Desktop is running in the background. In Docker Desktop, go to the Settings icon > Extensions and check Enable Docker Extensions.
  • Sign up for a free Postman account, and generate an API key. This is used to access your Postman data, like collections and environments.
  • Log in to your Postman account, and create a Postman collection to run. If you don’t have a Postman collection yet, you can fork this example collection to your own workspace. Once you do this, the forked collection will appear as your own collection.

This extension is not published yet, so build and deploy it locally from source code.

Clone the project

Run:

git clone https://github.com/loopDelicious/docker-extension.git

Change into the project directory

Run:

cd docker-extension

Build and install the extension

Run:

make && make install

Build the HTML reporter

Change into the HTML reporter directory:

cd htmlreporter-with-template

From inside the subdirectory, build the reporter image:

docker build -t joycelin79/htmlreporter-with-template:latest .

Developing the frontend

In your terminal, run individually one-by-one:

cd ..
cd client
npm install
npm start

This starts a development server that listens on port 3000.

You can now tell Docker Desktop to use this as the frontend source. In another terminal, run:

docker extension dev ui-source joycelin79/newman-extension:latest http://localhost:3000

In order to open the Chrome DevTools for your extension when you click on the extension tab, run:

docker extension dev debug joycelin79/newman-extension:latest

Code of Conduct

Everyone is welcome to contribute to this project. Please follow the Postman Code of Conduct, and don't be a jerk.

docker-extension's People

Contributors

aniqjaved avatar arjunsharda avatar benja-m-1 avatar felipecruz91 avatar gtardif avatar loopdelicious avatar lucbpz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

docker-extension's Issues

Failed to install extension

Hi, I am getting this error when I try to install the extension.

Failed to install extension: the local image you are trying to install has been modified and is different from the published image joycelin79/newman-extension:0.0.7

Missing files

I tried to clone and build the extension, but it threw the following error:

 make build
docker build --tag=joycelin79/newman-extension:latest .
[+] Building 1.3s (13/17)                                                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                                                  0.0s
 => => transferring dockerfile: 37B                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                     0.0s
 => => transferring context: 34B                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/node:17.7-alpine3.14                                                                                               1.2s
 => [internal] load build context                                                                                                                                     0.0s
 => => transferring context: 976B                                                                                                                                     0.0s
 => CANCELED [client-builder  1/14] FROM docker.io/library/node:17.7-alpine3.14@sha256:539e64749f7dc6c578d744d879fd0ec37f3afe552ae4aca9744cc85121728c4c               0.0s
 => => resolve docker.io/library/node:17.7-alpine3.14@sha256:539e64749f7dc6c578d744d879fd0ec37f3afe552ae4aca9744cc85121728c4c                                         0.0s
 => => sha256:ce3358b66925f144108f66802a25e737a5ac991bf77c27bfd14dddb92d389371 1.16kB / 1.16kB                                                                        0.0s
 => => sha256:ed51fad11ee87160e0d69d19e6a6be7420b4965a516f57f5a713b4ebd634bc33 6.59kB / 6.59kB                                                                        0.0s
 => => sha256:539e64749f7dc6c578d744d879fd0ec37f3afe552ae4aca9744cc85121728c4c 1.43kB / 1.43kB                                                                        0.0s
 => CACHED [client-builder  2/14] WORKDIR /app/client                                                                                                                 0.0s
 => CACHED [client-builder  3/14] COPY client/package.json /app/client/package.json                                                                                   0.0s
 => CACHED [client-builder  4/14] RUN npm config set cache-folder /usr/local/share/.cache/npm-arm64                                                                   0.0s
 => CACHED [client-builder  5/14] RUN --mount=type=cache,target=/usr/local/share/.cache/npm-arm64                                                                     0.0s
 => CACHED [client-builder  6/14] RUN npm install --production                                                                                                        0.0s
 => CACHED [client-builder  7/14] COPY client /app/client                                                                                                             0.0s
 => CACHED [client-builder  8/14] RUN --mount=type=cache,target=/usr/local/share/.cache/npm-arm64     npm run build                                                   0.0s
 => ERROR [client-builder  9/14] COPY client/src/file.hbs /tmp/file.hbs                                                                                               0.0s
------
 > [client-builder  9/14] COPY client/src/file.hbs /tmp/file.hbs:
------
failed to compute cache key: "/client/src/file.hbs" not found: not found
make: *** [build] Error 1

Can the extension persists the PMAK so that I don't have to find it everytime I want to run a collection?

When the extension starts, the first thing to do is to provide the PKAM. The thing is, it is only visible when it is generated. So I somehow have to save it somewhere or recreate a new one everytime I want to use the extension. I wish I can enter the key once and the extension remembers it. If I need to change it then I'd click to a button to reconfigure it.

@loopDelicious WDYT? I think it is feasible with local storage. I am going to give it a try :)

Increase test coverage

I'll accept any PR with new tests, for example:

  • Establish a new framework for adding tests - no test framework exists so far
  • Unit tests for the Postman API calls
  • Run Postman tests in Dockerfile
  • Docker build tests (to run locally when building locally)
  • Other ideas?

Image not build for linux/arm64

The extension is trying to run the image joycelin79/htmlreporter-with-template:latest that is only built for amd64 https://hub.docker.com/r/joycelin79/htmlreporter-with-template/tags

Screenshot 2022-10-10 at 11 15 27

The extension throws the following error when running in a non-intel Mac:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

The quick fix is to build joycelin79/htmlreporter-with-template for multi-architectures:

docker buildx build --platform linux/arm64,linux/amd64 -t joycelin79/htmlreporter-with-template:latest . --push

If you're using Github actions to build the image, I can provide you the steps to do the same.

The not-so-quick fix is to use that image as the extension's VM. This will allow you to do things like this:

let newmanURL = "https://api.getpostman.com/collections/" + collectionID +"?apikey=" + apiKey;
await ddClient.extension.host.cli.exec("newman", ["run", "newmanURL", "..."], {
  stream: {
    onOutput(data: { stdout: string } | { stderr: string }): void {
      if (data.stdout) {
        console.error(data.stdout);
      } else {
        console.log(data.stderr);
      }
    },
    onError(error: any): void {
      console.error(error);
    },
    onClose(exitCode: number): void {
      console.log("onClose with exit code " + exitCode);
    },
  },
});

I understand this change requires more time and knowledge, but I just wanted to point the way :)

https://docs.docker.com/desktop/extensions-sdk/dev/api/backend/#invoke-an-extension-binary-on-the-host

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.