How do I execute dotnet test in background mode on Linux - .net-core

I want to launch my test suite from a bash script using the & operator in background mode b/c I want my bash script to do something else while the test suite is running.
This doesn't seem possible ATM. What I see is:
$ dotnet test --filter "FullyQualifiedName~GenerateTransactions" >> dotnet.log 2>&1 &
[1] 2068
Tailing the log file for 5 minutes doesn't show me anything. Then pressing Enter in the terminal where I started the tests appears to show me that the dotnet process has stopped
$ <press Enter>
[1]+ Stopped dotnet test --filter "FullyQualifiedName~GenerateTransactions" >> dotnet.log 2>&1
Then I type fg and the dotnet process comes to the foreground and the log file immediatelly starts filling with output:
$ fg
dotnet test --filter "FullyQualifiedName~GenerateTransactions" >> dotnet.log 2>&1
So how do I make dotnet test detach from the controlling terminal/script ?

you can use nohup command to start you dotnet test
nohup dotnet test --filter "FullyQualifiedName~GenerateTransactions" >> dotnet.log &

Related

Robot Framework - Execute tests on multiple environments in parallel

I got a projet that running on multiple environnement en production. So I got an identical test environment like the production.
I need to execute my RobotFramework tests on each of this test environnement, in parralel.
So my needs is to do these 3 task in parralel with only 1 execution, in parallel to not waste time..
robot -d rapport -v env:UAT1 tests/
robot -d rapport -v env:UAT2 tests/
robot -d rapport -v env:UAT3 tests/
I tried to use --argumentfile to do it, in each of them I added env:UAT1, env:UAT2, env:UAT3. It should execute the tests for each argumentfile but it doesnt work :
robot -d rapport --argumentfile UAT1.args --argumentfile UAT2.args --argumentfile UAT3.args tests/
I tried pabot but it doesnt seems to work too...
you can use the suite initialization file, to set your environment variables, and you can trigger it using a CMD variable.

CLI dotnet run with another command

I need to run the command line dotnet run, after starting the url localhost, I need to run another command like curl.
I could do like it:
dotnet run & sleep 12; curl http://localhost:59406
but if dotnet run delay more then 12 seconds, it will be stopped.
It may be possible to solve with linux commands, but I am not experienced in this.
If that helps, I will use this when building the Azure DevOps pipeline, to run newman tests on localhost
You can extend the sleep time if dotnet run takes longer to start up your application, to make sure your application is started when curl the url localhost
If you use this in azure devops pipeline, you can use two bash tasks to run above command. The first bash task run dotnet run & to start your application in the background. The second bash task run curl to curl url localhost. See below yaml pipeline example.
- bash: |
#cd ConnectionWeb/ConnectionWeb
#dotnet restore
dotnet run &
- bash: |
curl http://localhost:8881

Running dotnet through cron on RedHat fails

