示例#1
0
def test_real_procurement_propagate2():
    """Test that a local file will not report propagation needed.
    """
    
    handle = "wrksp-412"
    relative_filename_testfile = "some-base-cluster-01.gz"
    createargs = ["--action", "create", 
                  "--name", handle,
                  "--memory", "256",
                  "--images", "file://%s" % relative_filename_testfile,
                  "--imagemounts", "xvda1",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate2()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    try:
        filelist = [relative_filename_testfile]
        _create_fake_securedir_files(p, c, handle, filelist)
        
        assert not procure.lengthy_obtain()
        
    finally:
        _destroy_fake_securedir(p, c, handle)
示例#2
0
def test_netlease1():
    """Test network leases based on old commandline args"""

    # a direct sample from logs, trailing null business (the very first
    # contextualization impl) is ignored entirely in the new workspace-control
    arg = "publicnic;public;A2:AA:BB:2C:36:9A;Bridged;Static;"
    arg += "128.135.125.22;128.135.125.1;128.135.125.255;"
    arg += "255.255.255.0;128.135.247.50;tp-x002.ci.uchicago.edu"
    arg += ";null;null;null;null"

    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_netlease1()")
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p, c)

    # should validate without error
    netlease.validate()

    nic = netlease.obtain("vm1", "publicnic", "public")
    assert nic
    assert nic.name == "publicnic"
    assert nic.network == "public"
    assert nic.mac == "A2:AA:BB:2C:36:9A"
    assert nic.ip == "128.135.125.22"
    assert nic.gateway == "128.135.125.1"
    assert nic.broadcast == "128.135.125.255"
    assert nic.netmask == "255.255.255.0"
    assert nic.dns == "128.135.247.50"
    assert nic.hostname == "tp-x002.ci.uchicago.edu"
