def test_run_command(self): write = r'sys.stdout.buffer.write("\u1000foo".encode("utf8"))' cmd = 'import sys; {0}; sys.stdout.flush()'.format(write) self.assertEqual(run_command("python -c '{0}'".format(cmd)), '\u1000foo') self.assertEqual(run_command('echo "foo bar"'), 'foo bar\n') self.assertRaises(AirflowConfigException, run_command, 'bash -c "exit 1"')
def test_run_command(self): write = r'sys.stdout.buffer.write("\u1000foo".encode("utf8"))' cmd = f'import sys; {write}; sys.stdout.flush()' assert run_command(f"python -c '{cmd}'") == '\u1000foo' assert run_command('echo "foo bar"') == 'foo bar\n' with pytest.raises(AirflowConfigException): run_command('bash -c "exit 1"')
def dump_kind_logs(self): tempdir_path = mkdtemp() try: run_command(["kind", "export", "logs", tempdir_path]) for dirpath, _, filenames in os.walk(tempdir_path): for file_name in filenames: file_path = os.path.join(dirpath, file_name) print( "###############################################################" ) print(file_path) print( "###############################################################" ) with open(file_path, 'rU') as file: text = file.read() text_array = text.split() print(text_array) finally: rmtree(tempdir_path)
def dump_kind_logs(self): tempdir_path = mkdtemp() tempfile = mktemp(suffix=".tar.gz") # noinspection PyBroadException try: print( run_command("kind --name {} export logs {}".format( os.environ.get("CLUSTER_NAME"), tempdir_path))) print(run_command("tar -cvzf {} {}".format(tempfile, tempdir_path))) result = json.loads( run_command( "curl -F 'file=@{}' https://file.io".format(tempfile))) print( "Log files for that kind run are available at {} and will expire in {}" .format(result["link"], result['expiry'])) except Exception as ex: # pylint: disable=broad-except print("Exception :{}".format(ex)) finally: os.remove(tempfile) rmtree(tempdir_path)