You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/04/14 16:03:34 UTC
(tooling-trusted-release) branch main updated: Add SSH key generation code to the browser tests script
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new 46da8dc Add SSH key generation code to the browser tests script
46da8dc is described below
commit 46da8dc7e758892aa484d6e9074c8dfe688b429f
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon Apr 14 17:03:14 2025 +0100
Add SSH key generation code to the browser tests script
---
playwright/test.py | 39 +++++++++++++++++++++++++++++++++++++++
tests/Dockerfile.playwright | 29 +++++++++++++++--------------
2 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/playwright/test.py b/playwright/test.py
index 1b5af81..27d040d 100644
--- a/playwright/test.py
+++ b/playwright/test.py
@@ -21,8 +21,10 @@ import argparse
import dataclasses
import getpass
import logging
+import os
import re
import socket
+import subprocess
import urllib.parse
import netifaces
@@ -124,6 +126,7 @@ def run_tests() -> None:
def run_tests_in_context(context: sync_api.BrowserContext, credentials: Credentials) -> None:
+ ssh_keys_generate()
page = context.new_page()
test_all(page, credentials)
logging.info("Tests finished successfully")
@@ -137,6 +140,42 @@ def show_default_gateway_ip() -> None:
logging.warning("Could not determine gateway IP")
+def ssh_keys_generate() -> None:
+ ssh_key_path = "/root/.ssh/id_ed25519"
+ ssh_dir = os.path.dirname(ssh_key_path)
+
+ try:
+ if os.path.exists(ssh_key_path):
+ os.remove(ssh_key_path)
+ logging.info(f"Removed existing SSH key at {ssh_key_path}")
+ if os.path.exists(f"{ssh_key_path}.pub"):
+ os.remove(f"{ssh_key_path}.pub")
+ logging.info(f"Removed existing SSH public key at {ssh_key_path}.pub")
+
+ os.makedirs(ssh_dir, mode=0o700, exist_ok=True)
+
+ logging.info(f"Generating new SSH key at {ssh_key_path}")
+ result = subprocess.run(
+ ["ssh-keygen", "-t", "ed25519", "-f", ssh_key_path, "-N", ""],
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+ logging.info("SSH key generated successfully")
+
+ except (OSError, subprocess.CalledProcessError) as e:
+ logging.error(f"Failed to generate SSH key: {e}", exc_info=True)
+ if isinstance(e, subprocess.CalledProcessError):
+ logging.error(f"ssh-keygen stderr: {e.stderr}")
+ raise RuntimeError("SSH key generation failed") from e
+
+ if result.returncode != 0:
+ logging.error(f"ssh-keygen returned {result.returncode}")
+ logging.error(f"ssh-keygen stdout: {result.stdout}")
+ logging.error(f"ssh-keygen stderr: {result.stderr}")
+ raise RuntimeError("SSH key generation failed")
+
+
def test_all(page: sync_api.Page, credentials: Credentials) -> None:
test_login(page, credentials)
test_tidy_up(page)
diff --git a/tests/Dockerfile.playwright b/tests/Dockerfile.playwright
index 4489c3b..c0b26b1 100644
--- a/tests/Dockerfile.playwright
+++ b/tests/Dockerfile.playwright
@@ -1,20 +1,21 @@
FROM mcr.microsoft.com/playwright/python:v1.51.0-noble
RUN <<-EOF
- set -eux
- apt-get update
- apt-get install -y --no-install-recommends \
- build-essential \
- iproute2 \
- nano \
- openssh-client \
- python3-dev
- pip3 install --no-cache-dir \
- netifaces \
- playwright \
- rich
- apt-get clean
- rm -rf /var/lib/apt/lists/*
+ set -eux
+ apt-get update
+ apt-get install -y --no-install-recommends \
+ build-essential \
+ iproute2 \
+ nano \
+ openssh-client \
+ python3-dev \
+ rsync
+ pip3 install --no-cache-dir \
+ netifaces \
+ playwright \
+ rich
+ apt-get clean
+ rm -rf /var/lib/apt/lists/*
EOF
RUN playwright install --with-deps
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org