0

I'm building a testing suite using Python Pytest library, my challenge is that I want to run the test on remote windows machines without the overhead of deploying my python code on those remote machines.

Current Solution:

Using Jenkins I'm cloning the tests repository from bit bucket to the remote machine , and then using a PowerShell command through WINRM triggering the execution of the pytest script on the remote machine.

Desired Solution: The pytest code/repository will reside on a machine (local/cloud) and will execute on remote windows machines (possibly in parallel on multiple machines)

I've investigated the paramiko/factory packages but they both require the code to be present on the remote machines.

Anyone encountered similar requirement ? implemented something similar?

Bored002
  • 353
  • 6
  • 18
  • "without the overhead of deploying my python code on those remote machines." but do you want to test if your code runs on those machines? – 9769953 May 22 '22 at 12:05
  • Most continuous integration solutions that I know off tend to set up a new (virtual machine) environment from scratch for every test. So that you don't have "left-overs" from previous test, and are guaranteed that all dependencies etc are properly installed by your installer system. – 9769953 May 22 '22 at 12:06
  • You will need a way to control, and manage, those remote machines. Pytest is a unit test framework, and not designed for this. – Keith May 22 '22 at 12:15
  • @Keith ye i know , the machines will be managed by a ci\cd tool i.e. booting up the machines etc. but i want to execute my pytest code on multiple machines , i know that it's being done in Linux via ssh connection. was wondering if from 1 machine i can execute the code remotely on multiple machines in parallel – Bored002 May 22 '22 at 12:28
  • Using ssh (which is platform independent, though it may not be an option for you on Windows) also means the code has to be installed on each separate machine. Ssh just allows you to start a process remotely; it doesn't "transfer" actual code. What does exists for *nix OSes, is something like NFS, which allows file access across machines. I think Windows has Samba? But that may be a red herring, since I don't understand your exact requirements. – 9769953 May 22 '22 at 13:10
  • If you can get the code over the the machine, then yes. You could use `rsync` or `scp` to do that first. Then run a command over ssh shell. – Keith May 22 '22 at 16:16
  • `pytest-xdist` supports remote tests execution over SSH (IIRC using `execnet` unser the hood). `mitogen` is another library that can do remote code execution over SSH, but you'll need to write the missing integration to `pytest` yourself. – hoefling May 22 '22 at 16:51
  • @9769953 there's usually no need to install any code on slaves aside from the Python interpreter itself. When the connection is established, the master bootstraps a custom PEP 302 importer on the slave, which will ask the master to send the code object via network on any unresolved import. This way, the slave doesn't need to have anything besides enough RAM :-) – hoefling May 22 '22 at 17:00

1 Answers1

0

you can try a pub-sub mechanism with aws ssm

hermes
  • 129
  • 1
  • 6