Example #1
0
def test_it(worker_count, my_vars_file):

    runname = str(uuid.uuid1()).replace("-", "")
    conf = os.path.join(os.environ['EPUMGMT_HOME'], "etc/epumgmt/main.conf")
    epu_opts = EPUMgmtOpts(name=runname, conf_file=conf)
    epu_opts.jsonvars = my_vars_file
    #epu_action.set_logfile(os.path.join(os.environ['EPUMGMT_HOME'], "tests/tests.logs"))

    cyvm_a = []
    (c, p, ac) = epumgmt.api.get_common(opts=epu_opts)
    persist = Persistence(p, c)
    persist.validate()
    cm = persist.cdb
    s_retry_count = 10

    print "RUNNAME IS %s" % (runname)
    service_name = os.environ['EPU_SERVICE']

    rc = 0
    error_msg = "SUCCESS"
    try:
        print "starting provisioner"
        epu_opts.haservice = "provisioner"
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        print "starting %s" % (service_name)
        epu_opts.haservice = service_name
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        epu_opts.haservice = None
        pre_kill_len = 0
        retry_count = s_retry_count
        while pre_kill_len != 2 + worker_count: 
            print "finding workers"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            epu_opts.action = ACTIONS.LOGFETCH
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            cm.commit()
            pre_kill_len = len(cyvm_a)
            retry_count = retry_count - 1
            if retry_count < 0:
                raise Exception("No new workers found after %d tries %d" % (s_retry_count, worker_count))
            time.sleep(20)

        epu_opts.action = ACTIONS.STATUS
        epumgmt_run(epu_opts)

    except Exception, ex:
        traceback.print_tb(sys.exc_info()[2])
        print "========= ERROR ===================="
        print ex
        print "============================="
        error_msg = str(ex)
        rc = 1
Example #2
0
def main(argv=sys.argv[1:]):

    service_name = os.environ['EPU_SERVICE']

    runname = str(uuid.uuid1()).replace("-", "")
    conf = os.path.join(os.environ['EPUMGMT_HOME'], "etc/epumgmt/main.conf")
    epu_opts = EPUMgmtOpts(name=runname, conf_file=conf)
    my_vars_file = os.environ['EPU_TEST_VARS']
    epu_opts.jsonvars = my_vars_file
    #epu_action.set_logfile(os.path.join(os.environ['EPUMGMT_HOME'], "tests/tests.logs"))

    cyvm_a = []
    (c, p, ac) = epumgmt.api.get_common(opts=epu_opts)
    persist = Persistence(p, c)
    persist.validate()
    cm = persist.cdb

    try:
        epu_opts.haservice = "provisioner"
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        epu_opts.haservice = service_name
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        cyvm_a = cm.get_iaas_by_runname(runname)

        if len(cyvm_a) != 2:
            raise Exception("the wrong number of VMs found by miner")

        found = 0
        for c in cyvm_a:
            if c.service_type == "provisioner":
                found = found + 1
            elif c.service_type == service_name:
                found = found + 1
            else:
                raise Exception("unknown service type found")
        if found != 2:
            raise Exception("did not find %s and/or provisioner" % (service_name))

    except Exception, ex:
        print ex
        return 1
