File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed
test-driver/src/test_driver Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,11 @@ def main() -> None:
109109 help = "the test script to run" ,
110110 type = Path ,
111111 )
112+ arg_parser .add_argument (
113+ "--dump-vsocks" ,
114+ help = "indicates that the interactive SSH backdoor is active and dumps information about it on start" ,
115+ action = "store_true" ,
116+ )
112117
113118 args = arg_parser .parse_args ()
114119
@@ -136,6 +141,8 @@ def main() -> None:
136141 if args .interactive :
137142 history_dir = os .getcwd ()
138143 history_path = os .path .join (history_dir , ".nixos-test-history" )
144+ if args .dump_vsocks :
145+ driver .dump_machine_ssh ()
139146 ptpython .ipython .embed (
140147 user_ns = driver .test_symbols (),
141148 history_filename = history_path ,
Original file line number Diff line number Diff line change 1111from typing import Any
1212from unittest import TestCase
1313
14+ from colorama import Style
15+
1416from test_driver .errors import MachineError , RequestedAssertionFailed
1517from test_driver .logger import AbstractLogger
1618from test_driver .machine import Machine , NixStartScript , retry
@@ -176,6 +178,19 @@ def subtest(name: str) -> Iterator[None]:
176178 )
177179 return {** general_symbols , ** machine_symbols , ** vlan_symbols }
178180
181+ def dump_machine_ssh (self ) -> None :
182+ print ("SSH backdoor enabled, the machines can be accessed like this:" )
183+ print (
184+ f"{ Style .BRIGHT } Note:{ Style .RESET_ALL } this requires { Style .BRIGHT } systemd-ssh-proxy(1){ Style .RESET_ALL } to be enabled (default on NixOS 25.05 and newer)."
185+ )
186+ names = [machine .name for machine in self .machines ]
187+ longest_name = len (max (names , key = len ))
188+ for num , name in enumerate (names , start = 3 ):
189+ spaces = " " * (longest_name - len (name ) + 2 )
190+ print (
191+ f" { name } :{ spaces } { Style .BRIGHT } ssh -o User=root vsock/{ num } { Style .RESET_ALL } "
192+ )
193+
179194 def test_script (self ) -> None :
180195 """Run the test script"""
181196 with self .logger .nested ("run the VM test script" ):
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ pkgs.lib.throwIf (args ? specialArgs)
7575 ) ,
7676 extraPythonPackages ? ( _ : [ ] ) ,
7777 interactive ? { } ,
78+ sshBackdoor ? { } ,
7879 } @t :
7980 let
8081 testConfig =
Original file line number Diff line number Diff line change 181181
182182 passthru . nodes = config . nodesCompat ;
183183
184+ extraDriverArgs = mkIf config . sshBackdoor . enable [
185+ "--dump-vsocks"
186+ ] ;
187+
184188 defaults = mkMerge [
185189 ( mkIf config . node . pkgsReadOnly {
186190 nixpkgs . pkgs = config . node . pkgs ;
You can’t perform that action at this time.
0 commit comments