Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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()
Expand Down
1 change: 1 addition & 0 deletions testinit/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /run/dbus/system_bus_socket:/run/dbus/system_bus_socket:rw
- /tmp:/var/lib/hyperv:rw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sharing all of /tmp seems a bit excessive for rw, I would probably suggest limiting to a particular directory specific for these tests (emptied prior to test)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like docker supports a tmpfs volume that should be perfect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When checking the Docker tmpfs documentation, it shows a limitation as not being able to share access across containers, as it is only available in one container. The two services here are run in different containers, so this will cause an issue when trying to pull the KVP logs from the mock server. I will update the code to have access to only a single /tmp/testinit/ folder, though, to avoid the braod /tmp/ access.

stdin_open: true
tty: true
container_name: azureinit-provisioning-agent
Expand Down
6 changes: 4 additions & 2 deletions testinit/testing-server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ services:
- SYS_MODULE
ports:
- "80:80"
volumes:
- /tmp:/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
Expand All @@ -30,7 +32,7 @@ networks:
config:
- subnet: 169.254.0.0/16
gateway: 169.254.0.1

wireserver-network:
driver: bridge
name: wireserver-network
Expand Down
20 changes: 20 additions & 0 deletions testinit/testing-server/wireserver_handler.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.error("KVP file not found")

def write_custom_response(self):
responses_list = self._responses

Expand Down Expand Up @@ -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
Expand Down