Automatic testing of server and client using `make`? - makefile

What is an example of a way to run a test against a server? In other words, how would you run a server and then run a test client against the server from a make file? For example, I want to run make test which will run all tests against the server to verify it's passing all tests. I know how to run a test for a single program, say against a library, but not how to run two programs that are dependent for the test, at once.

It is more convenient to have a shell script that spawns multiple processes and orchestrates them because each line of a makefile recipe is a new invocation of the shell. Use make to invoke that test shell script that would do something like:
Start the server in the background.
Start the client.
Run tests.
Terminate the client.
Terminate the server.
Return the process return code indicating test success or failure.

Related

Run multiple jmeter tasks on a machine, how to specify a port to stop jmeter test

I executed 3 jmeter tasks on an ubuntu server. Now I need to stop one of them (requires report generation). I execute the stoptest.sh script in the bin directory and find that only the first jmeter task started can be stopped. This is the test task with port 4445, which can be seen through the jmeter log at startup. The ports of the other 2 tasks are 4446 and 4447, so how do I specify the port to stop the test? For example, I want to stop the test task with port 4447, but keep the other 2 tests to continue, what should I do? Of course, I will not use the kill -9 jmeter-pid method, because this is a forced exit from the jmeter process, and no test report will be generated
You can provide the JMeter's shutdown client port as the parameter like:
./stoptest.sh 4446
It's better to use shutdown.sh as this script "asks" JMeter to stop its threads while stoptest.sh "kills" the threads which may result in tons of errors related to threads abnormal termination. The JMeter engine shutdown port can be specified exactly the same way
It is possible to generate the report at any time even during the test execution, if you set jmeter.save.saveservice.autoflush property to true JMeter will save each Sampler execution result into the .jtl file as soon as it's ready

Jmeter test status on non-gui mode

How can i get jmeter test status in non-gui mode.
Jenkins install jmeter helm chart on kuberntes and start the test as part of the installation, meaning that after the chart installed a script entry point will run automatically inside the container, jenkins is only trigger the chart. i want to know when the test is finished and get back the status to jenkins from the pod to publish the report test result on jenkins.
When JMeter's non-gui test execution is finished it returns a normal exit code which can be obtained:
%errorlevel% environment variable in Windows
$? environment variable in Unix and derivatives
Not knowing the details of how you launch JMeter it is quite hard to come up with exact Jenkins configuration but I'm pretty much sure that you can utilize the aforementioned variables to get the JMeter execution status
if you are triggering jmeter scripts via jenkins , you can have a post build operation after script execution using jenkins.
I am using powershell in jenkins to run jmeter in non gui mode, once test is done doing other post build operations.

Composer script to start a background process, whose lifetime is bound to that of the Composer script

I've started experimenting with Composer Scripts.
I have a project where there are "Functional tests" of the API endpoints. Running the whole test suite requires running the following commands in order:
composer install to install all required dependencies of the backend APIs
php yii server --test to start a lite server that is connected to the "test" MySQL database. The test server starts running on localhost:9000.
sh vendor/bin/phpunit --configuration tests/functional/phpunit.xml to run th actual tests. This last command triggers the execution of all test cases, most of which execute HTTP calls to the lite server, launched at step 2.
I would like to automate and "atomize" this 3 step process into a single Composer script that can be easily started, killed and restarted effortlessly.
Here's my current progress:
"scripts": {
"test-functional": [
"#composer install",
"php yii server --test",
"sh vendor/bin/phpunit --configuration tests/functional/phpunit.xml"
]
}
The problem is that the 2-nd command (php yii server --test) "steals" the terminal because PHPs built-in lite server requires the terminal to be open while the command is running. Killing the command kills the lite server as well. I tried suffixing the second step of the script with & which generally makes processes go in the background and not steal the terminal, but it seems this trick doesn't work for Composer Scripts. Any other workaround or possibility that I'm missing?
My final goal is to make the 3 steps execute in an atomic way, output the results of the tests and end the command, cleaning up everything (including killing the lite server, launched in step 2).

How can i run my ruby service with chef recipe

I have a web service in ruby, and i want to run my ruby service via chef recipe.
I have used execute command as :
execute 'start-ruby' do
command 'ruby /opt/certificate.rb start'
action :run
end
I can see my ruby service running in background on my Amazon instance, but somehow Instance setup is stuck in running setup.
Is there any other alternative from which i can run my ruby service via chef recipe.
The execute resource runs its command synchronously, meaning it waits for it to finish before continuing with the recipe. I'm guessing your start command there starts a foreground-mode daemon (which is how it should work) so it never returns and Chef just waits forever.
Check out https://github.com/poise/application_examples/blob/master/recipes/todo_rails.rb or https://github.com/poise/poise-service for examples of Ruby application deployment and generic service management respectively.

How to run selenium server in the background using windows batch script in Jenkins?

I am running protractor tests on a server machine through Jenkins. I need to start the selenium web driver before running the tests. i.e. "webdriver-manager start" and run the tests while the server is running and shut it down once tests are run. How do I do this using batch script?
I am using start, cmd commands in the batch file to achieve it but once the selenium server starts, I am unable to go back to the prompt unless I stop it.
How to I make it run in the background by staying in the same command prompt window rather than opening up the new command prompt window selenium server starts?
you should run webdriver-manager start as shell script.
Make sure
1 - Node.js installed on jenkins
2 - provide correct path to webdriver-manager

Resources