示例#3
0
def test_image_compress1():
    """Test file compression"""
    
    createargs = ["--action", "unpropagate", 
                  "--name", "wrksp-929",
                  "--images", "scp://somehost/some-base-cluster-01",
                  "--unproptargets", "scp://somehost/some-newfile.gz",
                  "--dryrun"
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_image_compress1()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    local_file_set = procure.obtain()
    
    editing_cls = c.get_class_by_keyword("ImageEditing")
    editing = editing_cls(p, c)
    editing.validate()
    
    editing.process_after_shutdown(local_file_set)
    procure.process_after_shutdown(local_file_set)
示例#4
0
def test_real_procurement_propagate8():
    """Test that a mismatch of images and mountpoints will cause an error
    """
    
    handle = "wrksp-499"
    createargs = ["--action", "create", 
                  "--name", handle,
                  "--memory", "256",
                  "--images", "scp://somehost/some-base-cluster-01.gz",
                  "--imagemounts", "xvda1;;xvda2",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate8()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    invalid_input = False
    try:
        procure.lengthy_obtain()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#5
0
def test_netlease2():
    """Test network leases based on old commandline args 2"""

    arg = "publicnic;public;A2:AA:BB:2C:36:9A;Bridged;Static;"
    arg += "128.135.125.22;128.135.125.1;128.135.125.255;"
    arg += "255.255.255.0;128.135.247.50;tp-x002.ci.uchicago.edu"

    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_netlease2()")
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p, c)

    # should validate without error
    netlease.validate()

    nic = netlease.obtain("vm1", "publicnic", "public")
    assert nic
    assert nic.name == "publicnic"
    assert nic.network == "public"
    assert nic.mac == "A2:AA:BB:2C:36:9A"
    assert nic.ip == "128.135.125.22"
    assert nic.gateway == "128.135.125.1"
    assert nic.broadcast == "128.135.125.255"
    assert nic.netmask == "255.255.255.0"
    assert nic.dns == "128.135.247.50"
    assert nic.hostname == "tp-x002.ci.uchicago.edu"
示例#6
0
def test_real_procurement_propagate1():
    """Test the procurement adapter propagate awareness (positive)"""

    handle = "wrksp-411"
    createargs = [
        "--action",
        "create",
        "--name",
        handle,
        "--memory",
        "256",
        "--images",
        "scp://somehost/some-base-cluster-01.gz",
        "--imagemounts",
        "xvda1",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate1()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    assert procure.lengthy_obtain()
示例#7
0
def test_notification3():
    """Test notification validation"""

    handle = "wrksp-104"
    createargs = [
        "--action", "unpropagate", "--name", handle, "--images",
        "scp://somehost/some-base-cluster-01.gz", "--notify",
        "nimbus@somehost:22/somepath", "--dryrun"
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_notification3()")

    notify_cls = c.get_class_by_keyword("AsyncNotification")
    notify = notify_cls(p, c)

    # should throw no error
    notify.validate()

    notify.notify(handle, "propagate", 0, None)
    notify.notify(handle, "propagate", 1, "bad\nbad\nbad")

    programming_error = False
    try:
        notify.notify(handle, "XYZpropagate", 1, "bad\nbad")
    except ProgrammingError:
        programming_error = True
    assert programming_error
示例#8
0
def test_image_compress1():
    """Test file compression"""

    createargs = [
        "--action", "unpropagate", "--name", "wrksp-929", "--images",
        "scp://somehost/some-base-cluster-01", "--unproptargets",
        "scp://somehost/some-newfile.gz", "--dryrun"
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_image_compress1()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    local_file_set = procure.obtain()

    editing_cls = c.get_class_by_keyword("ImageEditing")
    editing = editing_cls(p, c)
    editing.validate()

    editing.process_after_shutdown(local_file_set)
    procure.process_after_shutdown(local_file_set)
示例#9
0
def test_real_procurement_unpropagate3():
    """Test that procurement adapter rejects blanksspace requests in unpropagate"""

    handle = "wrksp-414"
    createargs = [
        "--action",
        "unpropagate",
        "--name",
        handle,
        "--images",
        "scp://somehost/some-base-cluster-01.gz;;blankspace://blah-size-40",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_unpropagate3()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    invalid_input = False
    try:
        procure.lengthy_shutdown()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#10
0
def test_notification2():
    """Test notification validation (negative2)"""

    createargs = [
        "--action",
        "unpropagate",
        "--name",
        "wrksp-114",
        "--images",
        "scp://somehost/some-base-cluster-01.gz",
        "--notify",
        "nimbus@somehost:22",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_notification2()")

    notify_cls = c.get_class_by_keyword("AsyncNotification")
    notify = notify_cls(p, c)

    invalid_input = False
    try:
        notify.validate()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#11
0
def test_real_procurement_propagate8():
    """Test that a mismatch of images and mountpoints will cause an error
    """

    handle = "wrksp-499"
    createargs = [
        "--action",
        "create",
        "--name",
        handle,
        "--memory",
        "256",
        "--images",
        "scp://somehost/some-base-cluster-01.gz",
        "--imagemounts",
        "xvda1;;xvda2",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate8()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    invalid_input = False
    try:
        procure.lengthy_obtain()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#12
0
def test_real_procurement_unpropagate2():
    """Test the procurement adapter unpropagate syntax (negative)"""

    handle = "wrksp-414"
    createargs = [
        "--action",
        "unpropagate",
        "--name",
        handle,
        "--images",
        "file://somehost/some-base-cluster-01.gz",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_unpropagate2()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    invalid_input = False
    try:
        procure.lengthy_shutdown()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#13
0
def test_real_procurement_propagate6():
    """Test that multiple image inputs are OK
    """

    handle = "wrksp-499"
    createargs = [
        "--action",
        "create",
        "--name",
        handle,
        "--memory",
        "256",
        "--images",
        "scp://somehost/some-base-cluster-01.gz;;scp://someotherhost/someother-base-cluster-01.gz",
        "--imagemounts",
        "xvda1;;xvda2",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate6()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    assert procure.lengthy_obtain()
示例#14
0
def test_netlease1():
    """Test network leases based on old commandline args"""
    
    # a direct sample from logs, trailing null business (the very first
    # contextualization impl) is ignored entirely in the new workspace-control
    arg = "publicnic;public;A2:AA:BB:2C:36:9A;Bridged;Static;"
    arg += "128.135.125.22;128.135.125.1;128.135.125.255;"
    arg += "255.255.255.0;128.135.247.50;tp-x002.ci.uchicago.edu"
    arg += ";null;null;null;null"
    
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_netlease1()")
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p,c)
    
    # should validate without error
    netlease.validate()
    
    nic = netlease.obtain("vm1", "publicnic", "public")
    assert nic
    assert nic.name == "publicnic"
    assert nic.network == "public"
    assert nic.mac == "A2:AA:BB:2C:36:9A"
    assert nic.ip == "128.135.125.22"
    assert nic.gateway == "128.135.125.1"
    assert nic.broadcast == "128.135.125.255"
    assert nic.netmask == "255.255.255.0"
    assert nic.dns == "128.135.247.50"
    assert nic.hostname == "tp-x002.ci.uchicago.edu"
示例#15
0
def test_netlease2():
    """Test network leases based on old commandline args 2"""
    
    arg = "publicnic;public;A2:AA:BB:2C:36:9A;Bridged;Static;"
    arg += "128.135.125.22;128.135.125.1;128.135.125.255;"
    arg += "255.255.255.0;128.135.247.50;tp-x002.ci.uchicago.edu"
    
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_netlease2()")
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p,c)
    
    # should validate without error
    netlease.validate()
    
    nic = netlease.obtain("vm1", "publicnic", "public")
    assert nic
    assert nic.name == "publicnic"
    assert nic.network == "public"
    assert nic.mac == "A2:AA:BB:2C:36:9A"
    assert nic.ip == "128.135.125.22"
    assert nic.gateway == "128.135.125.1"
    assert nic.broadcast == "128.135.125.255"
    assert nic.netmask == "255.255.255.0"
    assert nic.dns == "128.135.247.50"
    assert nic.hostname == "tp-x002.ci.uchicago.edu"
示例#16
0
def test_notification3():
    """Test notification validation"""
    
    handle = "wrksp-104"
    createargs = ["--action", "unpropagate", 
                  "--name", handle,
                  "--images", "scp://somehost/some-base-cluster-01.gz",
                  "--notify", "nimbus@somehost:22/somepath",
                  "--dryrun"
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_notification3()")
    
    notify_cls = c.get_class_by_keyword("AsyncNotification")
    notify = notify_cls(p, c)
    
    # should throw no error
    notify.validate()
    
    notify.notify(handle, "propagate", 0, None)
    notify.notify(handle, "propagate", 1, "bad\nbad\nbad")
    
    programming_error = False
    try:
        notify.notify(handle, "XYZpropagate", 1, "bad\nbad")
    except ProgrammingError:
        programming_error = True
    assert programming_error
示例#17
0
def test_real_procurement_propagate3():
    """Test that an unknown propagation scheme will cause an error.
    """
    
    handle = "wrksp-412"
    relative_filename_testfile = "some-base-cluster-01.gz"
    createargs = ["--action", "create", 
                  "--name", handle,
                  "--memory", "256",
                  "--images", "zzfile://%s" % relative_filename_testfile,
                  "--imagemounts", "xvda1",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate3()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    try:
        filelist = [relative_filename_testfile]
        _create_fake_securedir_files(p, c, handle, filelist)
        
        invalid_input = False
        try:
            procure.lengthy_obtain()
        except InvalidInput:
            invalid_input = True
        assert invalid_input
        
    finally:
        _destroy_fake_securedir(p, c, handle)
示例#18
0
def netlease_errors_common(arg, test_description):
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])
    p,c = get_pc(opts, realconfigs())
    c.log.debug(test_description)
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p,c)
    
    # should not validate
    invalid_input = False
    try:
        netlease.validate()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#19
0
def netlease_errors_common(arg, test_description):
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(["--networking", arg])
    p, c = get_pc(opts, realconfigs())
    c.log.debug(test_description)
    netlease_cls = c.get_class_by_keyword("NetworkLease")
    netlease = netlease_cls(p, c)

    # should not validate
    invalid_input = False
    try:
        netlease.validate()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#20
0
def test_real_procurement_unpropagate1():
    """Test the procurement adapter unpropagate awareness (positive)"""
    
    handle = "wrksp-2133"
    createargs = ["--action", "unpropagate", 
                  "--name", handle,
                  "--images", "scp://somehost/some-base-cluster-01.gz",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_unpropagate1()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    assert procure.lengthy_shutdown()
示例#21
0
def test_real_procurement_propagate3():
    """Test that an unknown propagation scheme will cause an error.
    """

    handle = "wrksp-412"
    relative_filename_testfile = "some-base-cluster-01.gz"
    createargs = [
        "--action",
        "create",
        "--name",
        handle,
        "--memory",
        "256",
        "--images",
        "zzfile://%s" % relative_filename_testfile,
        "--imagemounts",
        "xvda1",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate3()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    try:
        filelist = [relative_filename_testfile]
        _create_fake_securedir_files(p, c, handle, filelist)

        invalid_input = False
        try:
            procure.lengthy_obtain()
        except InvalidInput:
            invalid_input = True
        assert invalid_input

    finally:
        _destroy_fake_securedir(p, c, handle)
示例#22
0
def test_real_procurement_propagate6():
    """Test that multiple image inputs are OK
    """
    
    handle = "wrksp-499"
    createargs = ["--action", "create", 
                  "--name", handle,
                  "--memory", "256",
                  "--images", "scp://somehost/some-base-cluster-01.gz;;scp://someotherhost/someother-base-cluster-01.gz",
                  "--imagemounts", "xvda1;;xvda2",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate6()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    assert procure.lengthy_obtain()
示例#23
0
def test_notification2():
    """Test notification validation (negative2)"""
    
    createargs = ["--action", "unpropagate", 
                  "--name", "wrksp-114",
                  "--images", "scp://somehost/some-base-cluster-01.gz",
                  "--notify", "nimbus@somehost:22",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_notification2()")
    
    notify_cls = c.get_class_by_keyword("AsyncNotification")
    notify = notify_cls(p, c)
    
    invalid_input = False
    try:
        notify.validate()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#24
0
def test_real_procurement_propagate2():
    """Test that a local file will not report propagation needed.
    """

    handle = "wrksp-412"
    relative_filename_testfile = "some-base-cluster-01.gz"
    createargs = [
        "--action",
        "create",
        "--name",
        handle,
        "--memory",
        "256",
        "--images",
        "file://%s" % relative_filename_testfile,
        "--imagemounts",
        "xvda1",
    ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)

    p, c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_propagate2()")

    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()

    try:
        filelist = [relative_filename_testfile]
        _create_fake_securedir_files(p, c, handle, filelist)

        assert not procure.lengthy_obtain()

    finally:
        _destroy_fake_securedir(p, c, handle)
示例#25
0
def test_real_procurement_unpropagate3():
    """Test that procurement adapter rejects blanksspace requests in unpropagate"""
    
    handle = "wrksp-414"
    createargs = ["--action", "unpropagate", 
                  "--name", handle,
                  "--images", "scp://somehost/some-base-cluster-01.gz;;blankspace://blah-size-40",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_unpropagate3()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    invalid_input = False
    try:
        procure.lengthy_shutdown()
    except InvalidInput:
        invalid_input = True
    assert invalid_input
示例#26
0
def test_real_procurement_unpropagate2():
    """Test the procurement adapter unpropagate syntax (negative)"""
    
    handle = "wrksp-414"
    createargs = ["--action", "unpropagate", 
                  "--name", handle,
                  "--images", "file://somehost/some-base-cluster-01.gz",
                 ]
    parser = wc_optparse.parsersetup()
    (opts, args) = parser.parse_args(createargs)
    
    p,c = get_pc(opts, realconfigs())
    c.log.debug("test_real_procurement_unpropagate2()")
    
    procure_cls = c.get_class_by_keyword("ImageProcurement")
    procure = procure_cls(p, c)
    procure.validate()
    
    invalid_input = False
    try:
        procure.lengthy_shutdown()
    except InvalidInput:
        invalid_input = True
    assert invalid_input