Ejemplo n.º 1
0
    def test_cli_with_utils(self):
        """Test that the command line works with a simple simulation"""

        runner = CliRunner()
        runner.echo_stdin = True
        result = runner.invoke(cli.simulate, [
            "--sol-file", "tests/sols/basic.p", "--output-prefix", "clitest",
            "--output-dir", ".", "--workload-length", "3600", "--quantum",
            "3600", "--save-utils", "true"
        ])

        assert result.exit_code == 0

        files = glob.glob("clitest*")
        assert 'clitest.csv' in files
        assert 'clitest_out.txt' in files
        assert 'clitest_evs.csv' not in files
        assert 'clitest_reqs.csv' not in files
        assert 'clitest_utils.csv' in files

        df = pd.read_csv('clitest_utils.csv')
        assert len(df) == 3600

        util0_row = df.iloc[0]
        assert util0_row.vm_name == 'VM 0'
        assert util0_row.ic == 'priv'
        assert util0_row.util == 1

        last_util_row = df.iloc[-1]
        assert last_util_row.vm_name == 'VM 3599'
        assert last_util_row.ic == 'priv'
        assert last_util_row.util == 1
Ejemplo n.º 2
0
    def test_cli_with_evs(self):
        """Test that the command line works with a simple simulation"""

        runner = CliRunner()
        runner.echo_stdin = True
        result = runner.invoke(cli.simulate, [
            "--sol-file", "tests/sols/basic.p", "--output-prefix", "clitest",
            "--output-dir", ".", "--workload-length", "3600", "--quantum",
            "3600", "--save-evs", "true"
        ])

        assert result.exit_code == 0

        files = glob.glob("clitest*")
        assert 'clitest.csv' in files
        assert 'clitest_out.txt' in files
        assert 'clitest_reqs.csv' in files
        assert 'clitest_utils.csv' not in files

        df = pd.read_csv('clitest_reqs.csv')
        assert len(df) == 10800

        req1_row = df.iloc[1]
        assert req1_row.req == 1
        assert req1_row.creation == 0
        assert req1_row.start == 1200
        assert req1_row.end == 2400
        assert req1_row.app == 'a0'
        assert req1_row.vm == 'VM 0'
        assert req1_row.ic == 'priv'
        assert req1_row.lost == False
Ejemplo n.º 3
0
    def test_cli_yaml(self):
        """Test that the command line works with a YAML file"""

        runner = CliRunner()
        runner.echo_stdin = True
        result = runner.invoke(cli.simulate, [
            "--sol-file", "tests/sols/3vm.yaml", "--output-prefix", "clitest",
            "--output-dir", ".", "--quantum", "3600"
        ])

        assert result.exit_code == 0
Ejemplo n.º 4
0
    def test_list_repos(self):
        runner = CliRunner()
        runner.echo_stdin = True

        # create a repo and a component
        with runner.isolated_filesystem():
            result = runner.invoke(cli.create_repo,
                                   ["my_repo", "--gpgkey", "123456"])
            self.assertEqual(result.exit_code, 0)
            result = runner.invoke(cli.add_component, ["my_repo", "main"])
            self.assertEqual(result.exit_code, 0)

            # make sure list_repos is showing the correct output
            result = runner.invoke(cli.list_repos)
            self.assertEqual(result.exit_code, 0)
            self.assertEqual(result.output, LIST_REPOS_OUTPUT)
Ejemplo n.º 5
0
    def test_list_repos(self):
        runner = CliRunner()
        runner.echo_stdin = True

        # create a repo and a component
        with runner.isolated_filesystem():
            result = runner.invoke(
                cli.create_repo, ["my_repo", "--gpgkey", "123456"])
            self.assertEqual(result.exit_code, 0)
            result = runner.invoke(cli.add_component, ["my_repo", "main"])
            self.assertEqual(result.exit_code, 0)

            # make sure list_repos is showing the correct output
            result = runner.invoke(cli.list_repos)
            self.assertEqual(result.exit_code, 0)
            self.assertEqual(result.output, LIST_REPOS_OUTPUT)
Ejemplo n.º 6
0
    def test_cli_with_config_file(self):
        runner = CliRunner()
        runner.echo_stdin = True
        result = runner.invoke(cli.simulate, ["--config", "tests/config_test"])

        assert result.exit_code == 0