Coder Social home page Coder Social logo

unittest2canopsis's Introduction

UnitTest to Canopsis connector

https://travis-ci.org/linkdd/unittest2canopsis.svg?branch=master

This package provides a connector which will executes Python unittest to generate events for Canopsis.

Usage

In this example, we will use the following test (as mytest.py):

# -*- coding: utf-8 -*-

import unittest


class MyTestCase(unittest.TestCase):
    def test_success(self):
        self.assertTrue(True)

    def test_fail(self):
        self.assertFalse(True)


if __name__ == '__main__':
    unittest.main()

Run the unittest on :

$ unittest2canopsis -t mytest.py -n mytest0 -a "amqp://guest:guest@localhost:5672/"
unittest.mytest0.check.resource.MyTestCase.test_fail... FAIL
unittest.mytest0.check.resource.MyTestCase.test_success... OK

You can also use a JSON configuration file :

{"tcp2canopsis": {
    "test": "mytest.py",
    "testname": "mytest0",
    "amqp": "amqp://guest:guest@localhost:5672/"
}}

And load the file using :

$ unittest2canopsis -c path/to/config.json

Example of generated events :

{
  "timestamp": 1418206046,
  "connector": "unittest",
  "connector_name": "mytest0",
  "event_type": "check",
  "source_type": "resource",
  "component": "MyTestCase",
  "resource": "test_fail",
  "state": 2,
  "state_type": 1,
  "output": "Traceback (most recent call last):\n  File \"mytest.py\", line 11, in test_fail\n    self.assertFalse(True)\nAssertionError: True is not false\n"
}
{
  "timestamp": 1418206046,
  "connector": "unittest",
  "connector_name": "mytest0",
  "event_type": "check",
  "source_type": "resource",
  "component": "MyTestCase",
  "resource": "test_success",
  "state": 0,
  "state_type": 1,
  "output": "OK"
}

Installation

Just type :

$ pip install unittest2canopsis

Or, to install it in a locally :

$ ./makefile

This will create a virtual Python environment in the current folder, and install the dependencies listed by requirements.txt. Finally, it will perform a python setup.py install.

After executing this script, the connector will be available in the current folder (which is now a virtual Python environment).

unittest2canopsis's People

Contributors

linkdd avatar

Watchers

 avatar  avatar  avatar

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.