Commit f38054fd authored by Thomas Leymonerie's avatar Thomas Leymonerie

software/slapos-testing slapos-sr-testing: Use macro virtual-env

Now, the macro `virtual-env` is used in slapos-testing and slapos-sr-testing.

`virtual-env` provide a `deactivate` function to exit tesing environment
and a custom variable of `PS1` to know if we are in a test environment.
parent b245c546
......@@ -15,4 +15,4 @@
[template]
filename = instance.cfg
md5sum = 06379c0ed1fe0df409c7b8f61fc218eb
md5sum = d8e4c368ce1ef276d4f3f3de5b2104cd
[buildout]
extends = {{ nxdtest_instance }}
parts +=
extends =
{{ nxdtest_instance }}
{{ virtual_env }}
parts =
runTestSuite
publish
[slap-configuration]
......@@ -27,14 +30,26 @@ var = ${buildout:directory}/var
test-working-dir = ${buildout:directory}/tmp
nxdtest-working-dir = ${:var}/nxdtest
[slapos-test-runner-nxdtest-environment.sh]
recipe = slapos.recipe.template
output = ${directory:etc}/${:_buildout_section_name_}
inline =
export PATH={{ buildout['bin-directory'] }}:{{ curl_location }}/bin:{{ faketime_location }}/bin:{{ openssl_location }}/bin:/usr/bin:/bin
export SLAPOS_TEST_IPV4=${slap-configuration:ipv4-random}
export SLAPOS_TEST_IPV6=${slap-configuration:ipv6-random}
export SLAPOS_TEST_WORKING_DIR=${directory:test-working-dir}
[test-runner]
<= virtual-env-base
location = ${directory:etc}/slapos-test-runner-nxdtest-environment.sh
default-instance = false
{% set shared_part_list = [] %}
{% for shared_part in buildout['shared-part-list'].splitlines() -%}
{% do shared_part_list.append(shared_part) %}
{%- endfor %}
environment =
PATH = {{ buildout['bin-directory'] }}:{{ curl_location }}/bin:{{ faketime_location }}/bin:{{ openssl_location }}/bin:/usr/bin:/bin
SLAPOS_TEST_IPV4 = ${slap-configuration:ipv4-random}
SLAPOS_TEST_IPV6 = ${slap-configuration:ipv6-random}
SLAPOS_TEST_WORKING_DIR = ${directory:test-working-dir}
SLAPOS_TEST_SHARED_PART_LIST = {{ os.pathsep.join(shared_part_list) }}:$SLAPOS_TEST_SHARED_PART_LIST
message =
Environment loaded.
The embedded SlapOS is in $SLAPOS_TEST_WORKING_DIR
To work on a test, execute:
SLAPOS_TEST_DEBUG=1 {{ interpreter }} -m unittest discover -v
from a folder containing software release test.
[slapos-test-runner-dot-nxdtest]
recipe = slapos.recipe.template:jinja2
......@@ -70,26 +85,9 @@ context =
raw interpreter {{ interpreter }}
[runTestSuite]
env.sh = ${slapos-test-runner-nxdtest-environment.sh:output}
env.sh = ${test-runner:location}
workdir = ${slapos-test-runner-dot-nxdtest:workdir}
[slapos-local-development-environment.sh]
recipe = slapos.recipe.template
output = ${directory:etc}/${:_buildout_section_name_}
inline =
source ${slapos-test-runner-nxdtest-environment.sh:output}
{% set shared_part_list = [] %}
{% for shared_part in buildout['shared-part-list'].splitlines() -%}
{% do shared_part_list.append(shared_part) %}
{%- endfor %}
export SLAPOS_TEST_SHARED_PART_LIST={{ os.pathsep.join(shared_part_list) }}
echo "Environment loaded."
echo "The embedded SlapOS is in $SLAPOS_TEST_WORKING_DIR"
echo "To work on a test, execute:"
echo " SLAPOS_TEST_DEBUG=1 {{ interpreter }} -m unittest discover -v"
echo "from a folder containing software release test."
echo
[publish]
recipe = slapos.cookbook:publish
environment-script = ${slapos-local-development-environment.sh:output}
environment-script = ${test-runner:location}
......@@ -27,6 +27,9 @@ parts =
shared-part-list =
[macro-venv]
location = ${:_profile_base_location_}/../../component/macros/virtual-env.cfg
[setup-develop-egg]
recipe = zc.recipe.egg:develop
......@@ -340,6 +343,7 @@ context =
key openssl_location openssl-output:bin
key faketime_location faketime:location
key tests :tests
key virtual_env macro-venv:location
tests =
json-schemas ${slapos.cookbook-setup:setup}
......
......@@ -15,4 +15,4 @@
[template]
filename = instance.cfg
md5sum = 159789ad29ab2b1f4f9778e121d4133d
md5sum = 71352a4c49206a6e048914daae6d7970
[buildout]
extends =
${nxdtest-instance.cfg:output}
${:_profile_base_location_}/../../component/macros/virtual-env.cfg
${macro-venv:location}
parts =
runTestSuite
publish
test-venv
[test-venv]
<= virtual-env-base
location = ${buildout:directory}/activate
default-instance = false
environment =
one = 1
two = 2
message =
je suis un test
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
......@@ -102,18 +91,22 @@ repository = ${slapos.rebootstrap-repository:location}
<= download-source
repository = ${rubygemsrecipe-repository:location}
[slapos-test-runner-nxdtest-environment.sh]
recipe = slapos.recipe.template
output = $${create-directory:etc}/$${:_buildout_section_name_}
inline =
export PATH=${coreutils:location}/bin:${curl:location}/bin:${openssl:location}/bin:${jq:location}/bin:${sed:location}/bin:${grep:location}/bin:${git:location}/bin:${libxslt:location}/bin:${socat:location}/bin:${lmsensors:location}/bin:${rsync:location}/bin/:${buildout:bin-directory}:$PATH
export SLAPOS_TEST_IPV4=$${slap-configuration:ipv4-random}
export SLAPOS_TEST_IPV6=$${slap-configuration:ipv6-random}
export SLAPOS_TEST_EGGS_DIRECTORY=$${buildout:eggs-directory}
export SLAPOS_TEST_DEVELOP_EGGS_DIRECTORY=$${buildout:develop-eggs-directory}
export SLAPOS_TEST_POSTGRESQL_PREFIX=${postgresql:location}
[test-runner]
<= virtual-env-base
location = $${create-directory:etc}/slapos-test-runner-nxdtest-environment.sh
default-instance = false
environment =
PATH=${coreutils:location}/bin:${curl:location}/bin:${openssl:location}/bin:${jq:location}/bin:${sed:location}/bin:${grep:location}/bin:${git:location}/bin:${libxslt:location}/bin:${socat:location}/bin:${lmsensors:location}/bin:${rsync:location}/bin/:${buildout:bin-directory}:$PATH
SLAPOS_TEST_IPV4=$${slap-configuration:ipv4-random}
SLAPOS_TEST_IPV6=$${slap-configuration:ipv6-random}
SLAPOS_TEST_EGGS_DIRECTORY=$${buildout:eggs-directory}
SLAPOS_TEST_DEVELOP_EGGS_DIRECTORY=$${buildout:develop-eggs-directory}
SLAPOS_TEST_POSTGRESQL_PREFIX=${postgresql:location}
message =
Environment loaded.
To work on a test, execute:
$${runTestSuite:wrapper-path} -k test_name
replacing test_name by the name of the test.
[slapos-test-runner-dot-nxdtest]
recipe = slapos.recipe.template
......@@ -216,20 +209,9 @@ inline =
)
[runTestSuite]
env.sh = $${slapos-test-runner-nxdtest-environment.sh:output}
env.sh = $${test-runner:location}
workdir = $${slapos-test-runner-dot-nxdtest:workdir}
[slapos-local-development-environment.sh]
recipe = slapos.recipe.template
output = $${create-directory:etc}/$${:_buildout_section_name_}
inline =
source $${slapos-test-runner-nxdtest-environment.sh:output}
echo "Environment loaded."
echo "To work on a test, execute:"
echo " $${runTestSuite:wrapper-path} -k test_name"
echo "replacing test_name by the name of the test."
echo
[publish]
recipe = slapos.cookbook:publish
environment-script = $${test-venv:location}
environment-script = $${test-runner:location}
......@@ -30,6 +30,10 @@ parts =
phantomjs
template
[macro-venv]
location = ${:_profile_base_location_}/../../component/macros/virtual-env.cfg
[bootstrap-slapos.recipe.cmmi]
# install our develop version of slapos.recipe.cmmi before anything else,
# otherwise it will be installed from pypi by dependencies.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment