Skip to content

Commit

Permalink
intermediate commit
Browse files Browse the repository at this point in the history
- Still things missing, e.g., update topology to include stateless dispatcher
  • Loading branch information
JordiSubira committed Aug 25, 2023
1 parent baf43c3 commit 8940c4e
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 15 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pkg_tar(
srcs = [
"//control/cmd/control",
"//daemon/cmd/daemon",
"//dispatcher/cmd/dispatcher",
"//gateway/cmd/gateway",
"//router/cmd/router",
"//scion-pki/cmd/scion-pki",
Expand Down
1 change: 1 addition & 0 deletions acceptance/common/topogen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def container_loaders(tester, gateway):
images = {
"control:latest": "//docker:control",
"daemon:latest": "//docker:daemon",
"dispatcher:latest": "//docker:disptacher",
"tester:latest": tester,
"posix-router:latest": "//docker:posix_router",
}
Expand Down
16 changes: 16 additions & 0 deletions acceptance/sig_short_exp_time/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ services:
ipv4_address: 242.254.100.4
bridge2:
ipv4_address: 242.254.200.4
dispatcher1:
container_name: dispatcher1
image: bazel/acceptance/sig_short_exp_time:dispatcher1
networks:
bridge1:
ipv4_address: 242.254.100.2
volumes:
- vol_scion_disp_sig1-ff00_0_110:/run/shm/dispatcher:rw
dispatcher2:
container_name: dispatcher2
image: bazel/acceptance/sig_short_exp_time:dispatcher2
networks:
bridge2:
ipv4_address: 242.254.200.2
volumes:
- vol_scion_disp_sig1-ff00_0_111:/run/shm/dispatcher:rw
sig1:
cap_add:
- NET_ADMIN
Expand Down
7 changes: 4 additions & 3 deletions acceptance/sig_short_exp_time/test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# short lifetime expires, the first path is taken down and a ping sent out. If
# the failover was correct, this ping should not be lost.

# TODO(JordiSubira): Remove dispatcher from schema.
# Docker topology:
#
# +---------------------------+ +---------------------------+
Expand Down Expand Up @@ -51,10 +50,12 @@
run_test() {(set -e
# Register with the docker daemon the docker images bazel created
docker image load -i acceptance/sig_short_exp_time/udpproxy.tar
docker image load -i acceptance/sig_short_exp_time/dispatcher1.tar
docker image load -i acceptance/sig_short_exp_time/dispatcher2.tar
docker image load -i acceptance/sig_short_exp_time/sig1.tar
docker image load -i acceptance/sig_short_exp_time/sig2.tar

docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml up -d sig1 sig2 patha pathb
docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml up -d dispatcher1 dispatcher2 sig1 sig2 patha pathb

# Set up forward route on network stack 1 and 2 through the sig tunnel
# device. The route is a property of the network stack, and persists after
Expand Down Expand Up @@ -102,7 +103,7 @@ RC=$?
OUTPUT_DIR=$TEST_UNDECLARED_OUTPUTS_DIR
mkdir -p $OUTPUT_DIR/logs

for CNTR in sig1 sig2; do
for CNTR in sig1 sig2 dispatcher1 dispatcher2; do
docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml logs "$CNTR" > "$OUTPUT_DIR/logs/$CNTR.log"
done

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dispatcher]
id = "disp_1-ff00_0_110"

[log.console]
level = "debug"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dispatcher]
id = "disp_1-ff00_0_111"

[log.console]
level = "debug"
12 changes: 12 additions & 0 deletions acceptance/topo_cs_reload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_test(
"docker-compose.yml",
"testdata/topology_reload.json",
":control.tar",
":dispatcher.tar",
":invalid_changed_ip",
":invalid_changed_port",
":testdata/gen_crypto.sh",
Expand Down Expand Up @@ -55,6 +56,17 @@ container_image(
],
)

container_image(
name = "dispatcher",
base = "//docker:dispatcher",
cmd = [
"--config",
"/disp.toml",
],
entrypoint = ["/app/dispatcher"],
files = ["testdata/disp.toml"],
)

genrule(
name = "invalid_changed_ip",
srcs = ["//acceptance/topo_common:topology"],
Expand Down
14 changes: 10 additions & 4 deletions acceptance/topo_cs_reload/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ networks:
config:
- subnet: 242.253.100.0/24
services:
topo_cs_reload_dispatcher:
container_name: topo_cs_reload_dispatcher
image: bazel/acceptance/topo_cs_reload:dispatcher
networks:
bridge1:
ipv4_address: 242.253.100.2
topo_cs_reload_control_srv:
container_name: topo_cs_reload_control_srv
image: bazel/acceptance/topo_cs_reload:control
depends_on:
- topo_cs_reload_dispatcher
volumes:
- "${TOPO_CS_RELOAD_CONFIG_DIR}/certs:/certs:ro"
- "${TOPO_CS_RELOAD_CONFIG_DIR}/keys:/keys:ro"
- "${TOPO_CS_RELOAD_CONFIG_DIR}/crypto:/crypto:ro"
networks:
bridge1:
ipv4_address: 242.253.100.2
version: '2.4'
network_mode: service:topo_cs_reload_dispatcher
version: '2.4'
2 changes: 2 additions & 0 deletions acceptance/topo_cs_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func setupTest(t *testing.T) testState {
s.mustExec(t, "tar", "-xf", "crypto.tar", "-C", tmpDir)
// first load the docker images from bazel into the docker deamon, the
// tars are in the same folder as this test runs in bazel.
s.mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar")
s.mustExec(t, "docker", "image", "load", "-i", "control.tar")
// now start the docker containers
s.mustExec(t, "docker-compose", "-f", "docker-compose.yml", "up", "-d")
Expand All @@ -123,6 +124,7 @@ func (s testState) teardownTest(t *testing.T) {
require.NoError(t, os.MkdirAll(fmt.Sprintf("%s/logs", outdir), os.ModePerm|os.ModeDir))
// collect logs
for service, file := range map[string]string{
"topo_cs_reload_dispatcher": "disp.log",
"topo_cs_reload_control_srv": "control.log",
} {
cmd := exec.Command("docker-compose", "-f", "docker-compose.yml", "logs", "--no-color",
Expand Down
5 changes: 5 additions & 0 deletions acceptance/topo_cs_reload/testdata/disp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dispatcher]
id = "disp_1-ff00_0_110"

[log.console]
level = "debug"
11 changes: 11 additions & 0 deletions acceptance/topo_daemon_reload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ go_test(
],
)

container_image(
name = "dispatcher",
base = "//docker:dispatcher",
cmd = [
"--config",
"/disp.toml",
],
entrypoint = ["/app/dispatcher"],
files = ["testdata/disp.toml"],
)

container_image(
name = "daemon",
base = "//docker:daemon",
Expand Down
12 changes: 8 additions & 4 deletions acceptance/topo_daemon_reload/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ networks:
config:
- subnet: 242.254.100.0/24
services:
topo_daemon_reload_daemon:
container_name: topo_daemon_reload_daemon
image: bazel/acceptance/topo_daemon_reload:daemon
topo_daemon_reload_dispatcher:
container_name: topo_daemon_reload_dispatcher
image: bazel/acceptance/topo_daemon_reload:dispatcher
networks:
bridge1:
ipv4_address: 242.254.100.2
topo_daemon_reload_daemon:
container_name: topo_daemon_reload_daemon
image: bazel/acceptance/topo_daemon_reload:daemon
volumes:
- vol_topo_daemon_reload_certs:/certs:ro
network_mode: service:topo_daemon_reload_dispatcher
version: '2.4'
volumes:
vol_topo_daemon_reload_certs: null
vol_topo_daemon_reload_certs: null
6 changes: 4 additions & 2 deletions acceptance/topo_daemon_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ func TestSDTopoReload(t *testing.T) {
func setupTest(t *testing.T) {
// first load the docker images from bazel into the docker deamon, the
// tars are in the same folder as this test runs in bazel.
mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar")
mustExec(t, "docker", "image", "load", "-i", "daemon.tar")
// now start the docker containers
mustExec(t, "docker-compose", "-f", "docker-compose.yml", "up",
"-d", "topo_daemon_reload_daemon")
"-d", "topo_daemon_reload_dispatcher", "topo_daemon_reload_daemon")
// wait a bit to make sure the containers are ready.
time.Sleep(time.Second / 2)
t.Log("Test setup done")
Expand All @@ -86,7 +87,8 @@ func teardownTest(t *testing.T) {
require.NoError(t, os.MkdirAll(fmt.Sprintf("%s/logs", outdir), os.ModePerm|os.ModeDir))
// collect logs
for service, file := range map[string]string{
"topo_daemon_reload_daemon": "daemon.log",
"topo_daemon_reload_dispatcher": "disp.log",
"topo_daemon_reload_daemon": "daemon.log",
} {
cmd := exec.Command("docker-compose", "-f", "docker-compose.yml", "logs", "--no-color",
service)
Expand Down
5 changes: 5 additions & 0 deletions acceptance/topo_daemon_reload/testdata/disp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dispatcher]
id = "disp_1-ff00_0_110"

[log.console]
level = "debug"
3 changes: 1 addition & 2 deletions dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const (
ReceiveBufferSize = 1 << 20
// SendBufferSize is the size of the send buffers used by the dispatcher.
SendBufferSize = 1 << 20
mtu = 1920 - 20 - 8
)

// Server is the main object allowing to create new SCION connections.
Expand All @@ -66,7 +65,7 @@ func NewServer(topo *topology.Loader, conn *net.UDPConn) *Server {
server := Server{
topo: topo,
conn: conn,
buf: make([]byte, mtu),
buf: make([]byte, common.SupportedMTU),
decoded: make([]gopacket.LayerType, 4),
outBuffer: gopacket.NewSerializeBuffer(),
options: gopacket.SerializeOptions{
Expand Down
11 changes: 11 additions & 0 deletions docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ container_bundle(
images = {
"control:latest": ":control",
"daemon:latest": ":daemon",
"dispatcher:latest": ":dispatcher",
"posix-gateway:latest": ":posix_gateway",
"posix-router:latest": "posix_router",
},
Expand Down Expand Up @@ -45,6 +46,16 @@ scion_app_images(
entrypoint = ["/app/control"],
)

scion_app_images(
name = "dispatcher",
src = "//dispatcher/cmd/dispatcher",
cmd = [
"--config",
"/share/conf/disp.toml",
],
entrypoint = ["/app/dispatcher"],
)

scion_app_images(
name = "daemon",
src = "//daemon/cmd/daemon",
Expand Down
10 changes: 10 additions & 0 deletions spec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ openapi_bundle(
visibility = ["//visibility:public"],
)

openapi_bundle(
name = "dispatcher",
srcs = [
"//spec/common:base.yml",
"//spec/common:process.yml",
],
entrypoint = "//spec/dispatcher:spec.yml",
visibility = ["//visibility:public"],
)

openapi_bundle(
name = "daemon",
srcs = [
Expand Down

0 comments on commit 8940c4e

Please sign in to comment.