Running a single test in grpc - grpc

How to run a single gRPC test case in c language? Eg: bins/dbg/server_chttp2_test
As per documentation, tools/run_tests/run_tests.py -l c -c dbg runs complete test suite.

You can do this using the -r flag, which specifies that only tests matching a specific regular expression should be run. In the simplest case, you can pass an entire test name to run just that test. So, the command you would use is
tools/run_tests/run_tests.py -l c -c dbg -r server_chttp2_test

Related

Anyone have idea how to run linux command in robot framework at backend

I have to run this command
./emsInventory.sh -s 10 -i EMS1004 -p EMS -v 10.2.0.15.1 -d "EMS Patch " -c ems10/pass_ems10#rac_ems10.agnity.com
In robot framework to make sure that data is created or not
Use the Run Process in the Process library - this is its precise purpose.
You can use SSH Library in robot framework more details can be found here http://robotframework.org/SSHLibrary/SSHLibrary.html.
Below examples could be useful
Execute Command And Verify Return Code
[Documentation] Often getting the return code of the command is enough.
... This behaviour can be adjusted as Execute Command arguments.
${rc}= Execute Command echo Success guaranteed. return_stdout=False return_rc=True
Should Be Equal ${rc} ${0}
Executing Commands In An Interactive Session
[Documentation] Execute Command always executes the command in a new shell.
... This means that changes to the environment are not persisted
... between subsequent Execute Command keyword calls.
... Write and Read Until variants can be used to operate in the same shell.
Write cd ..
Write echo Hello from the parent directory!
${output}= Read Until directory!
Should End With ${output} Hello from the parent directory!

How to get TAG name which was passed in command line in Robot Framework?

I am running test cases using robot --include smoke /
I need smoke tag which was passed in command line argument in test case.
The current tags are available in the Test level through the built-in variable ${TEST TAGS}; you can iterate over its members to see what the case has:
FOR ${tag} IN #{TEST TAGS}
Log tag: ${tag}
END
Yet that will give you all tags a case has assigned; so in your case it will return "smoke", but will also return "sanity", "feature" and all others it might have.
There's no exposed user-level variable/keyword to get what exactly were the tags set for the current execution; using the RF API you may be able to get a reference to the current execution context and access such property (if it's present).
You should read the OPTIONS built-in variable.
Example:
EDGE-T900 - Test tags
[Tags] CB1 CB2 CB3 CB4 CB5
Log To Console running test EDGE-T900 - Test tags
run keyword if 'CB1' in #{TEST TAGS} Log To Console run because CB1 is on the tag list
Log To Console #{OPTIONS.include}
run keyword if 'CB5' in #{OPTIONS.include} Log To Console run because CB5 is passed
run keyword if 'CB2' in #{OPTIONS.include} Log To Console run because CB2 is passed
The OPTION variable includes all data passed by the command line, source documentation:
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#automatic-variables
You can test it with:
python3 -m robot "$#" -i CB5 -d results tests
python3 -m robot "$#" -i CB2 -d results tests
python3 -m robot "$#" -i CB1 -d results tests
And check the output...

SSH between N number of servers using script

I have n number of servers like c0001.test.cloud.com, c0002.test.cloud.com, c0003.test.cloud.com and I want to do the ssh between these servers like:
from Server: c0001 do the ssh to c0002 and then exit the server.
Come back to c0001 do the ssh to c0003 and then exit the server.
So in this way it will execute the script without entering any input during runtime and we can have n number of servers.
I have written one script :
str1=c0001.test.cloud.com,c0002.test.cloud.com,c0003.test.cloud.com
string="$( cut -d ',' -f 2- <<< "$str1" )"
echo "$string"
for j in $(echo $string | sed "s/,/ /g")
do
ssh appAccount#j
done
But this script is not running fine. I have also checked it by passing parameters
like: -o StrictHostKeyChecking=no and <<'ENDSSH' but it is not working.
Assuming the number of commands you want to run are small, you could:
Create a script of commands that will run from c0001.test.cloud.com to each of the servers. For example, create a file on your local machine called commands.sh with:
hosts="c0002.test.cloud.com c0003.test.cloud.com"
for host in $hosts do
ssh -o StrictHostKeyChecking=no -q appAccount#$host <command 1> && <command 2>
done
On your local machine, ssh to c0001.test.cloud.com and execute the commands in commands.sh:
ssh -o StrictHostKeyChecking=no -q appAccount#c0001.test.cloud.com 'bash -s' < commands.sh
However, if your requirements become more complex, a more robust solution might be to use a cluster administration tool such as ClusterShell

Linux top not printing full command name to file in batch mode as a nohup process

I am trying to find the cpu utilization of a process from top.So before that I had to test the below command
top -b -c -d1 -n2
I am using -c option to print the full command name as the process name gets truncated without -c.
No when I run this as nohup sh test.sh & ,the output nohup.out contains truncated process name and because of which I am not able to grep on the process name
159 neutron 30 0 127620 22765 5479 S 0.0 0.6 399:02.56 /usr/bin/p+t
But when I run this as sh test.sh & its printing the full command name to terminal.
Why is the full command name not printed in spite of using -c in batch mode for top command ?
Whats the difference between command name with -c enabled and process name ?
Or to phrase it the process name and command name are different and the process name is picked from /proc/pid/status by commands like ps or top?
We can set the COLUMNS environment variable before the top command to increase the available width.
COLUMNS=1000 top -b -c -d1 -n2
The other way would be is to use ps to find the pid's of the processes by their names and specify the format of ps output.This output can be used to feed top to get the cpu usage for the process based on pid.
ps -eo pid,comms,args
comms = command name only and not the args
args = full argument list used to launch the process

Crontab and testing a command to be executed

I'm quite new to cron and crontab.
I've edited the crontab file and I need to execute manually one of commands so I can try it and test it beforehand. How do I do that? If it fails, is there a mode that shows the errors?
Write a shell script that you can test.
Execute that shell script from the crontab.
Remember that cron provides barely any environment - so your script may have to fix that. In particular, your profile will not be used.
Do not get fancy with what you put in the crontab.
Build a debug mode into your shell script.
No, there isn't specifically a mode that shows errors. Usually, if the cron job witters, the output is emailed to you. That is, it sends standard output and standard error information to you if the executed command writes anything to either standard output or standard error.
On MacOS X (10.6.7), the environment I got was (via a crontab entry like 12 37 17 5 * env >/tmp/cron.env):
SHELL=/bin/sh
USER=jleffler
PATH=/usr/bin:/bin
PWD=/Users/jleffler
SHLVL=1
HOME=/Users/jleffler
LOGNAME=jleffler
_=/usr/bin/env
Of those, PWD, _ and SHLVL are handled by the shell. So, to test your script reliably in a cron-like environment, use:
(cd $HOME
env -i \
SHELL=/bin/sh \
USER=$USER \
PATH=/usr/bin:/bin \
HOME=$HOME \
LOGNAME=$LOGNAME \
/path/to/script/you/execute ...
)
The -i option to env means 'ignore all inherited enviroment'; the script will see exactly the five values specified plus anything the shell specifies automatically. With no arguments, env reports on the environment; with arguments, it adjusts the environment and executes a command.
To execute a script "manually" you first have to make it executable by doing:
$ chmod +x yourScriptName
Then do either
$ ./yourScriptName
if you execute it from its path or
$ /full/path/to/yourScriptName
from anywhere.

Resources