예제 #1
0
def test_first_warning_for_near_limit(tenant, keystone, nova, now,
                                      suspend_tenant, check_cpu_usage,
                                      set_status, send_email):
    check_cpu_usage.return_value = CPULimit.NEAR_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    set_status.assert_called_with(keystone, tenant,
                                  'quota warning')
    send_email.assert_called_with(tenant, 'first')
    assert not suspend_tenant.called
예제 #2
0
def test_first_warning_for_near_limit(tenant, keystone, nova, now,
                                      suspend_tenant, check_cpu_usage,
                                      set_status, send_email):
    check_cpu_usage.return_value = CPULimit.NEAR_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    set_status.assert_called_with(keystone, tenant,
                                  'quota warning')
    send_email.assert_called_with(tenant, 'first')
    assert not suspend_tenant.called
예제 #3
0
def test_over_limit_but_not_expired(tenant, keystone, nova, now,
                                    suspend_tenant, check_cpu_usage,
                                    set_status):
    tenant.status = 'pending suspension'
    tenant.expires = '2014-06-01'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    # Do nothing.
    assert not suspend_tenant.called
    assert not set_status.called
예제 #4
0
def test_over_limit_but_not_expired(tenant, keystone, nova, now,
                                    suspend_tenant, check_cpu_usage,
                                    set_status):
    tenant.status = 'pending suspension'
    tenant.expires = '2014-06-01'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    # Do nothing.
    assert not suspend_tenant.called
    assert not set_status.called
예제 #5
0
def test_suspend_expired_and_pending_suspension_tenant(tenant,
                                                       keystone,
                                                       nova,
                                                       now,
                                                       suspend_tenant,
                                                       check_cpu_usage):
    tenant.status = 'pending suspension'
    tenant.expires = '2013-12-31'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    suspend_tenant.assert_called_with(keystone, nova, tenant)
예제 #6
0
def test_suspend_expired_and_pending_suspension_tenant(tenant,
                                                       keystone,
                                                       nova,
                                                       now,
                                                       suspend_tenant,
                                                       check_cpu_usage):
    tenant.status = 'pending suspension'
    tenant.expires = '2013-12-31'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    suspend_tenant.assert_called_with(keystone, nova, tenant)
예제 #7
0
def test_second_warning_for_over_limit(tenant, keystone, nova, now,
                                       suspend_tenant, check_cpu_usage,
                                       set_status, set_nova_quota):
    tenant.status = 'quota warning'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    expires = '2014-02-01'
    set_status.assert_called_with(keystone, tenant,
                                  'pending suspension', expires)
    set_nova_quota.assert_called_with(nova, tenant.id,
                                      ram=0, instances=0, cores=0)
    assert not suspend_tenant.called
예제 #8
0
def test_second_warning_for_over_limit(tenant, keystone, nova, now,
                                       suspend_tenant, check_cpu_usage,
                                       set_status, set_nova_quota):
    tenant.status = 'quota warning'
    check_cpu_usage.return_value = CPULimit.OVER_LIMIT
    with freeze_time(now):
        update_expiry.process_tenant(keystone, nova, tenant)
    expires = '2014-02-01'
    set_status.assert_called_with(keystone, tenant,
                                  'pending suspension', expires)
    set_nova_quota.assert_called_with(nova, tenant.id,
                                      ram=0, instances=0, cores=0)
    assert not suspend_tenant.called