def test_removal(self): family = ContainerFamily(id=42) expected_plan = {'ContainerFamilies': {family}} plan = family.build_removal_plan() self.assertEqual(expected_plan, strip_removal_plan(plan))
def test_removal(self): family = ContainerFamily(id=42) expected_plan = {'ContainerFamilies': {family}} plan = family.build_removal_plan() self.assertEqual(expected_plan, strip_removal_plan(plan))
def test_removal_with_app(self): family = ContainerFamily(id=42) container = family.containers.create(id=43) expected_plan = {'ContainerFamilies': {family}, 'Containers': {container}} plan = family.build_removal_plan() self.assertEqual(expected_plan, strip_removal_plan(plan))
def test_removal_with_app(self): family = ContainerFamily(id=42) container = family.containers.create(id=43) expected_plan = { 'ContainerFamilies': {family}, 'Containers': {container} } plan = family.build_removal_plan() self.assertEqual(expected_plan, strip_removal_plan(plan))
def test_str(self): family = ContainerFamily(name='Spline Reticulator') container = Container(tag='v1.0.7', family=family) s = str(container) self.assertEqual("Spline Reticulator:v1.0.7", s)
def test_display_default(self): app = ContainerApp(name='') # default app app.container = Container(tag='v1.0') app.container.family = ContainerFamily(name='Splines') expected_display_name = 'Splines:v1.0' display_name = app.display_name self.assertEqual(expected_display_name, display_name)
def test_display_name(self): app = ContainerApp(name='reticulate') app.container = Container(tag='v1.0') app.container.family = ContainerFamily(name='Splines') expected_display_name = 'Splines:v1.0 / reticulate' display_name = app.display_name app_str = str(app) self.assertEqual(expected_display_name, display_name) self.assertEqual(expected_display_name, app_str)
def __init__(self, data=None, user=None, *args, **kwargs): super(MethodForm, self).__init__(data, *args, **kwargs) # This is required to re-populate the drop-down with CRs created since first load. if user is not None: self.fields["coderesource"].choices = ( [('', '--- CodeResource ---')] + [(x.id, x.name) for x in CodeResource.filter_by_user(user).order_by('name')]) self.fields["containerfamily"].choices = ( [('', '--- Container Family ---')] + [(x.id, x.name) for x in ContainerFamily.filter_by_user(user)])
def __init__(self, data=None, user=None, *args, **kwargs): super(MethodForm, self).__init__(data, *args, **kwargs) # This is required to re-populate the drop-down with CRs created since first load. if user is not None: self.fields["coderesource"].choices = ( [('', '--- CodeResource ---')] + [(x.id, x.name) for x in CodeResource.filter_by_user(user).order_by('name')] ) self.fields["containerfamily"].choices = ( [('', '--- Container Family ---')] + [(x.id, x.name) for x in ContainerFamily.filter_by_user(user)])
def test_slurm_command_custom_memory(self): run = ContainerRun(pk=99) run.user = User(username='******') run.app = ContainerApp(threads=3, memory=100) run.app.container = Container() run.app.container.family = ContainerFamily(name='my container') run.sandbox_path = 'run23' expected_command = [ 'sbatch', '-J', 'r99 my container', '--parsable', '--output', '/tmp/kive_media/run23/logs/job%J_node%N_stdout.txt', '--error', '/tmp/kive_media/run23/logs/job%J_node%N_stderr.txt', '-c', '3', '--mem', '100', EXPECTED_MANAGE_PATH, 'runcontainer', '99' ] command = run.build_slurm_command() self.assertListEqual(expected_command, command)
def test_slurm_command_priority(self): run = ContainerRun(pk=99) run.user = User(username='******') run.app = ContainerApp() run.app.container = Container() run.app.container.family = ContainerFamily(name='my container') slurm_queues = (('low', 'kive-low'), ('medium', 'kive-medium'), ('high', 'kive-high')) run.priority = 2 run.sandbox_path = 'run23' expected_command = [ 'sbatch', '-J', 'r99 my container', '--parsable', '--output', '/tmp/kive_media/run23/logs/job%J_node%N_stdout.txt', '--error', '/tmp/kive_media/run23/logs/job%J_node%N_stderr.txt', '-c', '1', '--mem', '6000', '-p', 'kive-high', EXPECTED_MANAGE_PATH, 'runcontainer', '99' ] command = run.build_slurm_command(slurm_queues) self.assertListEqual(expected_command, command)