Exemple #1
0
    def test_exceptions(self):
        with pytest.raises(CommandError) as e:
            run("""
                echo "test1"
                echo "throws error" && missing_command
                echo "test2"
                """)

        assert "missing_command: command not found" in str(e.value)
Exemple #2
0
    def __init__(self) -> None:
        self.stage = "local"
        self.emoji = "🐣"
        super().__init__()

        self.photos = HmletEnv.Photos(address="hmlet.photos.local")
        self.minio = HmletEnv.Minio(address="hmlet.minio.local")

        self.aux = AuxEnv(
        )  # Auxiliary cluster's registry is used for caching and CI images

        self.registry = HmletEnv.Registry(address="hmlet.registry.local",
                                          username="******",
                                          password="******")

        try:
            # TODO: Add timeout to this
            result = run(f"""kubectl describe nodes {self.device.name}""")
            ip_phrase = re.search(r"InternalIP: .*",
                                  "\n".join(result)).group(0)
            ip = ip_phrase.split(":")[1].strip()

            self.device.ip = ip
            self.registry.ip = ip

        except CommandError:
            self.device.ip = ""
            self.registry.ip = ""
Exemple #3
0
    def __init__(self) -> None:
        self.stage = "local"
        self.emoji = "🐣"
        super().__init__()

        self.keycloak = CitygrovesEnv.Keycloak(
            address="citygroves.keycloak.local")
        self.backend = CitygrovesEnv.Backend(
            address="citygroves.backend.local")
        self.frontend = CitygrovesEnv.Frontend(
            address="citygroves.frontend.local")
        self.appgen = CitygrovesEnv.Appgen(address="citygroves.appgen.local")

        self.aux = AuxEnv()

        self.registry = CitygrovesEnv.Registry(
            address="citygroves.registry.local",
            username="******",
            password="******")

        try:
            # TODO: Add timeout to this
            result = run(f"""kubectl describe nodes {self.device.name}""")
            ip_phrase = re.search(r"InternalIP: .*",
                                  "\n".join(result)).group(0)
            ip = ip_phrase.split(":")[1].strip()

            self.device.ip = ip
            self.registry.ip = ip

        except CommandError:
            self.device.ip = ""
Exemple #4
0
 def test_multine_command(self):
     result = run(""" 
             export VAR1=123
             echo "test \\ 
             blabla"
             echo "test\\
              $VAR1"
             """)
     assert len(result) == 2
     assert result[0] == 'test blabla'
     assert result[1] == 'test123'
Exemple #5
0
    def test_run_multiple_results(self, capsys):
        result = run("""
        export VAR1=123
        echo "test"
        echo "test$VAR1"
        """)
        assert len(result) == 2
        assert result[0] == 'test'
        assert result[1] == 'test123'

        assert capsys.readouterr().out == ""
Exemple #6
0
def test_shell(env):
    run("./shell.py --dry-run")
Exemple #7
0
 def test_ignore_errors(self):
     result = run("""non_existend_command""", ignore_errors=True)
     assert len(result) == 1
     assert "non_existend_command: command not found" in result[0]
Exemple #8
0
 def test_run_simple_echo_print(self, capsys):
     result = run('echo "test"', print_output=True)
     assert capsys.readouterr().out == "test\r\n"
     assert result[0] == 'test'
Exemple #9
0
 def test_run_simple_echo(self, capsys):
     result = run('echo "test"')
     assert len(result) == 1
     assert result[0] == 'test'
     assert capsys.readouterr().out == ""