def test_simple_deploy(): with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() commands.build() commands.deploy() commands.undeploy()
def test_add_remove_config(): """ Tests adding a new config, and then lists the configs to ensure that the new config is listed. Remove the config and then lists the configs to ensure that the config has been removed. """ with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() # list the configs original_configs, _ = commands.config(subcommand="list") # add a new config named `foo` new_config = "foo" new_value = "bar" commands.config(subcommand="set", config_name=new_config, config_value=new_value) # list the configs again to ensure that the new config is added. updated_configs, _ = commands.config(subcommand="list") assert updated_configs != original_configs p = re.compile("{}[\s]+{}".format(new_config, new_value)) assert p.search(str(updated_configs)) # remove the config and then ensure that the config has been removed. commands.config(subcommand="remove", config_name=new_config) updated_configs, _ = commands.config(subcommand="list") p = re.compile("{}[\s]+{}".format(new_config, new_value)) assert not p.search(str(updated_configs))
def test_deploying_templates(template): with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init(template) commands.build() commands.deploy() commands.undeploy()
def test_watch_build_and_deploy_no_push(): with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() commands.build(watch=True) commands.deploy() commands.deploy(no_push=True) commands.undeploy()
def test_config_list(): """ Tests listing configs in an init directory """ with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() commands.config(subcommand="list")
def test_interactive_deploy(): with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() commands.build() try: commands.deploy(interactive=True) commands.status() finally: commands.undeploy() commands.status()
def test_no_push_deploy(): with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() commands.build() try: commands.deploy() commands.status() commands.deploy(no_push=True) commands.status() finally: commands.undeploy() commands.status()
def test_local_templates(): """ Tests creating a new template in a clone of mlt. Verifies that we can specify the template-repo for mlt template list and see the new template in the list. Then uses mlt init to create an app with our new template and verifies that the app directory exists. """ # Create a git clone of mlt to use as a local template diretory with git_helpers.clone_repo(project.basedir()) as temp_clone: # Add a new test template to the local mlt template directory templates_directory = os.path.join(temp_clone, constants.TEMPLATES_DIR) new_template_name = "test-local" new_template_directory = os.path.join(templates_directory, new_template_name) os.mkdir(new_template_directory) new_template_file = os.path.join(new_template_directory, "README.md") with open(new_template_file, "w") as f: f.write("New local template for testing") # call mlt template list and then check the output output = call_template_list(temp_clone) # template list should include our new test-local template desired_template_output = """Template Description ------------------- -------------------------------------------------------------------------------------------------- hello-world A TensorFlow python HelloWorld example run through Kubernetes Jobs. pytorch Sample distributed application taken from http://pytorch.org/tutorials/intermediate/dist_tuto.html pytorch-distributed A distributed PyTorch MNIST example run using the pytorch-operator. test-local New local template for testing tf-dist-mnist A distributed TensorFlow MNIST model which designates worker 0 as the chief. tf-distributed A distributed TensorFlow matrix multiplication run through the TensorFlow Kubernetes Operator. """ assert output == desired_template_output # init an app with this new template and verify that the app exists with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init(template=new_template_name, template_repo=temp_clone) app_directory = os.path.join(workdir, commands.app_name) assert os.path.isdir(app_directory) assert os.path.isfile(os.path.join(app_directory, "README.md"))
def test_update_config(): """ Tests the `name` config and then checks the config list to ensure that the new `name` is listed. """ with create_work_dir() as workdir: commands = CommandTester(workdir) commands.init() # list the configs original_configs, _ = commands.config(subcommand="list") # set the `name` config to `foo` new_name = "foo" commands.config(subcommand="set", config_name="name", config_value=new_name) # list the configs again and compare to ensure the `name` was updated. updated_configs, _ = commands.config(subcommand="list") assert updated_configs != original_configs p = re.compile("name[\s]+{}".format(new_name)) assert p.search(str(updated_configs))