Skip to content

Commit

Permalink
fixup: use docker-compose to interact with tester containers in accep…
Browse files Browse the repository at this point in the history
…tance tests
  • Loading branch information
matzf committed Sep 26, 2023
1 parent 70e6b2b commit 1a07188
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
47 changes: 22 additions & 25 deletions acceptance/hidden_paths/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import http.server
import time
import threading

from plumbum import cmd
import sys

from acceptance.common import base
from acceptance.common import scion
from tools.topology.scion_addr import ISD_AS


class Test(base.TestTopogen):
Expand Down Expand Up @@ -109,12 +109,6 @@ def setup_start(self):
super().setup_start()
time.sleep(4) # Give applications time to download configurations

self._testers = {
"2": "tester_1-ff00_0_2",
"3": "tester_1-ff00_0_3",
"4": "tester_1-ff00_0_4",
"5": "tester_1-ff00_0_5",
}
self._ases = {
"2": "1-ff00:0:2",
"3": "1-ff00:0:3",
Expand All @@ -125,27 +119,30 @@ def setup_start(self):

def _run(self):
# Group 3
self._showpaths_bidirectional("2", "3", 0)
self._showpaths_bidirectional("2", "5", 0)
self._showpaths_bidirectional("3", "5", 0)
self._showpaths_bidirectional("2", "3")
self._showpaths_bidirectional("2", "5")
self._showpaths_bidirectional("3", "5")

# Group 4
self._showpaths_bidirectional("2", "4", 0)
self._showpaths_bidirectional("2", "5", 0)
self._showpaths_bidirectional("4", "5", 0)
self._showpaths_bidirectional("2", "4")
self._showpaths_bidirectional("2", "5")
self._showpaths_bidirectional("4", "5")

# Group 3 X 4
self._showpaths_bidirectional("3", "4", 1)

def _showpaths_bidirectional(self, source: str, destination: str, retcode: int):
self._showpaths_run(source, destination, retcode)
self._showpaths_run(destination, source, retcode)

def _showpaths_run(self, source_as: str, destination_as: str, retcode: int):
print(cmd.docker("exec", "-t", self._testers[source_as], "scion",
"sp", self._ases[destination_as],
"--timeout", "2s",
retcode=retcode))
try:
self._showpaths_bidirectional("3", "4")
except Exception as e:
print(e)
else:
assert("Unexpected success; should not have paths 3 -> 4")

def _showpaths_bidirectional(self, source: str, destination: str):
self._showpaths_run(source, destination)
self._showpaths_run(destination, source)

def _showpaths_run(self, source_as: str, destination_as: str):
print(self.execute_tester(ISD_AS(self._ases[source_as]),
"scion", "sp", self._ases[destination_as], "--timeout", "2s"))


def configuration_server(server):
Expand Down
9 changes: 4 additions & 5 deletions demo/drkey/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def setup_prepare(self):
# Enable delegation for tester host on the fast side (server side), i.e.
# allow the tester host to directly request the secret value from which
# keys can be derived locally for any host.
tester_ip = self._container_ip("scion_disp_tester_%s" % self.server_isd_as.file_fmt())
tester_ip = self._container_ip("disp_tester_%s" % self.server_isd_as.file_fmt())
cs_config = self._conf_dir(self.server_isd_as) // "cs*-1.toml"
scion.update_toml({"drkey.delegation.scmp": [tester_ip]}, cs_config)

Expand All @@ -82,9 +82,8 @@ def _run(self):

# install demo binary in tester containers:
drkey_demo = local["realpath"](self.get_executable("drkey-demo").executable).strip()
testers = ["tester_%s" % ia.file_fmt() for ia in {self.server_isd_as, self.client_isd_as}]
for tester in testers:
local["docker"]("cp", drkey_demo, tester + ":/bin/")
for ia in {self.server_isd_as, self.client_isd_as}:
self.dc("cp", drkey_demo, "tester_%s" % ia.file_fmt() + ":/bin/")

# Define DRKey protocol identifiers and derivation typ for test
for test in [
Expand Down Expand Up @@ -134,7 +133,7 @@ def _endhost_ip(self, isd_as: ISD_AS) -> str:
""" Determine the IP used for the end host (client or server) in the given ISD-AS """
# The address must be the daemon IP (as it makes requests to the control
# service on behalf of the end host application).
return self._container_ip("scion_sd%s" % isd_as.file_fmt())
return self._container_ip("sd%s" % isd_as.file_fmt())

def _container_ip(self, container: str) -> str:
""" Determine the IP of the container """
Expand Down

0 comments on commit 1a07188

Please sign in to comment.