Beispiel #1
0
 def start_responding():
     requests = get_model("SpotInstanceRequest", aws_region)
     while not requests:
         requests = get_model("SpotInstanceRequest", aws_region)
     [request] = requests
     [instance] = ec2.run_instances(ImageId="ami-1e749f67", MaxCount=1, MinCount=1)[
         "Instances"
     ]
     request.state = "active"
     request.instance_id = instance["InstanceId"]
Beispiel #2
0
def test_request_spot_instances_setting_instance_id():
    conn = boto.ec2.connect_to_region("us-east-1")
    request = conn.request_spot_instances(price=0.5, image_id='ami-abcd1234')

    req = get_model('SpotInstanceRequest', 'us-east-1')[0]
    req.state = 'active'
    req.instance_id = 'i-12345678'

    request = conn.get_all_spot_instance_requests()[0]
    assert request.state == 'active'
    assert request.instance_id == 'i-12345678'
Beispiel #3
0
def test_request_spot_instances_setting_instance_id():
    conn = boto.ec2.connect_to_region("us-east-1")
    request = conn.request_spot_instances(price=0.5, image_id="ami-abcd1234")

    req = get_model("SpotInstanceRequest", "us-east-1")[0]
    req.state = "active"
    req.instance_id = "i-12345678"

    request = conn.get_all_spot_instance_requests()[0]
    assert request.state == "active"
    assert request.instance_id == "i-12345678"
Beispiel #4
0
def test_request_spot_instances_setting_instance_id():
    conn = boto.ec2.connect_to_region("us-east-1")
    request = conn.request_spot_instances(
        price=0.5, image_id='ami-abcd1234')

    req = get_model('SpotInstanceRequest', 'us-east-1')[0]
    req.state = 'active'
    req.instance_id = 'i-12345678'

    request = conn.get_all_spot_instance_requests()[0]
    assert request.state == 'active'
    assert request.instance_id == 'i-12345678'
Beispiel #5
0
def test_request_spot_instances_fulfilled():
    """
    Test that moto correctly fullfills a spot instance request
    """
    conn = boto.ec2.connect_to_region("us-east-1")

    request = conn.request_spot_instances(price=0.5, image_id="ami-abcd1234")

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")

    get_model("SpotInstanceRequest", "us-east-1")[0].state = "active"

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("active")
Beispiel #6
0
def test_request_spot_instances_fulfilled():
    """
    Test that moto correctly fullfills a spot instance request
    """
    conn = boto.ec2.connect_to_region("us-east-1")

    request = conn.request_spot_instances(
        price=0.5, image_id='ami-abcd1234',
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")

    get_model('SpotInstanceRequest', 'us-east-1')[0].state = 'active'

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("active")
Beispiel #7
0
def test_request_spot_instances_fulfilled():
    """
    Test that moto correctly fullfills a spot instance request
    """
    conn = boto.connect_ec2()

    request = conn.request_spot_instances(
        price=0.5,
        image_id='ami-abcd1234',
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")

    get_model('SpotInstanceRequest')[0].state = 'active'

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("active")