Automate network disconnection on VM while maintaining remote connection from TFS job - tfs

I have the following setup:
Microsoft TFS with jobs and pipelines
A VM under Virtual Machine Manager (VMM) which has Windows10
The job from TFS can connect to VM to run commands remotely
My goal is to automate test case when there is no network connection inside the VM (mainly no internet connection) to verify that some features of my software under test behave as expected and do not use network to achieve my test calls.
Currently I use powershell on target machine to run scripts remotely in the VM https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/powershell-on-target-machines?view=azure-devops .
I made research online already but I didn't find something specific to TFS and VMM.
Perhaps it is worth it to mention that I found this script online:
#!/bin/sh
ip link set ens32 down
sleep 20
ip link set ens32 up
But the script was written in a Linux and SSH connection context, which isn't the same as my environment.
Is there anyway to achieve automation of networking disconnection remotely and then turning on again the network connection state ? (simulation tools are also ok for me if they do achieve my goal and can be integrated in TFS pipeline or VM tools installation).

Related

TeamCity server in a Linux container, but Build Agent in a Windows container

Is it possible to run a TeamCity server instance in a Linux container, and then run a Build Agent in a Windows container and have it connect?
The TeamCity Server just the central server, where Agents push the results.
The TC Server is responsible for to add to queue, send a task to Agent, wait, collect the result.
The Agent is responsible for executing Task, send the result to the server.
doesn't matter, where was run TC or Agent, important point is that if your configuration needs the Windows server then it can be run only Agent on the Windows.
conclusion.
The TC Server can be run as on Linux, as on Windows OS's
The TC Agent also can be run on Linux and OS, but:
If your configuration using the Windows component's, then the Configuration will add restrict OS type in the Agent Requirements
If you have few configurations with few OS type's just run few Agents on the some OS's

Jenkins: Execute a job where the project/workspace is located on other machine (LAN Network)

Having a PC for developing working with STS/Eclipse and Jenkins both working in the same machine and same time.
Now for pre-production testings is mandatory use servers running together such as ActiveMQ, RabbitMQ, MySQL, PostgreSQL
Due this the PC goes slower, even worst if SonarQube and JMeter are running.
The solution needed is have in the same LAN network two machines.
Machine A: with IDE just running with some servers running too, MySQL and ActiveMQ
Machine B: running Jenkins (and optionally SonarQube and JMeter)
Thus the tools dedicated for:
Continuous Integration (Jenkins)
Continuous Inspection (SonarQube)
Measure performance (JMeter)
are running in a dedicated machine, in this case B.
Currently when all is based in one machine. The following is used:
Thus Jenkins is able to work directly with the workspace
Therefore how through Jenkins or with a special plugin we can refer to execute a job, to execute a set of #Test, where the project (workspace) is located in other PC?
The project itself about all its #Test methods should be not aware that is being executed remotely from Jenkins
Should only exists one Jenkins server working over the network.
What is the best approach to accomplish this goal?

Using Telnet in Jenkins

We are currently running several Projects on several Servers. For our workflow we installed Telnet to communicate with theses servers. More than this, we run the Build/Make mechanism (own development php) on theses servers.
Now we like to introduce a CI mechanism to this. Therefore we installed a central Jenkins application, from which we like to trigger all these builds. Our standard way is to open a telnet connection an trigger the build command on shell. Now we like to adopt this mechanism and bring it to Jenkins.
Is there a possibility to open a Telnet connection via Jenkins?
Installing a slave Jenkins on the remote Servers is a not as much preferred option, because we don't like to install more Software on the server as necessary.
Yes, It is posible, you can use pipeline to include groovy program that use telnet commands, it could be one posibility another you can use ssh commands in a free style job.

How to get a Jenkins slave to open a windows server session

I'm trying to get a Jenkins slave to open a session on a windows server.
Basically, What I'm try to achieve is:
Jenkins slave is running as a service on a windows 2003 server. When master calls slave, it will open a desktop session on the server and kick off an .exe that will perform GUI testing
What I have done:
Jenkins node created (Node A). Dumb slave. Remote FS root set to path on Windows 2003 server. ("C:\Jenkins\Node"). Launch method Java Web Start
Slave 'Node A' installed from Jenkins master using Java Web Start on windows 2003 server
Jenkins slave now running as a service on server
Jenkins project created and 'Restrict where this project can be run' is set to 'Node A'
Project windows batch command 'C:\GUITest.exe'
When I build the project in Jenkins I was expecting that the slave would be able to open a session and run C:\GUITest.exe. But, I'm missing something.
Anyone any ideas, or know if it is possible (plugins I may need ??)
Any advise / direction much appreciated.
Looks like you want to run GUI test on windows session. It won't work if you run Jenkins Slave as service, you have to run JNLP agent on your windows server. Also if you want to run in unattended mode, meaning that the windows remote session would be disconnected, you need some other setup as well. Please provide more information on what you are trying to do.
You must ensure that whatever process runs the GUI tests (might be a java / cmd / ssh process if you're connected to Jenkins) is not running on session 0 as it won't have access to Desktop and the Windows UI in general. I was in a similar situation and running the same process as a scheduled task instead of service solved it for me.

Deploying and starting a webdriver test program on a remote windows vm from jenkins server

I have a test program in Java for testing a web app using webdriver. It builds and runs in my local machine just fine.
Now, I need to build it in jenkins, then deploy and run it on a VM running on Windows (e.g. server 2008 R2).
Obviously, the test program doesn't work on jenkins as it needs to open a browser. This cannot be done under system account in Jenkins server. So I need to deploy it to a remote machine and somehow start the test.
I've heard this can be done using ssh for a linux box, but don't know how to do it for a windows VM.
Any idea?
If you have installed jenkins as service then you need to create a JNLP node in order to run your webdriver tests.
Follow the post for creating JNLP node and running your tests on that.
http://qtp-help.blogspot.in/2013/09/setup-webdriver-maven-project-on-jenkins.html

Resources