def main(argv=sys.argv[1:]):

    runname = str(uuid.uuid1()).replace("-", "")
    conf = os.path.join(os.environ["EPUMGMT_HOME"], "etc/epumgmt/main.conf")
    epu_opts = EPUMgmtOpts(name=runname, conf_file=conf)
    my_vars_file = os.environ["EPU_TEST_VARS"]
    epu_opts.jsonvars = my_vars_file
    # epu_action.set_logfile(os.path.join(os.environ['EPUMGMT_HOME'], "tests/tests.logs"))

    cyvm_a = []
    (c, p, ac) = epumgmt.api.get_common(opts=epu_opts)
    persist = Persistence(p, c)
    persist.validate()
    cm = persist.cdb
    s_retry_count = 5
    worker_count = 2  # need to get this from conf file

    print "RUNNAME IS %s" % (runname)

    service_name = os.environ["EPU_SERVICE"]
    rc = 0
    error_msg = "SUCCESS"
    try:
        print "starting provisioner"
        epu_opts.haservice = "provisioner"
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        print "starting %s" % (service_name)
        epu_opts.haservice = service_name
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        epu_opts.haservice = None
        pre_kill_len = 0
        retry_count = s_retry_count
        while pre_kill_len != 2 + worker_count:
            print "finding workers"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            cm.commit()
            pre_kill_len = len(cyvm_a)
            retry_count = retry_count - 1
            if retry_count < 0:
                raise Exception("No new workers found after %d tries" % (s_retry_count))
            time.sleep(10)

        print "make sure hostnames have been achieved"
        done = False
        while not done:
            done = True
            epu_opts.action = ACTIONS.LOGFETCH
            epumgmt_run(epu_opts)

            print "finding workers hostnames"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            for c in cyvm_a:
                if c.hostname == None or c.hostname.strip() == "":
                    done = False
            cm.commit()

        epu_opts.action = ACTIONS.STATUS
        epumgmt_run(epu_opts)

        orig_iaas_ids = [c.iaasid for c in cyvm_a]

        print "KILLING A WORKER!"
        epu_opts.killnum = 1
        epu_opts.action = ACTIONS.FETCH_KILL
        epumgmt_run(epu_opts)

        cyvm_a = None
        post_kill_len = 0
        retry_count = s_retry_count
        while post_kill_len <= pre_kill_len:
            print "fetch logs"
            epu_opts.action = ACTIONS.LOGFETCH
            epumgmt_run(epu_opts)

            print "finding workers"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            post_kill_len = len(cyvm_a)
            retry_count = retry_count - 1
            if retry_count < 0:
                raise Exception("No new workers found after %d tries" % (s_retry_count))
            cm.commit()
            time.sleep(10)

        epu_opts.action = ACTIONS.STATUS
        epumgmt_run(epu_opts)

        new_iaas_ids = [c.iaasid for c in cyvm_a]

        orig_iaas_ids.sort()
        new_iaas_ids.sort()
        if orig_iaas_ids == new_iaas_ids:
            raise Exception("The iaas ids did not change: %s -> %s" % (str(orig_iaas_ids), str(new_iaas_ids)))

    except Exception, ex:
        traceback.print_tb(sys.exc_info()[2])
        print "========= ERROR ===================="
        print ex
        print "============================="
        error_msg = str(ex)
        rc = 1
def main(argv=sys.argv[1:]):

    service_name = os.environ['EPU_SERVICE']

    worker_count = 2
    runname = str(uuid.uuid1()).replace("-", "")
    conf = os.path.join(os.environ['EPUMGMT_HOME'], "etc/epumgmt/main.conf")
    epu_opts = EPUMgmtOpts(name=runname, conf_file=conf)
    my_vars_file = os.environ['EPU_TEST_VARS']
    epu_opts.jsonvars = my_vars_file
    #epu_action.set_logfile(os.path.join(os.environ['EPUMGMT_HOME'], "tests/tests.logs"))

    cyvm_a = []
    (c, p, ac) = epumgmt.api.get_common(opts=epu_opts)
    persist = Persistence(p, c) 
    persist.validate()
    cm = persist.cdb
    try:

        epu_opts.haservice = "provisioner"
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        epu_opts.haservice = service_name
        epu_opts.action = ACTIONS.CREATE
        epumgmt_run(epu_opts)

        epu_opts.haservice = None

        s_retry_count = 10
        pre_kill_len = 0
        retry_count = s_retry_count
        while pre_kill_len != 2 + worker_count:
            print "finding workers"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            cm.commit()
            pre_kill_len = len(cyvm_a)
            retry_count = retry_count - 1
            if retry_count < 0:
                raise Exception("No new workers found after %d tries" % (s_retry_count))
            time.sleep(10)
        print "make sure hostnames have been achieved"
        done = False
        while not done:
            done = True
            epu_opts.action = ACTIONS.LOGFETCH
            epumgmt_run(epu_opts)

            print "finding workers hostnames"
            epu_opts.action = ACTIONS.FIND_WORKERS_ONCE
            epumgmt_run(epu_opts)

            cyvm_a = cm.get_iaas_by_runname(runname)
            for c in cyvm_a:
                if c.hostname == None or c.hostname.strip() == "":
                    done = False
            cm.commit()
            time.sleep(10)

        # now check the logs to make sure the init events are there
        types = ["provisioner", "worker", service_name]
        for t in types:
            vm_a = cm.get_vms_by_type(runname, t)
            cm.commit()
            for vm in vm_a:
                found = False
                for e in vm.events:
                    if e.name == 'init_end':
                        found = True
                if not found:
                    raise Exception("init_end not found for %s" % (t))


    except Exception, ex:
        print ex
        return 1