def test_experiment_script_run(self): """Test running experiment script run.""" experiment.script_experiment( self.api, 123, 'run', experiment.site_association( 'grenoble', script=tests.resource_file('script.sh'), scriptconfig=tests.resource_file('scriptconfig')), experiment.site_association( 'strasbourg', script=tests.resource_file('script_2.sh')), ) scripts_json = helpers.json_dumps({ 'script': [ {'scriptname': 'script.sh', 'sites': ['grenoble']}, {'scriptname': 'script_2.sh', 'sites': ['strasbourg']}, ], 'scriptconfig': [ {'scriptconfigname': 'scriptconfig', 'sites': ['grenoble']}, ], }) expected_files = { 'script.json': scripts_json, 'script.sh': SCRIPTS['script.sh'], 'script_2.sh': SCRIPTS['script_2.sh'], 'scriptconfig': SCRIPTCONFIG['scriptconfig'], } self.api.script_command.assert_called_with(123, 'run', files=expected_files)
def test_experiment_script_run(self): """Test running experiment script run.""" experiment.script_experiment( self.api, 123, 'run', experiment.site_association( 'grenoble', script=tests.resource_file('script.sh'), scriptconfig=tests.resource_file('scriptconfig')), experiment.site_association( 'strasbourg', script=tests.resource_file('script_2.sh')), ) scripts_json = helpers.json_dumps({ 'script': [ {'scriptname': 'script.sh', 'sites': ['grenoble']}, {'scriptname': 'script_2.sh', 'sites': ['strasbourg']}, ], 'scriptconfig': [ {'scriptconfigname': 'scriptconfig', 'sites': ['grenoble']}, ], }) expected_files = { 'script.json': scripts_json, 'script.sh': SCRIPTS['script.sh'], 'script_2.sh': SCRIPTS['script_2.sh'], 'scriptconfig': SCRIPTCONFIG['scriptconfig'], } self.api.script_command.assert_called_with(123, 'run', files=expected_files)
def script_parser(opts): """Parse namespace 'opts' and execute requestes 'run' command.""" user, passwd = auth.get_user_credentials(opts.username, opts.password) api = rest.Api(user, passwd) exp_id = helpers.get_current_experiment(api, opts.experiment_id) command, options = _script_command_options(opts) return experiment.script_experiment(api, exp_id, command, *options)
def script_parser(opts): """Parse namespace 'opts' and execute requestes 'run' command.""" user, passwd = auth.get_user_credentials(opts.username, opts.password) api = rest.Api(user, passwd) exp_id = helpers.get_current_experiment(api, opts.experiment_id) command, options = _script_command_options(opts) return experiment.script_experiment(api, exp_id, command, *options)
def test_script_kill_status(self): """Test exp.script kill and status commands.""" # no sites experiment.script_experiment(self.api, 123, 'kill') self.api.script_command.assert_called_with(123, 'kill', json=[]) experiment.script_experiment(self.api, 123, 'status') self.api.script_command.assert_called_with(123, 'status', json=[]) # one site experiment.script_experiment(self.api, 123, 'kill', 'grenoble') self.api.script_command.assert_called_with(123, 'kill', json=['grenoble']) experiment.script_experiment(self.api, 123, 'status', 'grenoble') self.api.script_command.assert_called_with(123, 'status', json=['grenoble']) # multiple sites experiment.script_experiment(self.api, 123, 'kill', 'grenoble', 'strasbourg') self.api.script_command.assert_called_with( 123, 'kill', json=['grenoble', 'strasbourg']) experiment.script_experiment(self.api, 123, 'status', 'grenoble', 'strasbourg') self.api.script_command.assert_called_with( 123, 'status', json=['grenoble', 'strasbourg'])
def test_script_kill_status(self): """Test exp.script kill and status commands.""" # no sites experiment.script_experiment(self.api, 123, 'kill') self.api.script_command.assert_called_with(123, 'kill', json=[]) experiment.script_experiment(self.api, 123, 'status') self.api.script_command.assert_called_with(123, 'status', json=[]) # one site experiment.script_experiment(self.api, 123, 'kill', 'grenoble') self.api.script_command.assert_called_with(123, 'kill', json=['grenoble']) experiment.script_experiment(self.api, 123, 'status', 'grenoble') self.api.script_command.assert_called_with(123, 'status', json=['grenoble']) # multiple sites experiment.script_experiment(self.api, 123, 'kill', 'grenoble', 'strasbourg') self.api.script_command.assert_called_with( 123, 'kill', json=['grenoble', 'strasbourg']) experiment.script_experiment(self.api, 123, 'status', 'grenoble', 'strasbourg') self.api.script_command.assert_called_with( 123, 'status', json=['grenoble', 'strasbourg'])