Cypress commandline for rerun the failed TC - cypress

For re running the failed test case i saw the below option to put in cypress config file
{
"retries": {
// Configure retry attempts for `cypress run`
// Default is 0
"runMode": 2,
// Configure retry attempts for `cypress open`
// Default is 0
"openMode": 0
}
}
But i need to pass this value via command line while starting the automation , how i can pass the above value from command line

Related

Error exit code 1 code showing in Jenkins Consiole output ( I do not want to see it )

I have a job running in the Jenkins pipeline and the output is showing error exit code 1 because am using if statement to create NOT_BUILT in the stage. Is there any other way to not see the work error exit code 1. I do not want to use When statement but if possible to still use IF statement and have a blank stage but without this message error exit code 1 in the console output.
This is my script below :
if(route53 == 'false' ) {
catchError(buildResult: 'SUCCESS', stageResult: 'NOT_BUILT') {
sh "exit 1"
}
}
else if(route53 == 'true' && all == "Yes" ) {
catchError(buildResult: 'SUCCESS', stageResult: 'NOT_BUILT') {
sh "exit 1"
}
}
The result in the pipeline console output is showing this, the stage graphic is fine as it is showing a blank stage but the console output error code is what I really want to manipulate.
output result
+ exit 1
[Pipeline] }
[Pipeline] }
ERROR: script returned exit code 1
[Pipeline] }
ERROR: script returned exit code 1
[Pipeline] }
ERROR: script returned exit code 1
[Pipeline] }
When using declarative pipelines the NOT_BUILT state is preserved to a stage the was not executed because its when directive was evaluated as false, and there is not direct way to set it except with the catchError workaround. (btw you can control the error message by using error('Your Message') instead of exit 1)
Therefore, it is easiest to achieve using the when directive and also makes your pipeline more readable. If you insist on using if statements you can still use them inside a when directive with the generic expression option which allows you to run any groovy code and calculate the relevant Boolean value according to your needs.
So you can still use your original code and just update it to return a Boolean:
stage('Conditional stage') {
when {
expression {
if(route53 == 'false' ) {
return false
}
else if(route53 == 'true' && all == "Yes" ) {
return false
}
return true
}
}
steps {
...
}
}

ssh "packet_write_wait: Connection to x.x.x.x port 22: Broken pipe" -- where is the source code?

We got a client ssh to a remote server showing this error. It has always been running fine, no firewall rules change either. When an ssh session is idled over the weekend, it is still connected. Just some times when we 'less' and shift-F on a file for couple of hours, it shows this error.
I'm not trying to solve this problem in this post. We want to look at the ssh source code to figure out what is going on. On Centos 7, I downloaded openssh-7.4p1-21.el7.src.rpm, and extracted openssh-7.4p1.tar.gz. 'grep' through source code and found 'packet_write_wait' function. But curiously, "Broken pipe" (or -i on each word separately) is not found in all the .h and .c files. Where is that error text coming from?
You can find a copy of the OpenSSH source code in github. The packet_write_wait function is in opacket.c:
void
packet_write_wait(void)
{
int r;
if ((r = ssh_packet_write_wait(active_state)) != 0)
sshpkt_fatal(active_state, __func__, r);
}
It calls another function to write the packet. If that fails, it calls sshpkt_fatal. sshpkt_fatal is in packet.c, and its job is to print an error message and then exit.
/*
* Pretty-print connection-terminating errors and exit.
*/
void
sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
{
switch (r) {
case SSH_ERR_CONN_CLOSED:
logdie("Connection closed by %.200s port %d",
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
[...code removed...]
/* FALLTHROUGH */
default:
logdie("%s%sConnection %s %.200s port %d: %s",
tag != NULL ? tag : "", tag != NULL ? ": " : "",
ssh->state->server_side ? "from" : "to",
ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), ssh_err(r));
}
}
The message that you're asking about is handled by the default case. The last argument, which provides the text after the colon, is provided by calling ssh_err:
const char *
ssh_err(int n)
{
switch (n) {
case SSH_ERR_SUCCESS:
return "success";
case SSH_ERR_INTERNAL_ERROR:
return "unexpected internal error";
[...etc...]
The ssh_err case that you're interested in is this one:
case SSH_ERR_SYSTEM_ERROR:
return strerror(errno);
In short, the "Broken pipe" message comes from the standard library function strerror, which converts error numbers to standard error messages.
The list of standard error codes indicates that "Broken pipe" is associated with the EPIPE error.

Jmeter: Running the nongui command using java

I am trying to run the jmeter nongui command using java as follows:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\apache-jmeter-2.13\\bin\\jmeter.bat -t \"C:\\jmeter scripts\\test.jmx\" -n -l \"C:\\jmeter scripts\\nonGUI.csv\"");
It runs perfectly fine, until I add the argument:
-Jusers=15 inside the command mentioned above in the next run.
The property set for the number of threads is: ${__P(users,10)}
The result file does not seem to fill up and the process seems to run forever under the CPU Resource monitor.
P.S.: Please do not suggest me to run the jmeter file using the steps given in the blazemeter website. It has used one of the deprecated method and there is no resolution given for the plausible runtime errors in that website.
I was not able to reproduce your error, but here is a complete example with JMX File. I removed the need for the "".
// OSX exmaple
public class r {
public static void main(String[] args) throws Exception {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("/usr/local/bin/jmeter -t /Users/rfriedman/jmeter/SimpleUrl.jmx -Jusers=15 -n -l /Users/rfriedman/jmeter/nonGUI.csv");
}
}
Just to make sure I ran modified on Windows as well
// Windows Example
public class r {
public static void main(String[] args) throws Exception {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\Users\\rfriedman\\Desktop\\apache-jmeter-2.13\\bin\\jmeter.bat -t C:\\Users\\rfriedman\\Desktop\\SimpleUrl.jmx -Jusers=20 -n -l C:\\Users\\rfriedman\\Desktop\\nonGUI.csv");
}
}
JMeter Test Plan
It works after I add the property value for Synchronization timer similar to Thread count.
Also, if I have to pass the value of -Jusers in the form of variable, how to do it? I am trying to do the following. But it's not getting executed.
eg:
int value=10;
Process pr = rt.exec("C:\Users\rfriedman\Desktop\apache-jmeter-2.13\bin\jmeter.bat -t C:\Users\rfriedman\Desktop\SimpleUrl.jmx -Jusers=value -n -l C:\Users\rfriedman\Desktop\nonGUI.csv");
Update:
I tried with String value="10"; as well. Still the jmeter logs says:
"jmeter.reporters.Summariser: summary = 0 in 0s = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0.00%)"
Use this snippet.
int value = 10;
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\apache-jmeter-2.13\\bin\\jmeter.bat" +
" -t \"C:\\jmeter scripts\\test.jmx\" -Jusers=" + value + " -Jsync=" + value +
" -n -l \"C:\\jmeter scripts\\nonGUI.csv\" -j \"C:\\jmeter scripts\\jmeterLogs.log\"");

