Skip to content

A simple tool to ensure compatibility between microservices

Notifications You must be signed in to change notification settings

jmartin82/compatip

Repository files navigation

Compatip Build Status codecov

Compatip it's a simple tool to ensure compatibility between microservices.

Description

Compatip has been designed as a part of the checks that you should run in your CI/CD pipeline.

With Compatip you can specify the service you want to check and the version constraints you would like to validate. In case of incompatibility, the application will fail with a recognizable error code.

So far, Compatip supports REST and gRPC+Protobuf communications, Semver semantics (MAJOR.MINOR.PATCH) to ensure the compatibility between services and it's also able to use JSON dot notation to extract the version from the service response.

TL;DR

CMD assert version

Usage

Check Command

Checks the current version of the service.

Example: compatip check --jsonpath app.version http://myservice:8080/version.json

Exit codes:

0: All Ok.
2: Input argument error.
3: Error on server communication.
4: Invalid version response.

Assert Command

Asserts the current version of the service with the specified constraints.

Example: compatip assert grpc://myservice:50051/rpc/versionservice/current ">1.4.10"

Exit codes:

0: All Ok.
1: Incompatible service version.
2: Input argument error.
3: Error on server communication.
4: Invalid version response.

Examples

Check service version

HTTP (GET verb) request to the service:

CMD check version

Extracting the version from json:

Server response:

{
   "app": {
      "version" : "v1.3.24"
   }
}

CMD check version

gRPC request to the service:

CMD check version

Due to the nature the protobuf the service should answer with this very same message format.

message VersionMessage {
  string version = 1;
}

Assert service version

Assert exact version:

CMD assert version

Assert version range:

Greater than 1.2:

CMD assert version

Greater than 1.2 and lower than 1.4:

CMD assert version

Incompatible range:

CMD assert version

Install

To install, use go get:

$ go get -d github.com/jmartin82/jmartin82

Installation

Binary Release (Linux/OSX)

You can manually download a binary release from the release page.

Automated install/update, don't forget to always verify what you're piping into bash:

curl https://raw.githubusercontent.com/jmartin82/compatip/master/scripts/install_compatip.sh | bash

Go

Required go version: 1.12+

go get github.com/jmartin82/compatip

DEB and RPM

You can manually download a DEB and RPM packages release from the release page

sudo dpkg -i compatip_XXX_linux_amd64.deb

OR

sudo rpm –i compatip_XXX_linux_amd64.rpm

Contribution

  1. Fork (https://github.com/jmartin82/compatip/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Licence

Copyright © 2019, Jordi Martín (http://jordi.io)

Released under MIT license, see LICENSE for details.