We have a dotnet core script we use to index some files. We leverage RedHat Software Collection so items like dotnet can tie into our RHEL setup.
To run the script, we do the following:
source scl_source enable rh-dotnet30
/opt/rh/rh-dotnet30/root/usr/bin/dotnet /d/h/fileprocessor.dll 1
We want to run this in cron, but we can not get it to work. We have tried the following:
Adding the 'source' command to the bash profile, but this doesn't seem to be reliable for us, and not run on the cron event.
Running this directly in cron
Running this as a shell script in cron
We are at a loss, it seems we can never get the two commands to work together. If we don't include the source command, even if in our profile, it will not run and gives us the error " It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download"
The following works for me. I am using rh-dotnet31 (.NET Core 3.1) though, since rh-dotnet30 (.NET Core 3.0) is out of support:
Install packages:
$ sudo yum install rh-dotnet31 -y
Start at a known directory
$ cd ~
Create a directory for .NET Core source code to use
$ mkdir hello
$ cd hello
Create a simple application for testing
$ scl enable rh-dotnet31 bash
$ dotnet new console
$ dotnet publish
$ exit # this exits from the subshell started from scl enable command above
Copy the build over to a separate directory where we can run it
$ cp -a bin/Debug/netcoreapp3.1/publish ../hello-bin
Create the script that cron will invoke
$ cd ~
And put this in a ./test.sh file:
#!/bin/bash
echo "test.sh running now...."
source scl_source enable rh-dotnet31
dotnet $HOME/hello-bin/hello.dll 1
You could probably even combine the last two lines (source... and dotnet ...) into scl enable rh-dotnet31 -- dotnet $HOME/hello-bin/hello.dll 1
Then make it executable:
$ chmod +x ./test.sh
Set up the crontab file
$ crontab -e
And then add the line below in this file. This one runs the script every minute.
* * * * * $HOME/test.sh >> $HOME/test.cron.log 2>&1
On my machine, cron is running, so I now see the output of the cron job in the log file after a few minutes:
$ tail -f test.cron.log
test.sh running now....
Hello World!
test.sh running now....
Hello World!
test.sh running now....
Hello World!
test.sh running now....
Hello World!
test.sh running now....
Hello World!
The issue we ran into for this was that the runtime had only been installed, and not the SDK. Once the SDK was installed, which included many other dependencies, it just worked.

How to start WSO2 in back ground in Unix

How to start WSO2 API Manager in background? I start it by
$ sh wso2server.sh
How to make it run in background so that it wont be stopped when I exit my putty terminal?
You can also use the nohup command to run the script as a background process.
nohup ./wso2server.sh &
It would write all the logs you get on terminal to a file nohup.out in the same directory where you run your wso2server.sh script file.
You can run the command ./wso2server.sh --start or ./wso2server.sh --stop
You can use ./wso2server.sh start > /dev/null &
Following will help you, It's similar to any other Linux scripts.
sh wso2server.sh start > /dev/null &
Additionally, you can start any WSO2 products as Linux services. Please refer documentation.

xcodebuild test : Could not launch simulator: -10827

I am running my build agent as a launch agent. I get this error when I try to run "xcodebuild test ..." :
2016-07-14 16:31:00.535 xcodebuild[11579:21390] [MT] iPhoneSimulator: Could not launch simulator: -10827 xcodebuild: error: Failed to build project XcodeTestsTest1 with scheme XcodeTestsTest1. Reason: The operation couldn’t be completed. (OSStatus error -10827.)
Do you have any idea about how can this issue be solved?
Thanks!
I had exact same issue.
It happens because Mac OS X doesn't allow an iOS simulator to run in the BACKGROUND.
If you are constructing a Jenkins CI environment, and trying to unit test via the simulator, you can't run the simulator, because Jenkins is basically run as a DAEMON. This also happens if you're running the tests behind environments like tmux or screen.
Here is a great tutorial to read that can help you fix this.
Cheers!
For me this helped
- close XCode & Simulator (if running)
- open Terminal and type:
ps -ax | grep simdeviceio | grep -v grep
this had some output on my Mac:
50755 ?? Ss 0:00.67 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/SimStreamProcessorServices.simdeviceio/Contents/XPCServices/SimStreamProcessorService.xpc/Contents/MacOS/SimStreamProcessorService
50756 ?? Ss 0:00.07 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/SimAudioProcessorServices.simdeviceio/Contents/XPCServices/SimAudioProcessorService.xpc/Contents/MacOS/SimAudioProcessorService
This 2 processes could either manually be killed by typing their PIDs (first number in above lines) with a kill command:
kill -9 50755 50756
or with
ps ax | grep simdeviceio | grep -v grep | awk '{print $1}' | xargs kill -9
Go to the apple icon (top left of screen), then force quit then select the simulator
Run the project again
If you run
xcrun simctl boot "iPhone 7"
then
run xcodebuild test
then after cleanup with
xcrun simctl shutdown "iPhone 7"
Note: you have to have an active user session running somewhere on the box you are trying to run this on.

Resources