def test_allocation(self): """Test allocation input validation.""" api = allocation.API() good = {'environment': 'prod'} _ok(api.create, ['aaa-prod'], good) _ok(api.create, ['aaa:bbb-xxx'], good) _fail(api.create, ['aaa:bbb--xxx'], good) _fail(api.create, ['aaa:b-bb-xxx'], good) good.update({'features': ['xxx']}) _ok(api.create, ['aaa-prod'], good) good.update({ 'memory': '1G', 'cpu': '100%', 'disk': '1G', 'features': [] }) _ok(api.create, ['aaa-prod'], good) _ok(api.create, ['aaa-prod'], _patch(good, '/environment', 'qa')) _ok(api.create, ['aaa-prod'], _patch(good, '/environment', 'dev')) _ok(api.create, ['aaa-prod'], _patch(good, '/environment', 'uat')) _fail(api.create, ['aaa-prod'], _patch(good, '/environment', 'x')) # Update good = {'cpu': '77%'} _ok(api.update, ['aaa-prod'], good) good['memory'] = '2G' good['disk'] = '1G' good['features'] = ['ssd'] _ok(api.update, ['aaa-prod'], good) _fail(api.update, ['aaa-prod'], _patch(good, '/environment', 'qa'))
def test_allocation(self): """Test allocation input validation.""" api = allocation.API() good = {'environment': 'prod'} _ok(api.create, 'aaa/prod', good) _ok(api.create, 'aaa/prod', _patch(good, '/environment', 'qa')) _ok(api.create, 'aaa/prod', _patch(good, '/environment', 'dev')) _ok(api.create, 'aaa/prod', _patch(good, '/environment', 'uat')) _fail(api.create, 'aaa/prod', _patch(good, '/environment', 'x')) _fail(api.create, 'aaa/prod', _patch(good, '/environment', ' uat '))
def test_reservation(self): """Test allocation input validation.""" api = allocation.API().reservation good = { 'memory': '1G', 'cpu': '100%', 'disk': '1G', 'partition': 'xxx', } _ok(api.create, 'aaa/prod/cell', good) # Update good = {'cpu': '77%'} _fail(api.update, 'aaa/prod/cell', good) good['memory'] = '2G' good['disk'] = '1G' good['partition'] = 'yyy' _ok(api.update, 'aaa/prod/cell', good) _fail(api.update, 'aaa/prod/cell', _patch(good, '/environment', 'qa'))
def setUp(self): self.alloc = allocation.API()
def test_reservation_plugin_loading(self): """Test loading of plugins""" alloc_api = allocation.API(['test-plugin']) treadmill.api.allocation._api_plugins.assert_called_once_with( ['test-plugin'] )