How to integrate Perl automation test script with TeamCity build - perl

I have a Rest API. I wrote my test automation in Perl which sends curl commands. I want to integrate the tests with TeamCity build so that any change in the code will be pulled, installed in a machine and the tests will be run. If all the tests pass then only the build will be green in TeamCity.
Now I don't know how to integrate Perl with TeamCity. Is there any plugins available for this?

You can use the Teamcity plugin for Perl to integrate your perl tests with Teamcity. If you use this ,
The test results are displayed in a nice Teamcity Tests tab witch a breakdown for Success, Failed and ignored tests.
You can go into the history of tests to know exactly when a change started breaking someone's tests.
You get a log info per each test which is useful for debugging when you have multiple tests.
The documentation for the plugin at the CPAN page has good examples of how to implement this

You can use the Command Line Runner to execute a Perl script. If it returns a non-zero exit code the build will fail. See https://confluence.jetbrains.com/display/TCD8/Configuring+Build+Steps:
The build step status is considered failed if the build process returned a non-zero exit code and the Fail build if build process exit code is not zero build failure condition is enabled (see Build Failure Conditions); otherwise build step is successful.

Related

pytest --forked flag processes don't die causing GitLab build to hang

We are using pytest-xdist to run pytest tests with the --forked flag (we are writing integration tests for code that uses Scrapy). However, we noticed that when the tests finish running, some of the created child processes remain alive, which causes our GitLab build to hang.
The Python version we'e using is 3.7.9.
I couldn't find other mentions of the issue online. Is anyone familiar with it? Are there any solutions/fixes/workarounds?

Azure DevOps Release Pipeline Inline Powershell script failing to run python unittest suite

I have a release pipeline setup in Azure DevOps to run a regression test suite. I am running these tests remotely on a Microsoft self-hosted Windows Agent using Selenium (Python bindings) and the Python unittest framework, which invokes chromedriver.exe to run tests.
When the release job reaches the task Run Python Unit Tests however, it freezes and I don't see any output (although, when I open the task manager on the agent
I can see chromedriver and chome instances running which suggests that something is happening).
Other info -
I am able to connect to the agent sucessfully as all my repos and latest commits are pulled down (from an earlier task in the pipeline)
the Chromedriver path is set as an environment variable on the agent
I am using Chromedriver 2.43
I am using Python 2.7.14 as the interpreter (also set as an env variable in the Path)
The inline powershell task has the following in the Script to run field -
cd C:\path\to\folder\with\tests
python tests.py staging
The message displayed when this task runs in DevOps pipeline is -
Waiting for console output from an agent...
console output
When I run the tests locally on the agent with the exact same command (opening the cmd.exe terminal on the agent), I can see chromedriver opening and the tests running as expected (with output in the terminal too)
Why am I unable to run see these tests running when invoked from the inline powershell task in the release pipeline but able to see the tests run when invoked on the VM? And why does the output still not show as the tests are running?
(I have also tried a normal cmd.exe task in place of the inline powershell task, the same issue was encountered)
Any help would be much appreciated, thank you :)
EDIT:
Ran a simple selenium test to check everything was working and got a successful result. However -
I was still unable to see console output as the test was executing
I was still unable to "see" anything executing on the VM (so it appeared to be running as a background task but could not see chrome launching and navigating to pages etc)

How do I get the commands executed by Bazel

