loading...

Postman-Newman, wherever you go.

rohithmenon89 profile image Rohith Menon ・1 min read

Postman-Newman

GitHub logo postmanlabs / newman

Newman is a command-line collection runner for Postman

I have been writing Postman-Newman tests for a couple of years now.
A new carrier move for a software developer will give new challenges to solve. But most of these new challenges could be resolved using a solution/framework/process which he/she is familiar with.

In my case when I moved to FREE NOW(earlier mytaxi), there were projects being migrated to Spring Cloud Config. There is documentation on Steps to migrate and clearly mentioned do's and dont's.

There were mistakes during past migrations and projects are being misconfigured. However, software engineers learn from mistakes and we thought of some process in place for some kind of identification, later notification and finally rectification.

This is when we came up with The Hero (Postman-Newman).

The test or collection of tests includes some bunch of API tests that check whether the configurations are correct or not.

GitHub logo jango89 / postman-test-validate-spring-cloud-configuration

Docker image for validating ConnectionFactory created are not overriden for spring cloud projects.

What

Postman Tests for validating
1. ConnectionFactory created for spring cloud projects.
2. Test webhook is created in the configuration project.
Base image is - newman-postman.

Why

  1. By default spring cloud migrated projects should have property as follows to notify the application about configuration changes spring.rabbitmq.host=configbus.mgmt.mytaxi.com This docker image has POSTMAN TESTS which runs and validates the prelive and live environment has not overriden this property Overriding this property will create issues with notifying config changes to app.

  2. Spring cloud also needs a webhook in the configuration repository for listening to config file changes. The test also checks min 1 webhook is present in the configuration repository.

How

Create a task and add to DefaultPlan in bamboo spec in case missing.

private static DockerRunContainerTask getCloudConfigurationPostmanTest()
{
    return new DockerRunContainerTask()
        .description("Check spring.rabbitmq.host mapped to config server")
        .imageName("docker.intapps.it/configservertest:latest")
        .serviceURLPattern("http://localhost:${docker.port}")
        .containerCommand("run api.json --global-var \"servicename=bookingoptionsservice\"")
        .containerWorkingDirectory("/etc/newman")
        .clearVolumeMappings();
}
 private static Stage getDefaultStage()
{

Why am I so in favor

  1. Only need to know Request URI to test.
  2. No basic knowledge is required to write assertions. Of course, we write assertions using javascript however, with an effective documentation there is a very less knowledge curve.
  3. Easy to plugin the tests to various environments (automated build platforms, docker, linux, mac).

Posted on Aug 16 '19 by:

rohithmenon89 profile

Rohith Menon

@rohithmenon89

#startups #techenthusiast #java #js #tech #linux #datastructures #patternlover #arsenal #gooner #arsenalmyfirstlove

Discussion

markdown guide