From fbbb37ca5a2e5bf521c0b721649ecd75a62f472e Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 13 Feb 2025 15:40:20 +0100 Subject: [PATCH] tests(tdxtest): ramp up the testing Signed-off-by: Harald Hoyer --- systems/x86_64-linux/tdxtest/default.nix | 147 ++++-------------- .../v1/instance/attributes/container_config | 21 +++ .../v1/instance/attributes/container_hub | 1 + .../v1/instance/attributes/container_image | 1 + .../v1/instance/attributes/kafka_topic | 1 + .../v1/instance/attributes/kafka_urls | 1 + 6 files changed, 52 insertions(+), 120 deletions(-) create mode 100644 systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_config create mode 100644 systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_hub create mode 100644 systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_image create mode 100644 systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_topic create mode 100644 systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_urls diff --git a/systems/x86_64-linux/tdxtest/default.nix b/systems/x86_64-linux/tdxtest/default.nix index 96a2e8c..668d840 100644 --- a/systems/x86_64-linux/tdxtest/default.nix +++ b/systems/x86_64-linux/tdxtest/default.nix @@ -7,13 +7,33 @@ ./../../../packages/tdx_google/configuration.nix ]; + networking.hosts = { + "127.0.0.100" = [ "metadata.google.internal" ]; + # might want to run kafka on the testing host + "10.0.2.2" = [ "kafka" ]; + }; + + # emulate metadata.google.internal + services.static-web-server = { + enable = true; + listen = "127.0.0.100:80"; + root = ./web-root; + }; + + # systemd.services.vector = { + # environment = { + # KAFKA_URLS = "10.0.2.2:9092"; + # KAFKA_TOPIC = "tdx-google-test"; + # }; + # }; + systemd.services.docker_start_container = { - environment = { - CONTAINER_IMAGE = "amd64/hello-world@sha256:e2fc4e5012d16e7fe466f5291c476431beaa1f9b90a5c2125b493ed28e2aba57"; - CONTAINER_HUB = "docker.io"; - CONTAINER_USER = ""; - CONTAINER_TOKEN = ""; - }; + # environment = { + # CONTAINER_IMAGE = "matterlabsrobot/tdx-test:pnj1ryxxb8gbzk9wh18s9bcqrzr1z9ff"; + # CONTAINER_HUB = "docker.io"; + # CONTAINER_TOKEN = ""; + # CONTAINER_USER = ""; + # }; postStop = '' : @@ -37,6 +57,7 @@ environment.systemPackages = with pkgs; [ strace tcpdump + static-web-server ]; @@ -60,118 +81,4 @@ cores = 4; }; }; - - /* - services.loki = { - enable = true; - configuration = { - server.http_listen_port = 3030; - auth_enabled = false; - analytics.reporting_enabled = false; - - ingester = { - lifecycler = { - address = "127.0.0.1"; - ring = { - kvstore = { - store = "inmemory"; - }; - replication_factor = 1; - }; - }; - chunk_idle_period = "1h"; - max_chunk_age = "1h"; - chunk_target_size = 999999; - chunk_retain_period = "30s"; - }; - - schema_config = { - configs = [ - { - from = "2024-04-25"; - store = "tsdb"; - object_store = "filesystem"; - schema = "v13"; - index = { - prefix = "index_"; - period = "24h"; - }; - } - ]; - }; - - storage_config = { - tsdb_shipper = { - active_index_directory = "/var/lib/loki/tsdb-shipper-active"; - cache_location = "/var/lib/loki/tsdb-shipper-cache"; - cache_ttl = "24h"; - }; - - filesystem = { - directory = "/var/lib/loki/chunks"; - }; - }; - - limits_config = { - reject_old_samples = true; - reject_old_samples_max_age = "168h"; - volume_enabled = true; - }; - - - table_manager = { - retention_deletes_enabled = false; - retention_period = "0s"; - }; - - compactor = { - working_directory = "/var/lib/loki"; - compactor_ring = { - kvstore = { - store = "inmemory"; - }; - }; - }; - }; - }; - - services.promtail = { - enable = true; - configuration = { - server = { - http_listen_port = 3031; - grpc_listen_port = 0; - }; - clients = [ - { - url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; - } - ]; - scrape_configs = [{ - job_name = "journal"; - journal = { - max_age = "12h"; - labels = { - job = "systemd-journal"; - }; - }; - relabel_configs = [ - { - source_labels = [ "__journal__systemd_unit" ]; - target_label = "systemd_unit"; - } - { - source_labels = [ "__journal__hostname" ]; - target_label = "nodename"; - } - { - source_labels = [ "__journal_container_id" ]; - target_label = "container_id"; - } - ]; - }]; - }; - # extraFlags - }; - */ } diff --git a/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_config b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_config new file mode 100644 index 0000000..3258906 --- /dev/null +++ b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_config @@ -0,0 +1,21 @@ +{ + "server": { + "port": 8080, + "timeout_seconds": 30 + }, + "metrics": { + "port": 9000 + }, + "telemetry": { + "otlp": { + "enable": true, + "endpoint": "http://127.0.0.1:4317", + "protocol": "grpc" + }, + "logging": { + "level": "trace", + "console": true, + "json": false + } + } +} diff --git a/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_hub b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_hub new file mode 100644 index 0000000..243e482 --- /dev/null +++ b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_hub @@ -0,0 +1 @@ +docker.io diff --git a/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_image b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_image new file mode 100644 index 0000000..8b18200 --- /dev/null +++ b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/container_image @@ -0,0 +1 @@ +matterlabsrobot/tdx-test:81hgl91s5hj0sb83c7ij9acf2s5qjvb5 diff --git a/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_topic b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_topic new file mode 100644 index 0000000..fba611d --- /dev/null +++ b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_topic @@ -0,0 +1 @@ +tdx-google diff --git a/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_urls b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_urls new file mode 100644 index 0000000..8758015 --- /dev/null +++ b/systems/x86_64-linux/tdxtest/web-root/computeMetadata/v1/instance/attributes/kafka_urls @@ -0,0 +1 @@ +10.0.2.2:9092