I was wondering if there is a way to get Bazel to list, output, display, etc., all of the commands that can be executed from a command line that are run during a build after a clean. I do not care if the output is to the screen, in a file, etc. I will massage it into a usable form if necessary.
I have captured the screen output during a run of Bazel which gives me an idea of what is being done, however it does not give me a command I can execute on the command line. The command would have to include all of the command options and not display variables.
If this is not possible, since Bazel is open source, where in the code is/are the lines that represent the commands to be run so that I can modify Bazel to output the executable commands.
I am aware of the query command within Bazel, and used it generate the dependency diagram. If this could be done as a query command it would be even better.
TLDR;
My goal is to build TensorFlow using Bazel on Windows. Yes I know of all of the problems and reasons NOT to do it and have successfully installed TensorFlow on Windows via a Virtual Machine or Docker. I did take a shot at building Bazel on Windows starting with Cygwin, but that started to get out of hand as I am use to installing with packages and Cygwin doesn't play nice with packages, so then I started trying to build Bazel by hand and that was turning into a quagmire. So I am now trying to just build TensorFlow by hand on Windows by duplicating what Bazel would do to build TensorFlow on Linux.
You are correct, you can use the -s (--subcommands) option:
bazel build -s //foo
See https://docs.bazel.build/versions/master/user-manual.html#flag--subcommands.
For your use case, you'd probably want to redirect the output to a file and then global replace any library/binary paths to the Windows equivalents.
You might want to track https://github.com/bazelbuild/bazel/issues/276 (Windows support), although it'll probably be a while.
(Disclaimer: This solution does not print the commands that currently get executed but the commands that would get or got executed.)
I'd use aquery (action graph query) (forget about "graph"):
bazel aquery //foo
Advantages:
It's very fast, because it prints the actions without executing the build.
It's a query. It does not have side effects.
You don't have to do a bazel clean before in order to find out the build steps for a library that has already been built.
It prints information about the specific build step that you request. It does not print all the build commands required for the dependencies.

Test Coverage in Jenkins for a Perl application

I just implemented an excellent example of test coverage in Perl described at Perl, Code Coverage Example
But that required Module::Build , Now what if i have existing Perl Application which does NOT have the Module::Build instrumentation, is there a way to get test coverage for unit or functional tests ?
I looked at :
Clean up from previous test run (optional)
cover -delete
#Test run with coverage instrumentation
PERL5OPT=-MDevel::Cover prove -r t
#Collect covered and caller information
# Run this _before_ running "cover"
# Don't run with Devel::Cover enabled
covered runs
- or e.g. -
covered runs --rex_skip_test_file='/your-prove-file.pl$/' \
--rex_skip_source_file='{app_cpan_deps/}'
#Post process to generate covered database
cover -report Html_basic
%perl -d:Coverage -Iblib/lib test.pl
But this seems to indicate Code Coverage while running the application.
I want to be able to get a Clover or Cobertura Compatible output, so i can integrate it with email-ext in Jenkins
Task::Jenkins may be of some help. It has instructions about how to publish the Devel::Cover HTML reports through Jenkins, as well as info about adapting other Perl tools to Jenkins.
Jira has some instructions about integrating Devel::Cover into Jenkins.
To get code coverage for any Perl process (test, application, server, whatever) you set the PERL5OPT environment variable to -MDevel::Cover which is like putting use Devel::Cover in the program. If your command to execute tests is perl something_test then you'd run PERL5OPT=-MDevel::Cover perl something_test.
If you're using prove, use HARNESS_PERL_SWITCHES=-MDevel::Cover prove <normal prove arguments>. This tells prove to load Devel::Cover when running the tests, but avoids gathering coverage for prove itself.

How to further automate Teamcity

I have successfully configured my project for build in TeamCity. Going a step more, I want to run a deployment script once a build completes successfully. The deployment script is a simple bash command. To make the question more simpler, how would I invoke a shell command once a build successfully completes in Teamcity.
Please help
TeamCity 6.0 has a new feature called Multiple Build Steps:
Multiple Build Steps: Now any build configuration can be comprised of unlimited number of build steps, where each step is represented by a build runner. Don’t limit yourself, and combine as many build runners into one configuration as you need. Feel free to call a NAnt script before compiling VS solutions, run inspections and duplicates finder after your ANT build, add NUnit tests after your Rake build, and so on.
So you can add a new build step with the command line runner which will execute your shell script.