diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml index 6a8db730..e8341a77 100644 --- a/.github/workflows/e2e-testing.yml +++ b/.github/workflows/e2e-testing.yml @@ -73,7 +73,7 @@ jobs: - name: Output KVP telemetry if: always() run: | - docker exec azureinit-provisioning-agent cat /var/lib/hyperv/.kvp_pool_1 + docker exec azure-testing-server cat /tmp/testinit.kvp_pool_1 - name: Output Azure-init log if: always() diff --git a/testinit/docker-compose.yml b/testinit/docker-compose.yml index 8461f8bf..8cbffe29 100644 --- a/testinit/docker-compose.yml +++ b/testinit/docker-compose.yml @@ -11,6 +11,7 @@ services: volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:rw + - /var/lib/hyperv:/var/lib/hyperv:rw stdin_open: true tty: true container_name: azureinit-provisioning-agent diff --git a/testinit/testing-server/docker-compose.yml b/testinit/testing-server/docker-compose.yml index b037d627..1a8de7e7 100644 --- a/testinit/testing-server/docker-compose.yml +++ b/testinit/testing-server/docker-compose.yml @@ -10,13 +10,15 @@ services: - SYS_MODULE ports: - "80:80" + volumes: + - /var/lib/hyperv:/var/lib/hyperv:rw networks: imds-network: ipv4_address: 169.254.169.254 wireserver-network: ipv4_address: 168.63.129.16 healthcheck: - test: ["CMD", "curl", "-f", "-H", "Metadata: true", "http://localhost:80/metadata/instance?api-version=2021-02-01"] + test: [ "CMD", "curl", "-f", "-H", "Metadata: true", "http://localhost:80/metadata/instance?api-version=2021-02-01" ] interval: 30s timeout: 10s retries: 3 @@ -30,7 +32,7 @@ networks: config: - subnet: 169.254.0.0/16 gateway: 169.254.0.1 - + wireserver-network: driver: bridge name: wireserver-network diff --git a/testinit/testing-server/wireserver_handler.py b/testinit/testing-server/wireserver_handler.py index 1b30faa9..8a81c63e 100644 --- a/testinit/testing-server/wireserver_handler.py +++ b/testinit/testing-server/wireserver_handler.py @@ -1,6 +1,7 @@ from http.server import BaseHTTPRequestHandler import time import json +import os import xml.etree.ElementTree as ET from utils import logger @@ -54,6 +55,23 @@ def load_responses(cls): logger.info("Outputting loaded custom WireServer responses") logger.info(json.dumps(cls._responses, indent=2)) + def store_kvp_file(self): + kvp_file_path = "/var/lib/hyperv/.kvp_pool_1" + output_file_path = "/tmp/testinit.kvp_pool_1" + + if os.path.exists(kvp_file_path): + with open(kvp_file_path, "r") as f: + kvp_data = f.read() + + # Write to output file, overwriting if it exists since this gets + # called multiple times with a failure. + with open(output_file_path, "w") as f: + f.write(kvp_data) + + logger.info(f"KVP data written to {output_file_path}") + else: + logger.info("KVP file not found") + def write_custom_response(self): responses_list = self._responses @@ -106,6 +124,8 @@ def do_POST(self): logger.info(f"WireServer POST request: {self.path}") logger.info(f"POST data: {post_data.decode('utf-8', errors='ignore')}") + self.store_kvp_file() + if self._responses is not None: self.write_custom_response() return