Executing shell commands through beanshell in jmeter

Executing shell commands through beanshell in jmeter. I want to execute shell commands in beanshell preprocessor in jmeter
Can any one tell how to do so.
Beanshell is JAVA (scripting language).
Below statement should help.
Runtime.getRuntime().exec("COMMAND");
Based on #vins answer I cloud create my ping test to verify my email server is available.
Additionally if you want to log the output of the Runtime.getRuntime().exec("COMMAND"); use something similar to this in your jmeter BeanShell Sampler:
// ********
// Ping the email server to verify it's accessible from the execution server
//
// Preconditions:
// custom variable is available named "emailServer" which contains the IP-Adress of the machine to ping
//
// ********
log.info(Thread.currentThread().getName()+": "+SampleLabel+": Ping email server: " + vars.get("emailServer"));
// Select the ping command depending on your machine type windows or Unix machine.
//String command = "ping -n 2 " + vars.get("emailServer"); // for windows
String command = "ping -c2 " + vars.get("emailServer"); // for Unix
// Print the generated ping command
log.info(command);
// Create a process object and let this object execute the ping command
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
log.info("Execution complete.");
// Read the output of the ping command and log it
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder logCommandOutput = new StringBuilder();
String line;
while( (line = in.readLine()) != null) {
logCommandOutput.append(line);
}
in.close();
log.info("Output: " + logCommandOutput.toString());

C - passing an unknown command into execvp()

I'm writing a fake shell, where I create a child process and then call execvp(). In the normal shell, when I enter an unknown command such as 'hello' it returns 'hello: Command not found.' However, when I pass hello into execvp(), it doesn't return any error by default and just continues running the rest of my program like nothing happened. What's the easiest way to find out if nothing was actually run? here's my code:
if(fork() == 0)
{
execvp(cmd, args);
}
else
{
int status = 0;
int corpse = wait(&status);
printf(Child %d exited with a status of %d\n", corpse, status);
}
I know that if corpse < 0, then it's an unknown command, but there are other conditions in my code not listed where I don't want to wait (such as if & is entered at the end of a command). Any suggestions?
All of the exec methods can return -1 if there was an error (errno is set appropriately). You aren't checking the result of execvp so if it fails, the rest of your program will continue executing. You could have something like this to prevent the rest of your program from executing:
if (execvp(cmd, args) == -1)
exit(EXIT_FAILURE);
You also want to check the result of fork() for <0.
You have two independent concerns.
1) is the return value of execvp. It shouldn't return. If it does there is a problem. Here's what I get execvp'ing a bad command. You don't want to wait if execvp fails. Always check the return values.
int res = execvp(argv[1], argv);
printf ("res is %i %s\n", res, strerror(errno));
// => res is -1 No such file or directory
2) The other concern is background processes and such. That's the job of a shell and you're going to need to figure out when your program should wait immediately and when you want to save the pid from fork and wait on it later.

Resources