Test Your Software Release

Agenda

  • Prerequisite
  • Supply and Request "slapos-sr-testing"
  • Run Tests

Any Software release used in production should be tested.

Manual test are handled by slapos-sr-testing software release. This tutorial is an illustration of the README of this software release in the context of Theia runner and html5as-base.

Prerequisite

Prepare Supply and Request for Slapos SR Testing

Create a new file request-sr-testing.sh by duplicating the request-script.sh and change the value of software_name to slapos-sr-testing and set software_release_uri to https://lab.nexedi.com/nexedi/slapos/raw/1.0/software/slapos-sr-testing/software.cfg in order to make sure you get the latest version indepedently of your local changes.

#!/bin/sh
software_name=slapos-sr-testing
software_release_uri=https://lab.nexedi.com/nexedi/slapos/raw/1.0/software/slapos-sr-testing/software.cfg
# slapos supply is used to add the software to the software list to be supplied to a node.
slapos supply $software_release_uri slaprunner
# slapos request the allocation of an instance to the master.
# slapos request also gets status and parameters of the instance if it has any
# (slapos request is meant to be run multiple time until you get the status).
slapos request $software_name'_1' $software_release_uri

Run Supply and Request for Slapos SR Testing

Run the request.

$ bash ~/srv/project/request-sr-testing.sh

Wait for Installation

Compile the software by

$ slapos node software --all

Once it completes, you may re-instantiate it by

$ slapos node instance --all

Check the output to make sure it has been deployed and installed.

Get Parameters and set environment

Run the request.

$ bash ~/srv/project/request-sr-testing.sh
2021-04-22 11:14:46 slapos[37985] INFO Requesting software installation of https://lab.nexedi.com/nexedi/slapos/raw/1.0/software/slapos-sr-testing/software.cfg...
2021-04-22 11:14:46 slapos[37985] INFO Done.
2021-04-22 11:14:47 slapos[38044] INFO Requesting slapos-sr-testing_1 as instance of https://lab.nexedi.com/nexedi/slapos/raw/1.0/software/slapos-sr-testing/software.cfg...
2021-04-22 11:14:47 slapos[38044] INFO Instance requested.
State is : started.
2021-04-22 11:14:47 slapos[38044] INFO Connection parameters of instance are:
2021-04-22 11:14:47 slapos[38044] INFO {'environment-script': '/srv/slapgrid/slappartXX/srv/runner/instance/slappartX/etc/slapos-local-development-environment.sh'}
2021-04-22 11:14:47 slapos[38044] INFO You can rerun the command to get up-to-date information.

Copy the path of "environment-script" and run the following command where the path after source is the path you copied. It return the instruction on how to run a test.

$ source /srv/slapgrid/slappartXX/srv/runner/instance/slappartX/etc/slapos-local-development-environment.sh
Environment loaded.
The embedded SlapOS is in /srv/slapgrid/slappartXX/srv/runner/instance/slappartX/tmp
To work on a test, execute:
   SLAPOS_TEST_DEBUG=1 python_for_test -m unittest discover -v
from a folder containing software release test.

Go to your test folder

$ cd ~/srv/project/slapos/software/html5as-base/test/

If the test directory is not existed, please get the latest version of html5as-base from gitlab by:

$ git stash
$ git fetch
$ git reset --hard origin/master
$ git stash pop

Run the test

Run your test by running the command returned when setting the environment.

$ SLAPOS_TEST_DEBUG=1 python_for_test -m unittest discover -v

The end of the output should be like: 

test_deploy_with_no_paramater (test.TestEmptyDeploy) ... ok
----------------------------------------------------------------------
Ran 1 test in 24.747s
OK

If you have modified html5as-base the test will fail. You can try to fix it in slapos/software/html5as-base/test/test.py or check the tutorial on how to edit tests.

 

Attention: once the test is launched, DO NOT attempt to stop it by pressing ctrl + c. The test will never stop and you will not be able to launch the test again due to the conflicts.  
However, If you unfornately hit the runtime error ("SlapOS not started"), you can use the command line to kill the process:

ps -u $(whoami) | grep python_for_test

Thank You

  • Rapid.Space
  • 147 Rue du Ballon
  • 59110 La Madeleine
  • France
  • +33629024425
  • contact (@) rapid.space

For more information, please contact Jean-Paul, CEO of Rapid.Space (+33 629 02 44 25).