diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-08-12 11:09:50 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-08-12 11:09:50 +1000 |
commit | 7bc566a88277ecbc0f712b7c54116163930f187d (patch) | |
tree | ce4729556fcc2669321b72024d613a97f7504581 | |
parent | 69fa901bca9b1e032d6784df60a0e1c14d27d830 (diff) | |
download | samba-7bc566a88277ecbc0f712b7c54116163930f187d.tar.gz samba-7bc566a88277ecbc0f712b7c54116163930f187d.tar.bz2 samba-7bc566a88277ecbc0f712b7c54116163930f187d.zip |
s4:provision Allow provision-backend to not run slapd for 'make test'
As the version of OpenLDAP required for Samba4 is fairly new, we don't
want to make it a requirement before this python code is run in 'make
test'.
As such, skip over the actual starting of slapd, but check the rest
runs alright (which still validates syntax and other modules).
Andrew Bartlett
-rw-r--r-- | source4/scripting/python/samba/provision.py | 45 | ||||
-rwxr-xr-x | source4/setup/provision-backend | 6 | ||||
-rwxr-xr-x | source4/setup/tests/blackbox_provision-backend.sh | 10 |
3 files changed, 33 insertions, 28 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 634904441a..39c3fffce3 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -1275,7 +1275,7 @@ def provision_backend(setup_dir=None, message=None, domain=None, hostname=None, adminpass=None, root=None, serverrole=None, ldap_backend_type=None, ldap_backend_port=None, ol_mmr_urls=None, ol_olc=None, - ol_slapd=None, nosync=False): + ol_slapd=None, nosync=False, testing_mode=False): def setup_path(file): return os.path.join(setup_dir, file) @@ -1303,7 +1303,7 @@ def provision_backend(setup_dir=None, message=None, targetdir) # if openldap-backend was chosen, check if path to slapd was given and exists - if ldap_backend_type == "openldap" and ol_slapd is None: + if ldap_backend_type == "openldap" and ol_slapd is None and not testing_mode: sys.exit("Warning: OpenLDAP-Backend must be setup with path to slapd (OpenLDAP-Daemon), e.g. --ol-slapd=\"/usr/local/libexec/slapd\"!") if ldap_backend_type == "openldap" and ol_slapd is not None: if not os.path.exists(ol_slapd): @@ -1659,26 +1659,27 @@ def provision_backend(setup_dir=None, message=None, print e message("Ok. - No other slapd-Instance listening on: " + ldapi_uri + ". Starting slapd now for final provision.") - p = subprocess.Popen(slapdcommand_prov, shell=True) - - # after startup: store slapd-provision-pid also in a separate file. - # this is needed as long as provision/provision-backend are not fully merged, - # to compare pids before shutting down - - # wait for pidfile to be created - time.sleep(3) - if os.path.exists(paths.slapdpid): - f = open(paths.slapdpid, "r") - p = f.read() - f.close() - f = open(paths.ldapdir +"/slapd_provision_pid", "w") - f.write(str(p) + "\n") - f.close() - message("Started slapd for final provisioning with PID: "+ str(p)) - else: - message("slapd-PID File could not be found. Sorry") - - # done slapd checking + start + if not testing_mode: + p = subprocess.Popen(slapdcommand_prov, shell=True) + + # after startup: store slapd-provision-pid also in a separate file. + # this is needed as long as provision/provision-backend are not fully merged, + # to compare pids before shutting down + + # wait for pidfile to be created + time.sleep(3) + if os.path.exists(paths.slapdpid): + f = open(paths.slapdpid, "r") + p = f.read() + f.close() + f = open(paths.ldapdir +"/slapd_provision_pid", "w") + f.write(str(p) + "\n") + f.close() + message("Started slapd for final provisioning with PID: "+ str(p)) + else: + message("slapd-PID File could not be found. Sorry") + + # done slapd checking + start diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend index fb7f56b881..3da360447f 100755 --- a/source4/setup/provision-backend +++ b/source4/setup/provision-backend @@ -73,6 +73,9 @@ parser.add_option("--ol-olc", type="choice", metavar="OPENLDAP-OLC", choices=["yes", "no"]) parser.add_option("--ol-slapd", type="string", metavar="SLAPD-PATH", help="Path to OpenLDAP-Daemon (slapd) [e.g.:'/usr/local/libexec/slapd']. Required for Setup with OpenLDAP-Backend. OpenLDAP Version >= 2.4.17 should be used.") +parser.add_option("--testing-mode", type="choice", metavar="TESTING-MODE", + help="Do not select this option, except as part of 'make test' to verify behaviour without a slapd on the system", + choices=["yes", "no"]) opts = parser.parse_args()[0] @@ -112,4 +115,5 @@ provision_backend(setup_dir=setup_dir, message=message, smbconf=smbconf, targetd ol_mmr_urls=opts.ol_mmr_urls, ol_olc=opts.ol_olc, ol_slapd=opts.ol_slapd, - nosync=opts.nosync) + nosync=opts.nosync, + testing_mode=opts.testing_mode) diff --git a/source4/setup/tests/blackbox_provision-backend.sh b/source4/setup/tests/blackbox_provision-backend.sh index 04f22dbf1d..e1331d62eb 100755 --- a/source4/setup/tests/blackbox_provision-backend.sh +++ b/source4/setup/tests/blackbox_provision-backend.sh @@ -12,13 +12,13 @@ shift 1 . `dirname $0`/../../../testprogs/blackbox/subunit.sh -testit "openldap-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend -testit "openldap-mmr-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-mmr-backend --ol-mmr-urls='ldap://localdc1:9000,ldap://localdc2:9000,ldap://localdc3:9000' -testit "fedora-ds-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=fedora-ds --targetdir=$PREFIX/fedora-ds-backend +testit "openldap-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend --testing-mode=yes --ol-slapd=/dev/null +testit "openldap-mmr-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-mmr-backend --ol-mmr-urls='ldap://localdc1:9000,ldap://localdc2:9000,ldap://localdc3:9000' --testing-mode=yes --ol-slapd=/dev/null +testit "fedora-ds-backend" $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=fedora-ds --targetdir=$PREFIX/fedora-ds-backend --testing-mode=yes --ol-slapd=/dev/null reprovision() { - $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend-reprovision - $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend-reprovision + $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend-reprovision --testing-mode=yes --ol-slapd=/dev/null + $PYTHON ./setup/provision-backend --domain=FOO --realm=foo.example.com --host-name=samba --ldap-backend-type=openldap --targetdir=$PREFIX/openldap-backend-reprovision --testing-mode=yes --ol-slapd=/dev/null } testit "reprovision-backend" reprovision |