How can I make parallel ant scripts easier to debug? - ant

Ant has a nifty element but when used results in confusing messages. The output from Ant seems to consist of just the union of both sets of messages. Is there any way to separate these out or, at least, force Ant to serialize them as if they were run sequentially?

I do not believe so, Ant is doing a FIFO. I would advise printing the thread ID along with message to help make sense of the messages.

Related

Is there a way to run a Busted test suite in parallel?

The test suite for my Lua project is split up into multiple files inside the spec/ directory.
Is there a way to ask busted to run those tests in parallel? If I call busted without any arguments it runs all the tests sequentially.
One thing that seems to work is to use GNU Parallel to run multiple test scripts at once.
parallel busted -o utfTerminal ::: spec/*_spec.lua
The -o utfTerminal is to tell busted to use the familiar "green circles" output instead of the simplified text output it uses when its stdout is redirected.
I don't understand much about the Busted library, but apparently what you want is working with multiple threads
Threads are basically the process where the code executes line by line until the end. When we create more threads for a code, multiple loops, functions, etc ... within this new Thread, they executed simultaneously with the original code, without interfering in the process, that is, more than one thing is executed in parallel.
Unfortunately Lua does not contain a way to perform multiple threads, the most it has to work with threads is coroutines. However, there are libraries like lua-llthreads that perform this task, try it out and see what you think. By joining it with your code with Busted, you will be able to perform parallel tasks

How to write a while loop in ant script?

I have a requirement where I have to run a while loop in ant script.
I have to check for the status of a file (it is being created by some other process) in the while loop and perform some task based on it.
I strongly urge you not to use third party tasks that provide looping capability if at all possible. Introducing programming logic such as loops and if statements can easily make your build scripts into unusable spaghetti code.
For your specific case, native Ant already has a much simpler solution. You can use the waitfor task with a nested available condition pointed to the file in question:
<waitfor>
<available file="/path/to/your/file" />
</waitfor>
https://ant.apache.org/manual/Tasks/waitfor.html
https://ant.apache.org/manual/Tasks/available.html

Running Jmeter multiple independent jmx tests in parallel

I have a scenario where there are several independent jmx files, each of them has their own threadgroup etc. Using JMeter Ant script I can fire them all in sequence and collect the result in a jtl file. My challenge here is to do the same thing but fire off the tests in parallel. Please note that Include Controller is not an option since I want to use(or honor) the ThreadGroup and User Defined Variables in each jmx files.
Thanks for your help
Perhaps Parallel Ant Task is what you're looking for.
However <parallel> directive is not thread safe so I wouldn't recommend to use it with JMeter Ant task and consider using i.e. command-line mode, maven plugin or custom Java class which will spawn individual JMeter tests with it.
See 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide for details of the approaches, hope this helps to find the one which matches your environment.
Yes, Ant parallel solves this problem.

How can I validate an Ant XML file itself?

I am using Ant files for build
The build itself is done by IBM Rational Team Concert (RTC) with the help of this Ant file.
My problem is that if I make a mistake in the build XML itself like wrongly typed attribute name, this itself is detected by RTC after loading the files from source control (normally 15-20 mins)
Is there a way to verify (validate) the Ant XML file itself?
There is no schema for an Ant XML. As explained in the FAQ an incomplete DTD can be created but will not work:
An incomplete DTD can be created by the task - but this
one has a few problems:
It doesn't know about required attributes. Only manual tweaking of
this file can help here.
It is not complete - if you add new tasks via
it won't know about it. See this page by Michel Casabianca
for a solution to this problem. Note that the DTD you can download at
this page is based on Apache Ant 0.3.1.
It may even be an invalid DTD.
As Ant allows tasks writers to define arbitrary elements, name
collisions will happen quite frequently - if your version of Ant
contains the optional and tasks, there are two XML
elements named test (the task and the nested child element of )
with different attribute lists. This problem cannot be solved; DTDs
don't give a syntax rich enough to support this.
Again, the FAQ states the DTD is not (yet?) powerful enough to do this, but I found a preliminary work for Ant 1.6 based on Michel Casabianca's work at the AntDTD page on the Ant Wiki. As for me, I do not intend to use it.

Apache Ant: turn off output for a specific task

I have a build file that has different variety of tasks. Some of these are in-house tasks that I am able to control the amount of logging/output generated.
The other tasks are libraries that I have no control over. They do not provide a way to control the amount of output. There is one very trivial task and I am comfortable with turning off the output of the task all together.
My question is if there a way to turn off this specific tasks output in the ant execution. Or does ant provide a way to wrap this task in another task that has echo set to 'off' or something similar?
-Syam
Ant has no builtin feature to turn off output for specific task, but there are possibilities via buildlisteners. See Make ant quiet without the -q flag? for answers
outputproperty="devnull"
It works fine for me and allways you can print this var if you need.

Resources