Eager to get started? This page gives a good introduction in how to get started with Knowru.

Creating a microservice

Preparing a microservice in R

  1. Open a text editor and copy & paste the following
  2.                                 run <- function(data) {
                                        return(list(sum=data$a + data$b))
  3. Save the file as knowledge.R in a directory of your choice.

Preparing a microservice in Python

  1. Open a text editor and copy & paste the following
  2.                             def run(data):
                                    return {"sum": data["a"] + data["b"]}
  3. Save the file as knowledge.py in a directory of your choice.

Creating a runnable

  1. Log in and create “Runnables” on the top menu
  2. Click “Create Runnable” on the top right
  3. Enter a title, choose the language and select knowledge file (knowledge.R or knowledge.py), requirement file (packrat.lock or requirement.txt) and miscellaneous files (please refer Appendices 1 and 2 for more information on the requirement and miscellaneous files). Then click “Create”
  4. Click the title of the new runnable to move to the runnable’s detail page. Wait until the status of the first version changes from building to ready.

Making the first run request

  1. Click the title of the new runnable created
  2. Click "View Runs" button
  3. Click "Run" button
  4. Enter input in JSON that your microservices expect. In our case we need to provide an object with two keys a and b. Then click “Run” button
  5. This will redirect you to a list of recent runs where you can find the output

Testing a microservice

Creating a test using a file

  1. Create a semi-colon(;)-delimited file that contains input json, expected output json and maximum response time in milliseconds. An example is provided below
  2.                                 input_json;output_json;max_response_time
                                    {"a": 3, "b": 4};{"sum": 7};200
                                    {"a": -1, "b": 2};{"sum": 1};200
                                    {"a": 0, "b": 0};{"sum": 3};200
                                    {"a": 3, "b": 4};{"sum": 7};1
  3. Click "View Tests" button
  4. Click "Create Test" button
  5. Enter title, choose the test file we just created and click “Create Test”
  6. Click title of the new test. This will direct you to the test’s detail page
  7. Make sure all test cases are listed in “Scenarios”

Adding a scenario manually

  1. In a scenario’s detail page, click “Add Scenario”
  2. Click "Add Scenario" button
  3. Enter input json, expected json and maximum response time. Click “Add Scenario.” If there is an already existing scenario with the same input and expected json, only the one with the less maximum response time will remain.

Running a test on a runnable

  1. In test detail page, click "Test Runnable"
  2. Choose a test that you want to run for this runnable. Then click “Test Runnable”
  3. This will direct you to a list of test results on the runnable. Wait until your test request is complete
  4. Click the name of the test result to check the test result. You can see what scenarios passed and failed and why they failed

More information of Knowru please refer to Documents of Knowru