Commit d9ad0da5 authored by Jérome Perrin's avatar Jérome Perrin

slaprunner: support shared parts

If slaprunner itself was installed on a slapos which had shared parts
enabled, these shared parts will also be used while installing softwares
inside the slaprunner.
parent db718c03
......@@ -14,11 +14,11 @@
# not need these here).
[template]
filename = instance.cfg
md5sum = c44a7481bb85e3258128afe3fcf23f44
md5sum = 0c5f5577b295e0bcc762fce46a11aaf5
[template-runner]
filename = instance-runner.cfg
md5sum = 5d533661405a6c3a66662ea02a811ddc
md5sum = c994113c5d332e5d20fbd23a1d8c02a7
[template-runner-import-script]
filename = template/runner-import.sh.jinja2
......@@ -50,7 +50,7 @@ md5sum = 525e37ea8b2acf6209869999b15071a6
[template-slapos-cfg]
filename = template/slapos.cfg.in
md5sum = 035e027e9cb9bbdca0509ac895fc4696
md5sum = 25cf0aeb02216aac8321f834b3097550
[template-parameters]
filename = parameters.xml.in
......
......@@ -146,6 +146,7 @@ project = $${:home}/project
public = $${:home}/public
software-root = {{ slapparameter_dict.get('software-root', '$${:home}/software') }}
instance-root = $${:home}/instance
shared-root = $${:home}/shared
project-test = $${:test}/project
software-test = $${:test}/software
instance-test = $${:test}/instance
......@@ -165,6 +166,9 @@ working-directory = $${runnerdirectory:home}
project-directory = $${runnerdirectory:project}
instance_root = $${runnerdirectory:instance-root}
software_root = $${runnerdirectory:software-root}
shared_part_list =
{{ '\n '.join(shared_part_list.splitlines()) }}
$${runnerdirectory:shared-root}
pidfile-software = $${directory:run}/slapgrid-cp.pid
pidfile-instance = $${directory:run}/slapgrid-sr.pid
ssh_client = ${openssh:location}/bin/ssh
......
......@@ -28,6 +28,7 @@ context = key buildout buildout:bin-directory
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
key slapparameter_dict slap-configuration:configuration
key shared_part_list buildout:shared-part-list
raw curl_executable_location ${curl:location}/bin/curl
raw dash_executable_location ${dash:location}/bin/dash
raw dcron_executable_location ${dcron:location}/sbin/crond
......
......@@ -27,6 +27,10 @@ extends =
../../stack/logrotate/buildout.cfg
../../stack/monitor/buildout.cfg
# make sure shared-part-list is available, even for old versions
# of slapos who do not set it.
shared-part-list =
# stacks are listed from most generic to most specific,
# to avoid versioning issues
......
[slapos]
software_root = {{ slaprunner['software_root'] }}
instance_root = {{ slaprunner['instance_root'] }}
shared_part_list =
{{ '\n '.join(slaprunner['shared_part_list'].splitlines()) }}
master_url = http://{{ slaprunner['ipv4'] }}:{{ slaprunner['proxy_port'] }}
computer_id = slaprunner
maximal_delay = 0
......
......@@ -30,8 +30,10 @@ import paramiko
import contextlib
import base64
import hashlib
import subprocess
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import quote
from six.moves.configparser import ConfigParser
from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
......@@ -116,6 +118,45 @@ class TestSSH(SlaprunnerTestCase):
self.assertIn("Welcome to SlapOS slaprunner shell", received)
class TestSlapOS(SlaprunnerTestCase):
def test_slapos_command(self):
# in ~/bin/slapos there is a wrapper setting configuration to use slapos from
# the web runner.
proxy_show_output = subprocess.check_output(
(
os.path.join(self.computer_partition_root_path, 'bin', 'slapos'),
'proxy',
'show',
),
env={})
self.assertIn('slaprunner', proxy_show_output)
def test_shared_part_list(self):
# this slapos used shared_part_list
cfg_parser = ConfigParser()
with open(os.path.join(self.computer_partition_root_path,
'etc',
'slapos.cfg')) as f:
cfg_parser.readfp(f)
shared_part_list = cfg_parser.get('slapos', 'shared_part_list').splitlines()
# web runner own shared parts. Note that there is intentionnaly a double
# slash in this path, because slaprunner has double slash in paths since
# early releases, including for the path of slapos repository that will be
# used to develop and install software. If we fix this duplication, then
# the URL of installed software will be different and it will get a different
# hash and be reinstalled. To prevent this, we keep that //
self.assertEqual(
'{}/srv//runner/shared'.format(self.computer_partition_root_path.rstrip('/')),
shared_part_list[-1])
# shared parts from outer slapos
outer_shared_part_list = os.getenv('SLAPOS_TEST_SHARED_PART_LIST',
'').split(os.pathsep)
for outer_shared_part in outer_shared_part_list:
self.assertIn(outer_shared_part, shared_part_list)
class ServicesTestCase(SlaprunnerTestCase):
def test_hashes(self):
hash_files = [
......
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