Skip to content

Service tests#

General information about tests#

You can launch automated tests for LUNA PLATFORM services.

You should run tests on an empty database only. Errors will occur if the database already contains data.

The service testing can be skipped during the installation, but it is recommended to perform testing. Tests enable you to make sure that the tested service and all the linked services are working properly.

You can test most of the Python services after their launch. API and Admin services must be tested only after all other services launch.

The testing result is outputted to the console. The testing example is given below:

[root@localhost]# docker exec luna-faces python3.9 -m unittest tests.unittests_main

....................................................................
....................................................................
....................................................................
...................................................................s
....................................................................
..............................s..............................

----------------------------------------------------------------------

Ran 401 tests in 249.803s



OK (skipped=2)

The actual number of tests may be different since test sets are constantly updated and new tests are added.

The "." symbol denotes successfully finished tests.

The "s" symbol denotes skipped tests. The tests were disabled for some reason.

The "F" symbol denotes failed tests. These tests were executed but the result of the test is incorrect. The problem description is outputted to the console after all the tests are finished.

FAIL: test_emit_events_source_and_tags (tests.unittests_emit_events.TestEmitEvents) (param='tags')

----------------------------------------------------------------------

Traceback (most recent call last):

 File "/var/lib/luna/luna_11470331eaf91f4c30864ce45d4af6a0ce70ba97/luna-api/tests/unittests_emit_events.py", line 150, in test_emit_events_source_and_tags

   self.assertEqual(201, reply.statusCode, reply.text)

AssertionError: 201 != 500 : {"error_code":2104,"desc":"Queue driver call failed","detail":"RabbitMQ MessageReturnedException: Message returned. Reply code: 312 NO_ROUTE correlation id: 1,13f23ce3-88ae-4723-b407-7ff372554986"}

The "E" symbol denotes runtime errors. They show that the test cannot be completed for some reasons. Descriptions of errors are outputted to the console after all the tests are finished.

======================================================================

ERROR: test_bad_event_time (tests.unittests_handler_events.TestHandlerEvents)

----------------------------------------------------------------------

Traceback (most recent call last):

 File "/var/lib/luna/luna_11470331eaf91f4c30864ce45d4af6a0ce70ba97/luna-api/tests/unittests_handler_events.py", line 100, in test_bad_event_time

  self.attributes.append(reply.json['events'][0]['attributes']['attribute_id'])

KeyError: 'events'

Errors can occur for various reasons:

  • configurations of the service are incorrect,

  • one or more required services or databases were not launched,

  • access to one or several servers with required services is denied,

  • license key is missing,

  • configuration files of the service test include invalid parameters,

  • etc.

Launch tests#

This section includes launching commands for testing all the LUNA PLATFORM services.

You should run tests for the services that were launched and configured for working.

It is considered that the tests are launched on empty databases.

Liveness test launch#

Liveness tests are performed using the API service. The Liveness V1 service should be installed and enabled if you are using Liveness V1. See the "Enable Liveness service" section.

First way:

  • Enter the API, Backport 3, and Backport 4 containers (See "Docker commands").
  • Open the test file.
vi tests/config.py
  • If you are entered into the API container then change the LICENSE_LIVENESS_VALUE value to 1.
LICENSE_LIVENESS_VALUE = 1
  • If you are entered into the Backport 3 or Backport 4 container then change the USE_LIVENESS value to 1.
USE_LIVENESS = 1
  • Save changes to file and run API, Backport 3 and Backport 4 tests.

Second way:

docker exec -it luna-api sed -i 's/LICENSE_LIVENESS_VALUE.*/LICENSE_LIVENESS_VALUE = 1/' tests/config.py
docker exec -it luna-backport3 sed -i 's/USE_LIVENESS.*/USE_LIVENESS = 1/' tests/config.py
docker exec -it luna-backport4 sed -i 's/USE_LIVENESS.*/USE_LIVENESS = 1/' tests/config.py

Commands for launching tests#

You should launch the tests for the launched services only. Make sure that the usage of not launched services is disabled in the Configurator service (if required).

API tests#

Disable Python Matcher Proxy tests (the service is not used by default):

docker exec -it luna-api sed -i 's/USE_MATCHER_PROXY.*/USE_MATCHER_PROXY = 0/' tests/config.py

Run tests:

docker exec luna-api python3.9 -m unittest tests.unittests_main

Handlers tests#

Run tests:

docker exec luna-handlers python3.9 -m unittest tests.unittests_main

Faces tests#

Run tests:

docker exec luna-faces python3.9 -m unittest tests.unittests_main

Python Matcher tests#

Run tests:

docker exec luna-python-matcher python3.9 -m unittest tests.unittests_main

Admin tests#

Change the following parameters before launching tests:


docker exec -it luna-admin sed -i 's/USE_LIVENESS.*/USE_LIVENESS = 0/' tests/config.py
docker exec -it luna-admin sed -i 's/USE_LPM_PROXY.*/USE_LPM_PROXY = 0/' tests/config.py
docker exec -it luna-admin sed -i 's/USE_LUNA_SENDER.*/USE_LUNA_SENDER = 1/' tests/config.py

Run tests:

docker exec luna-admin python3.9 -m unittest tests.unittests_main

Image Store tests#

Run tests:

docker exec luna-image-store python3.9 -m unittest tests.unittests_main

Tasks tests#

Run tests:

docker exec luna-tasks python3.9 -m unittest tests.unittests_main

Sender tests#

Run tests:

docker exec luna-sender python3.9 -m unittest tests.unittests_main

Events tests#

Run tests:

docker exec luna-events python3.9 -m unittest tests.unittests_main

Licenses tests#

Run tests:

docker exec luna-licenses python3.9 -m unittest tests.unittests_main

Backport 3 tests#

Disable Python Matcher Proxy tests (the service is not used by default):

docker exec -it luna-backport3 sed -i 's/USE_MATCHER_PROXY.*/USE_MATCHER_PROXY = 0/' tests/config.py

Run tests:

docker exec luna-backport3 python3.9 -m unittest tests.unittests_main

Backport 4 tests#

Disable Python Matcher Proxy tests (the service is not used by default):

docker exec -it luna-backport4 sed -i 's/USE_MATCHER_PROXY.*/USE_MATCHER_PROXY = 0/' tests/config.py

Enable the Sender service tests (the service is used default):

docker exec -it luna-backport4 sed -i 's/USE_LUNA_SENDER.*/USE_LUNA_SENDER = 1/' tests/config.py

Run tests:

docker exec luna-backport4 python3.9 -m unittest tests.unittests_main
Back to top