diff options
author | Rob Austein <sra@hactrn.net> | 2010-03-10 21:08:02 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-03-10 21:08:02 +0000 |
commit | fadb9d40acfd9715e4cecee22b3f92ebb6d61bbf (patch) | |
tree | 1189010c97e723caf25868607bc2571d226355ef /myrpki.rototill | |
parent | bebec498d4c02306f50b1e52951377d3b97e1179 (diff) |
yamltest pidfile support
svn path=/myrpki.rototill/test-all.sh; revision=3070
Diffstat (limited to 'myrpki.rototill')
-rw-r--r-- | myrpki.rototill/test-all.sh | 4 | ||||
-rw-r--r-- | myrpki.rototill/yamltest.py | 280 |
2 files changed, 145 insertions, 139 deletions
diff --git a/myrpki.rototill/test-all.sh b/myrpki.rototill/test-all.sh index 50a8927b..b1ce0879 100644 --- a/myrpki.rototill/test-all.sh +++ b/myrpki.rototill/test-all.sh @@ -28,7 +28,7 @@ for i in ../rpkid/testbed.*.yaml do rm -rf test python sql-cleaner.py - screen python yamltest.py $i + screen python yamltest.py -p yamltest.pid $i date sleep 180 for j in . . . . . . . . . . @@ -39,7 +39,7 @@ do xsltproc --param refresh 0 ../rcynic/rcynic.xsl rcynic.xml | w3m -T text/html -dump date done - pstree -ws python | awk '/yamltest/ {system("kill -INT " $2)}' + test -r yamltest.pid && kill -INT `cat yamltest.pid` sleep 30 make backup done diff --git a/myrpki.rototill/yamltest.py b/myrpki.rototill/yamltest.py index c7bb2888..f50db49d 100644 --- a/myrpki.rototill/yamltest.py +++ b/myrpki.rototill/yamltest.py @@ -537,14 +537,17 @@ os.environ["TZ"] = "UTC" time.tzset() cfg_file = "yamltest.conf" +pidfile = None -opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +opts, argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help", "pidfile="]) for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) if o in ("-c", "--config"): cfg_file = a + elif o in ("-p", "--pidfile"): + pidfile = a # We can't usefully process more than one YAMl file at a time, so # whine if there's more than one argument left. @@ -552,164 +555,167 @@ for o, a in opts: if len(argv) > 1: raise RuntimeError, "Unexpected arguments %r" % argv -rpki.log.use_syslog = False -rpki.log.init("yamltest") +try: -yaml_file = argv[0] if argv else "../rpkid/testbed.1.yaml" + if pidfile is not None: + open(pidfile, "w").write("%s\n" % os.getpid()) -# Allow optional config file for this tool to override default -# passwords: this is mostly so that I can show a complete working -# example without publishing my own server's passwords. + rpki.log.use_syslog = False + rpki.log.init("yamltest") -try: - cfg = rpki.config.parser(cfg_file, "yamltest") - rpkid_password = cfg.get("rpkid_db_pass") - irdbd_password = cfg.get("irdbd_db_pass") - pubd_password = cfg.get("pubd_db_pass") - only_one_pubd = cfg.getboolean("only_one_pubd", True) - prog_openssl = cfg.get("openssl", prog_openssl) -except: - rpkid_password = None - irdbd_password = None - pubd_password = None - only_one_pubd = True - -# Start clean - -for root, dirs, files in os.walk(test_dir, topdown = False): - for file in files: - os.unlink(os.path.join(root, file)) - for dir in dirs: - os.rmdir(os.path.join(root, dir)) - -# Read first YAML doc in file and process as compact description of -# test layout and resource allocations. Ignore subsequent YAML docs, -# they're for testbed.py, not this script. - -db = allocation_db(yaml.safe_load_all(open(yaml_file)).next()) - -# Show what we loaded - -db.dump() - -# Set up each entity in our test - -for d in db: - os.makedirs(d.path()) - d.dump_asns("asns.csv") - d.dump_prefixes("prefixes.csv") - d.dump_roas("roas.csv") - d.dump_conf("myrpki.conf") - d.dump_rsyncd("rsyncd.conf") - if False: - d.dump_children("children.csv") - d.dump_parents("parents.csv") - d.dump_clients("pubclients.csv", db) - -# Initialize BPKI and generate self-descriptor for each entity. - -for d in db: - d.run_setup("initialize") - -# This is where we need to get clever about running setup.py in its -# various modes to do the service URL and BPKI cross-certification -# setup. - -for d in db: - if d.is_root(): - print - d.run_setup("answer_repository_client", d.path("entitydb", "repositories", "%s.xml" % d.name)) - print - d.run_setup("process_repository_answer", d.path("entitydb", "pubclients", "%s.xml" % d.name)) - print - else: - print - d.parent.run_setup("answer_child", d.path("entitydb", "identity.xml")) - print - d.run_setup("process_parent_answer", d.parent.path("entitydb", "children", "%s.xml" % d.name)) - print - p, n = d.find_pubd(want_path = True) - p.run_setup("answer_repository_client", d.path("entitydb", "repositories", "%s.xml" % d.parent.name)) - print - d.run_setup("process_repository_answer", p.path("entitydb", "pubclients", "%s.xml" % n)) - print - -# Run myrpki.py several times for each entity. First pass misses -# stuff that isn't generated until later in first pass. Second pass -# should pick up everything and reach a stable state. If anything -# changes during third pass, that's a bug. - -for i in xrange(3): - for d in db: - d.run_myrpki() + yaml_file = argv[0] if argv else "../rpkid/testbed.1.yaml" -# Create publication directories. + # Allow optional config file for this tool to override default + # passwords: this is mostly so that I can show a complete working + # example without publishing my own server's passwords. -for d in db: - if d.is_root() or d.runs_pubd(): - os.makedirs(d.path("publication")) + try: + cfg = rpki.config.parser(cfg_file, "yamltest") + rpkid_password = cfg.get("rpkid_db_pass") + irdbd_password = cfg.get("irdbd_db_pass") + pubd_password = cfg.get("pubd_db_pass") + only_one_pubd = cfg.getboolean("only_one_pubd", True) + prog_openssl = cfg.get("openssl", prog_openssl) + except: + rpkid_password = None + irdbd_password = None + pubd_password = None + only_one_pubd = True -# Create RPKI root certificate. + # Start clean -print "Creating rootd RPKI root certificate" + for root, dirs, files in os.walk(test_dir, topdown = False): + for file in files: + os.unlink(os.path.join(root, file)) + for dir in dirs: + os.rmdir(os.path.join(root, dir)) -# Should use req -subj here to set subject name. Later. -db.root.run_openssl("x509", "-req", "-sha256", "-outform", "DER", - "-signkey", "bpki/servers/ca.key", - "-in", "bpki/servers/ca.req", - "-out", "publication/root.cer", - "-extfile", "myrpki.conf", - "-extensions", "rootd_x509_extensions") + # Read first YAML doc in file and process as compact description of + # test layout and resource allocations. Ignore subsequent YAML docs, + # they're for testbed.py, not this script. -# At this point we need to start a whole lotta daemons. + db = allocation_db(yaml.safe_load_all(open(yaml_file)).next()) -progs = [] + # Show what we loaded -def all_daemons_running(): - for p in progs: - if p.poll() is not None: - return False - return True + db.dump() -try: - print "Running daemons" - progs.append(db.root.run_rootd()) - progs.extend(d.run_irdbd() for d in db if not d.is_hosted()) - progs.extend(d.run_pubd() for d in db if d.runs_pubd()) - progs.extend(d.run_rsyncd() for d in db if d.runs_pubd()) - progs.extend(d.run_rpkid() for d in db if not d.is_hosted()) + # Set up each entity in our test - print "Giving daemons time to start up" - time.sleep(20) + for d in db: + os.makedirs(d.path()) + d.dump_asns("asns.csv") + d.dump_prefixes("prefixes.csv") + d.dump_roas("roas.csv") + d.dump_conf("myrpki.conf") + d.dump_rsyncd("rsyncd.conf") + if False: + d.dump_children("children.csv") + d.dump_parents("parents.csv") + d.dump_clients("pubclients.csv", db) + + # Initialize BPKI and generate self-descriptor for each entity. - assert all_daemons_running() + for d in db: + d.run_setup("initialize") - # Run myirbe again for each host, to set up IRDB and RPKI objects. - # Need to run a second time to push BSC certs out to rpkid. Nothing - # should happen on the third pass. Oops, when hosting we need to - # run myrpki between myirbe passes, since only the hosted entity can - # issue the BSC, etc. + # This is where we need to get clever about running setup.py in its + # various modes to do the service URL and BPKI cross-certification + # setup. + + for d in db: + if d.is_root(): + print + d.run_setup("answer_repository_client", d.path("entitydb", "repositories", "%s.xml" % d.name)) + print + d.run_setup("process_repository_answer", d.path("entitydb", "pubclients", "%s.xml" % d.name)) + print + else: + print + d.parent.run_setup("answer_child", d.path("entitydb", "identity.xml")) + print + d.run_setup("process_parent_answer", d.parent.path("entitydb", "children", "%s.xml" % d.name)) + print + p, n = d.find_pubd(want_path = True) + p.run_setup("answer_repository_client", d.path("entitydb", "repositories", "%s.xml" % d.parent.name)) + print + d.run_setup("process_repository_answer", p.path("entitydb", "pubclients", "%s.xml" % n)) + print + + # Run myrpki.py several times for each entity. First pass misses + # stuff that isn't generated until later in first pass. Second pass + # should pick up everything and reach a stable state. If anything + # changes during third pass, that's a bug. for i in xrange(3): for d in db: d.run_myrpki() - for d in db: - d.run_myirbe() - print "Done initializing daemons" + # Create publication directories. - # Wait until something terminates. + for d in db: + if d.is_root() or d.runs_pubd(): + os.makedirs(d.path("publication")) - signal.signal(signal.SIGCHLD, lambda *dont_care: None) - if all_daemons_running(): - signal.pause() + # Create RPKI root certificate. -finally: + print "Creating rootd RPKI root certificate" + + # Should use req -subj here to set subject name. Later. + db.root.run_openssl("x509", "-req", "-sha256", "-outform", "DER", + "-signkey", "bpki/servers/ca.key", + "-in", "bpki/servers/ca.req", + "-out", "publication/root.cer", + "-extfile", "myrpki.conf", + "-extensions", "rootd_x509_extensions") - # Shut everything down. + # At this point we need to start a whole lotta daemons. - signal.signal(signal.SIGCHLD, signal.SIG_DFL) - for p in progs: - if p.poll() is None: - os.kill(p.pid, signal.SIGTERM) - print "Program pid %d %r returned %d" % (p.pid, p, p.wait()) + progs = [] + + try: + print "Running daemons" + progs.append(db.root.run_rootd()) + progs.extend(d.run_irdbd() for d in db if not d.is_hosted()) + progs.extend(d.run_pubd() for d in db if d.runs_pubd()) + progs.extend(d.run_rsyncd() for d in db if d.runs_pubd()) + progs.extend(d.run_rpkid() for d in db if not d.is_hosted()) + + print "Giving daemons time to start up" + time.sleep(20) + + assert all(p.poll() is None for p in progs) + + # Run myirbe again for each host, to set up IRDB and RPKI objects. + # Need to run a second time to push BSC certs out to rpkid. Nothing + # should happen on the third pass. Oops, when hosting we need to + # run myrpki between myirbe passes, since only the hosted entity can + # issue the BSC, etc. + + for i in xrange(3): + for d in db: + d.run_myrpki() + for d in db: + d.run_myirbe() + + print "Done initializing daemons" + + # Wait until something terminates. + + signal.signal(signal.SIGCHLD, lambda *dont_care: None) + if all(p.poll() is None for p in progs): + signal.pause() + + finally: + + # Shut everything down. + + signal.signal(signal.SIGCHLD, signal.SIG_DFL) + for p in progs: + if p.poll() is None: + os.kill(p.pid, signal.SIGTERM) + print "Program pid %d %r returned %d" % (p.pid, p, p.wait()) + +finally: + if pidfile is not None: + os.unlink(pidfile) |