Script

Script type test is used to run custom scripts

[
    {
        "name": "<string>", // Text of the test, users will see this if test will fail
        "type": "script", // Test type e.g: script, http .. 
        "command": "<string>",
            // Command that script will execute e.g.: 
            // (1) ls /home/labs/flask-app 
            // (2) az network public-ip show --name my-ip --resource-group "test"
            // (3) python /my/directory/app.py
        "result": "<string>"
            // Parses result that command above return and looks for word that is in result field e.g.
            // (1) my-test-folder
            // (2) 10.23.23.14
            // (3) hello-world
    }
]

Lets use example (3):

App.py is expected to be created by the user and store in the /user/app/app.py folder.

As a lab creator you should explain how file should be written and in which folder it has to be saved.

i=0
while True:
    i+=1
    print("doing some work..")
    if i == 10:
        print("finished successfully")
        break

our test will look like this:

[
    {
        "name": "Python test failed, app.py didn't run successfully",
        "type": "script",
        "command": "python /user/app/app.py",
        "result": "finished successfully"
    }
]

HTTP(S)

Http type test is used check for correct http response

[
    {
        "name": "Some http test", 
        "type": "http", // http(s) both is = http
        "endpoint": "http://localhost:3000", 
        "expectedStatus": 200
    }
]

Example:

Lets write http service in python using Flask that should return some result on the web page and listen on port 5000

from flask import Flask

app = Flask(__name__)
@app.route('/my-python-api')

def home():
    return "Hello, World!"
if __name__ == '__main__':
    app.run(port=5000)

our test will look like this:

[
    {
        "name": "app.py failed - Application didn't respond correctly",
        "type": "http",
        "command": "http://user.env.prepare.sh:5000/my-python-api",
        "result": "200"
    }
]