Robot framework - How do I see the output of a command executed in a shell? - docker

I would like to use the Robot framework to automate a step where the next command is executed in a cmd:
docker-compose logs --no-color --tail=1 the-server
The output of the previous command will be the log of the server named the-server in the docker-compose.yml file.
After I would like to check if the response of this command has the string Started the-server, to check if the server is up.
I'm using the next robot file:
*** Settings ***
Library Process
Library OperatingSystem
Suite Setup log running on ${properties.hostname}
Suite Teardown Terminate All Processes kill=True
Variables C:/Users/TheUser/Desktop/CheckOutRegression/properties.py
*** Test Cases ***
Check if the-server is up
${result} Wait Until Keyword Succeeds 10x 20s Check The-Server
*** Keyword ***
Check The-Server
${resultOfcmd} Run Process docker-compose logs --no-color --tail\=1 the-server shell=yes cwd=${properties.pathToDocker}
Should Contain ${resultOfcmd} 'Started the-server' PASS
Log To Console ${resultOfcmd}
The test-case is always failing with the error:
Keyword 'Check The-Server' failed after retrying 10 times. The last error was: TypeError: 'ExecutionResult' object is not iterable
also I'm not sure if the variable {resultOfcmd} contains the output of the command docker-compose logs --no-color --tail\=1 the-server.
Can anyone help?

Check Process library documentation about Result object from Run Process keyword:
https://robotframework.org/robotframework/latest/libraries/Process.html#Result%20object
You get your results from ${resultOfcmd.stdout}.
You should also use Log To Console before failing keyword to see result before test fails.

Log To Console ${resultOfcmd.stdout} console=yes

Related

Jenkins (2.297) build fails because an "output.xml" file could not be parsed

i set up an Jenkins-> robot framework chain where the robot tasks are stimulated by Jenkins.
The example robot tasks (some simple shell scripts) are executed without errors, but Jenkind fails because it is not able to parse some "output.xml" file which has nothing to do with the robot framework tasks.
Error message:
[ ERROR ] Reading XML source '/var/lib/jenkins/workspace/Test/output.xml' failed:ParseError: junk after document element: line 188, column 0
When i investigate the "output.xml" there is indeed an error:
...
rrors>
</errors>
</robot>
This behavior is already known and active and is described in https://issues.jenkins.io/browse/JENKINS-62359?attachmentViewMode=list
in 2020, but the error is still appearing.
Is there a solution or workaround? It is curious that sometimes the build is executing without an error when nothing changed.

Bazel not building correctly. Error with os.bzl

I've pulled the most recent drake repo "https://github.com/RobotLocomotion/drake" and I am trying to
$run bazel build //...
but bazel is returning the following error
ERROR: /home/nathan/drake/tools/workspace/os.bzl:73:13: invalid escape sequence: \(. You can enable unknown escape sequences by passing the flag --incompatible_restrict_string_escapes=false ERROR: /home/nathan/drake/tools/workspace/os.bzl:73:19: invalid escape sequence: \|. You can enable unknown escape sequences by passing the flag --incompatible_restrict_string_escapes=false ERROR: /home/nathan/drake/tools/workspace/os.bzl:73:31: invalid escape sequence: \). You can enable unknown escape sequences by passing the flag --incompatible_restrict_string_escapes=false ERROR: error loading package '': in /home/nathan/drake/tools/workspace/default.bzl: in /home/nathan/drake/tools/workspace/blas/repository.bzl: Extension 'tools/workspace/os.bzl' has errors INFO: Elapsed time: 0.139s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded).
It seems to not like line 73 in os.bzl, but I'm not sure how to fix it. Any suggestions would be very helpful.
I've just run a build using those same versions of Bazel, Ubuntu, and Drake, with no problems.
There was a problem on that line several months ago, that we fixed in https://github.com/RobotLocomotion/drake/pull/12696. Can you confirm you're using a new-enough version of Drake? For example, what does git log -1 report?

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

Passing command Line Arguments for grails run-app through gradle task

I have a grails 3 application for which I am trying to pass command line arguments to my application when I am running it through gradle bootRun task.
I want to read the arguments in my config file for runtime operations. As per the grails documentation for yml configration here I tried to add the following to my build.gradle file
run {
systemProperties = System.properties
}
When I add that configuration and run my task I get the following error:
3:11:20 PM: Executing external task 'bootRun -Dcolor=red -Dfruit=apple'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\docs\projects\jet\build.gradle' line: 85
* What went wrong:
A problem occurred evaluating root project 'jet'.
> Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.892 secs
Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
3:11:32 PM: External task execution finished 'bootRun -Dcolor=red -Dfruit=apple'.
Please let me know if there is anything I am missing here or if there is a better way of doing this.
So I find out what the issue was.
Grails 3.0 uses bootRun as target instead of run. Changing adding the below code fixed the issue.
bootRun {
systemProperties = System.properties
}
Hope this helps everyone.

How to run specific tests using SBT Jenkins Plugin for ScalaTest test

Currently we are using IntelliJ, Scala, SBT to kick off our tests in our local enviroment. With SBT command line, we can specify specific test, suites, wildcards, as instructed here:
ScalaTest.org Page
Such as "test-only *RedSuite"
However on our CI Jenkins server, with the SBT pluging, when specifying this, it gives an error.
In the action field, the following values were used:
Action:compile test-only test.package.name
Using the following does work for ALL tests:
Action:compile test
[success] Total time: 240 s, completed Apr 28, 2014 12:29:36 PM
[error] Expected ID character
[error] Not a valid command: org (similar: export)
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: org (similar: fork, run, doc)
[error] org.company.scalatest.abc.regressionsuite
[error] ^
Build step 'Build using sbt' changed build result to FAILURE
Build step 'Build using sbt' marked build as failure
Recording test results
Does anyone know if there is a way we can pass these parameters through the jenkins SBT plugin?
This is a quoting problem, your Action field is parsed as 3 commands:
compile
test-only
org.company.scalatest.abc.regressionsuite
And it chokes because that org is not a valid command.
Using compile "test-only org.company.scalatest.abc.regressionsuite" should fix that.

Resources