1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

script/autobuild.py: replace random-sleep.sh with python function

The random-sleep.sh script is tricky, and there is no need to rely on another
script just for random sleep.

Using the python function, the random number generation will happen when
load autobuild.py other than execute cmd, but shouldn't affect the
result.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joe Guo 2019-05-22 22:34:57 +12:00 committed by Andrew Bartlett
parent 1b70d43ed1
commit 0383747dcc
2 changed files with 39 additions and 58 deletions

View File

@ -9,6 +9,7 @@ import os
import tarfile
import sys
import time
import random
from optparse import OptionParser
import smtplib
import email
@ -107,6 +108,15 @@ if options.enable_coverage:
else:
LCOV_CMD = 'echo "lcov skipped since no --enable-coverage specified"'
if args:
# If we are only running specific test,
# do not sleep randomly to wait for it to start
def random_sleep(low, high):
return 'sleep 1'
else:
def random_sleep(low, high):
return 'sleep {}'.format(random.randint(low, high))
cleanup_list = []
builddirs = {
@ -159,7 +169,7 @@ samba_libs_configure_samba = samba_libs_configure_base + samba_libs_configure_bu
tasks = {
"ctdb": [
("random-sleep", "../script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure " + ctdb_configure_params),
("make", "make all"),
("install", "make install"),
@ -170,7 +180,7 @@ tasks = {
# We have 'test' before 'install' because, 'test' should work without 'install (runs all the other envs)'
"samba": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -220,7 +230,7 @@ tasks = {
],
"samba-nt4": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --without-ads --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -236,7 +246,7 @@ tasks = {
],
"samba-fileserver": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --without-ad-dc --without-ldap --without-ads --without-json --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -250,7 +260,7 @@ tasks = {
],
"samba-ad-member": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -265,7 +275,7 @@ tasks = {
],
"samba-ad-dc-1": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -278,7 +288,7 @@ tasks = {
],
"samba-ad-dc-2": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -292,7 +302,7 @@ tasks = {
],
"samba-ad-dc-3": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -307,7 +317,7 @@ tasks = {
],
"samba-ad-dc-4": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -322,7 +332,7 @@ tasks = {
],
"samba-ad-dc-5": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -334,7 +344,7 @@ tasks = {
],
"samba-ad-dc-6": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -346,7 +356,7 @@ tasks = {
],
"samba-schemaupgrade": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -361,7 +371,7 @@ tasks = {
# We split out the ad_dc_ntvfs tests (which are long) so other test do not wait
# This is currently the longest task, so we don't randomly delay it.
"samba-ad-dc-ntvfs": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -375,7 +385,7 @@ tasks = {
# run the backup/restore testenvs separately as they're fairly standalone
# (and CI seems to max out at ~8 different DCs running at once)
"samba-ad-dc-backup": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test FAIL_IMMEDIATELY=1 "
@ -399,7 +409,7 @@ tasks = {
# Test cross-compile infrastructure
"samba-xc": [
("random-sleep", "script/random-sleep.sh 900 1500"),
("random-sleep", random_sleep(900, 1500)),
("configure-native", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("configure-cross-execute", "./configure.developer --out ./bin-xe --cross-compile --cross-execute=script/identity_cc.sh" \
" --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xe/ab" + samba_configure_params),
@ -413,7 +423,7 @@ tasks = {
# test build with -O3 -- catches extra warnings and bugs, tests the ad_dc environments
"samba-o3": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "ADDITIONAL_CFLAGS='-O3 -Wp,-D_FORTIFY_SOURCE=2' ./configure.developer --with-selftest-prefix=./bin/ab --abi-check-disable" + samba_configure_params),
("make", "make -j"),
("test", "make quicktest FAIL_IMMEDIATELY=1 "
@ -425,7 +435,7 @@ tasks = {
],
"samba-ctdb": [
("random-sleep", "script/random-sleep.sh 900 1500"),
("random-sleep", random_sleep(900, 1500)),
# make sure we have tdb around:
("tdb-configure", "cd lib/tdb && PYTHONPATH=${PYTHON_PREFIX}:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}"),
@ -446,7 +456,7 @@ tasks = {
],
"samba-libs": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("talloc-configure", "cd lib/talloc && " + samba_libs_configure_libs),
("talloc-make", "cd lib/talloc && make"),
("talloc-install", "cd lib/talloc && make install"),
@ -476,7 +486,7 @@ tasks = {
],
"samba-none-env": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
("make", "make -j"),
("test", "make test "
@ -486,7 +496,7 @@ tasks = {
],
"samba-static": [
("random-sleep", "script/random-sleep.sh 1 1"),
("random-sleep", random_sleep(1, 1)),
# build with all modules static
("allstatic-configure", "./configure.developer " + samba_configure_params + " --with-static-modules=ALL"),
("allstatic-make", "make -j"),
@ -507,7 +517,7 @@ tasks = {
],
"samba-systemkrb5": [
("random-sleep", "script/random-sleep.sh 900 1500"),
("random-sleep", random_sleep(900, 1500)),
("configure", "./configure.developer " + samba_configure_params + " --with-system-mitkrb5 --with-experimental-mit-ad-dc"),
("make", "make -j"),
# we currently cannot run a full make test, a limited list of tests could be run
@ -527,7 +537,7 @@ tasks = {
# support this environment). The target here is for vendors
# shipping a minimal smbd.
"samba-nopython": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer ${ENABLE_COVERAGE} --picky-developer ${PREFIX} --with-profiling-data --disable-python --without-ad-dc"),
("make", "make -j"),
("install", "make install"),
@ -563,7 +573,7 @@ tasks = {
# check we can do the same thing using python2
"samba-nopython-py2": [
("random-sleep", "script/random-sleep.sh 300 900"),
("random-sleep", random_sleep(300, 900)),
("configure", "PYTHON=python2 ./configure.developer ${ENABLE_COVERAGE} --picky-developer ${PREFIX} --with-profiling-data --disable-python --without-ad-dc"),
("make", "PYTHON=python2 make -j"),
("install", "PYTHON=python2 make install"),
@ -598,7 +608,7 @@ tasks = {
],
"ldb": [
("random-sleep", "../../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "./configure ${ENABLE_COVERAGE} --enable-developer -C ${PREFIX}"),
("make", "make"),
("install", "make install"),
@ -616,7 +626,7 @@ tasks = {
],
"tdb": [
("random-sleep", "../../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "./configure ${ENABLE_COVERAGE} --enable-developer -C ${PREFIX}"),
("make", "make"),
("install", "make install"),
@ -628,7 +638,7 @@ tasks = {
],
"talloc": [
("random-sleep", "../../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "./configure ${ENABLE_COVERAGE} --enable-developer -C ${PREFIX}"),
("make", "make"),
("install", "make install"),
@ -640,7 +650,7 @@ tasks = {
],
"replace": [
("random-sleep", "../../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "./configure ${ENABLE_COVERAGE} --enable-developer -C ${PREFIX}"),
("make", "make"),
("install", "make install"),
@ -652,7 +662,7 @@ tasks = {
],
"tevent": [
("random-sleep", "../../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "./configure ${ENABLE_COVERAGE} --enable-developer -C ${PREFIX}"),
("make", "make"),
("install", "make install"),
@ -664,7 +674,7 @@ tasks = {
],
"pidl": [
("random-sleep", "../script/random-sleep.sh 60 600"),
("random-sleep", random_sleep(60, 600)),
("configure", "perl Makefile.PL PREFIX=${PREFIX_DIR}"),
("touch", "touch *.yp"),
("make", "make"),
@ -772,10 +782,6 @@ class buildlist(object):
tasknames = ["samba-test-only"]
else:
tasknames = defaulttasks
else:
# If we are only running one test,
# do not sleep randomly to wait for it to start
os.environ['AUTOBUILD_RANDOM_SLEEP_OVERRIDE'] = '1'
for n in tasknames:
b = builder(n, tasks[n], cp=n is not "pidl")

View File

@ -1,25 +0,0 @@
#!/bin/sh
#
if [ $# -lt 2 ]; then
echo "$0: <low> <high>"
exit 1;
fi
l=$1
h=$2
s=$(expr $h - $l)
r=$(head --bytes=2 /dev/urandom | od -l | head -n 1 | sed -e 's/^[^ ]* *//')
v=$(expr $r % $s)
d=$(expr $l + $v)
if test "x${AUTOBUILD_RANDOM_SLEEP_OVERRIDE}" != "x" ; then
d="${AUTOBUILD_RANDOM_SLEEP_OVERRIDE}"
fi
echo "$0: sleep $d ... start"
sleep $d
echo "$0: sleep $d ... end"