Code Monkey home page Code Monkey logo

guardian's Introduction

Subutai Guardian

Protects and alerts peer and resource host owners. Just ideas at this point to fix a lot of our headaches.

Using Subutai Guardian

To get help about this tool you can simply run python3 main.py with no arguments provided.

Arguments:

  • list - list all test components. Test component is a group of tests related to specific component, e.g. p2p, peeros etc.
  • list componentName - list all registered tests inside a component
  • run - run all registered tests
  • run componentName - run all tests inside specified component
  • run componentName.testName - run specific test

Writing tests

If you want to extend this tool with additional tests you need to perform the following steps:

  1. Create a separate file for your tests. It's better to use the form of componentName_testName.py 1.a. If your component is completely new you need to create a new file named componentName.py and add it to import list in main.py (see p2p.py for example)
  2. In your test file define the following functions:
  • Executor(t) - main entry point for your test. This function accepts Test class object as an argument
  • ResultHandler(t, result) - function that will handle results provided by Executor(). In this function you need to define a logic, that will decide whether your test was failed or not. Inside this method you need to call t.MarkAsSucceed() if test succeed or t.MarkAsFailed() otherwise. ResultHandler must return an instance of Result class.
  • Test() function must create an instance of Test class, providing component name, test name and setting Executor and ResultHandler callbacks
  1. Final step is to open your componentName.py file and add a call of t.RegisterTest function with callback to Test() function that you defined in a previous step

You can use files p2p.py and p2p_daemon.py as an example.

Handling test results

To understand the idea behind ResultHandler() function we can look at p2p status test. This test will execute p2p status command and pass result to this handler function. Result is a tuple of 3 elements: exit code, stdout, stderr. In this particular case we want to know whether p2p have broken connections or not. So, inside a ResultHandler() function we're taking stdout of p2p status and see if it contains 'DISCONNECTED' or 'WAITING_CONNECTION' keywords. If we have such keywords we consider test as failed and execute t.MarkAsFailed(). Then we create an instance of Result class and return it.

Output

Subutai Guardian generated YAML file (TBD) for each test in the following format:

    component: componentName
    name: testName
    timestamp: 1533554195
    status: 0
    peer: <peer_id>
    payload:
        extraField1: value1
        extraField2: value2

List of tests and components

p2p

  • daemon (p2p_daemon.py) - check status of p2p daemon
  • status (p2p_status.py) - executes p2p status command

guardian's People

Contributors

akarasulu avatar crioto 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.