Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

GNU parallel: Running tests against a service - Fail early

I am using parallel to parallelize automatic tests against a service as part of a build pipeline. Essentially, my current approach is to use the following. In the end, what should happen:

  • As soon as both tests are successfully -> success
  • As soon as any one of the job fails -> terminate all and return error

However, it currently happens that of course the service runs indefinitely (unless cancelled), so thats why below I put success=2. If a test fails, however, this will never trigger, and thus I had to add a --timeout 120. However, this only leads to the workaround that after a test fails, I have to wait 2 more minutes to received that info.

parallel --halt now,success=2 -j3 ::: start_service.py test1.py test2.py
question from:https://stackoverflow.com/questions/65883847/gnu-parallel-running-tests-against-a-service-fail-early

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are thinking the right thing, but focusing on the wrong conclusion.

Do not focus on success but on failure:

start_service.py &
# wait until service is ready then run:
parallel --halt now,fail=1 -j0 ::: test1.py test2.py
# stop service
stop_service.py

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...