def main():
    parser = argparse.ArgumentParser(description='Run integration tests')
    parser.add_argument('--chisel',
                        dest="run_chisel",
                        action="store_true",
                        help="run integration tests using chisel")
    parser.add_argument('--gotest',
                        dest="run_go",
                        action="store_true",
                        help="run Go integration tests")
    parser.add_argument('--filter',
                        dest="test_case_filter",
                        action="store",
                        help="Regex filter for test cases")
    # allow any ACME client to run custom command for integration
    # testing (without having to implement its own busy-wait loop)
    parser.add_argument('--custom', metavar="CMD", help="run custom command")
    parser.set_defaults(run_chisel=False,
                        test_case_filter="",
                        skip_setup=False)
    args = parser.parse_args()

    if not (args.run_chisel or args.custom or args.run_go is not None):
        raise (Exception(
            "must run at least one of the letsencrypt or chisel tests with --chisel, --gotest, or --custom"
        ))

    # Setup issuance hierarchy
    startservers.setupHierarchy()

    if not args.test_case_filter:
        now = datetime.datetime.utcnow()

        six_months_ago = now + datetime.timedelta(days=-30 * 6)
        if not startservers.start(race_detection=race_detection,
                                  fakeclock=fakeclock(six_months_ago)):
            raise (Exception("startservers failed (mocking six months ago)"))
        v1_integration.caa_client = caa_client = chisel.make_client()
        setup_six_months_ago()
        startservers.stop()

        twenty_days_ago = now + datetime.timedelta(days=-20)
        if not startservers.start(race_detection=race_detection,
                                  fakeclock=fakeclock(twenty_days_ago)):
            raise (Exception("startservers failed (mocking twenty days ago)"))
        setup_twenty_days_ago()
        startservers.stop()

    if not startservers.start(race_detection=race_detection, fakeclock=None):
        raise (Exception("startservers failed"))

    if args.run_chisel:
        run_chisel(args.test_case_filter)

    if args.run_go:
        run_go_tests(args.test_case_filter)

    if args.custom:
        run(args.custom)

    # Skip the last-phase checks when the test case filter is one, because that
    # means we want to quickly iterate on a single test case.
    if not args.test_case_filter:
        run_cert_checker()
        check_balance()
        if not CONFIG_NEXT:
            run_expired_authz_purger()

        # Run the boulder-janitor. This should happen after all other tests because
        # it runs with the fake clock set to the future and deletes rows that may
        # otherwise be referenced by tests.
        run_janitor()

        # Run the load-generator last. run_loadtest will stop the
        # pebble-challtestsrv before running the load-generator and will not restart
        # it.
        run_loadtest()

    if not startservers.check():
        raise (Exception("startservers.check failed"))

    # This test is flaky, so it's temporarily disabled.
    # TODO(#4583): Re-enable this test.
    #check_slow_queries()

    global exit_status
    exit_status = 0
Example #2
0
start them all on their own ports (see test/startservers.py)

Keeps servers alive until ^C. Exit non-zero if any servers fail to
start, or die before ^C.
"""

import errno
import os
import sys
import time

sys.path.append('./test')
import startservers

# Setup issuance hierarchy
startservers.setupHierarchy()

if not startservers.start(race_detection=False, fakeclock=None):
    sys.exit(1)
try:
    os.wait()

    # If we reach here, a child died early. Log what died:
    startservers.check()
    sys.exit(1)
except KeyboardInterrupt:
    print("\nstopping servers.")
except OSError as v:
    # Ignore EINTR, which happens when we get SIGTERM or SIGINT (i.e. when
    # someone hits Ctrl-C after running docker-compose up or start.py.
    if v.errno != errno.EINTR: