Some refactoring

This commit is contained in:
GeorgianaElena
2020-02-20 13:31:17 +02:00
parent 36f79340ec
commit b51467dcd3
2 changed files with 22 additions and 17 deletions

View File

@@ -15,7 +15,7 @@ def build_systemd_image(image_name, source_path):
])
def run_systemd_image(image_name, container_name, branch_path):
def run_systemd_image(image_name, container_name, bootstrap_pip_spec):
"""
Run docker image with systemd
@@ -35,9 +35,9 @@ def run_systemd_image(image_name, container_name, branch_path):
'--memory', '1G',
]
if branch_path:
if bootstrap_pip_spec:
cmd.append('-e')
cmd.append(f'TLJH_BOOTSTRAP_PIP_SPEC={branch_path}')
cmd.append(f'TLJH_BOOTSTRAP_PIP_SPEC={bootstrap_pip_spec}')
cmd.append(image_name)
@@ -81,12 +81,12 @@ def copy_to_container(container_name, src_path, dest_path):
])
def run_test(image_name, test_name, branch_path, test_files, upgrade, installer_args):
def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, installer_args):
"""
Wrapper that sets up tljh with installer_args & runs test_name
"""
stop_container(test_name)
run_systemd_image(image_name, test_name, branch_path)
run_systemd_image(image_name, test_name, bootstrap_pip_spec)
source_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir)
@@ -159,7 +159,7 @@ def main():
run_test_parser.add_argument('--installer-args', default='')
run_test_parser.add_argument('--upgrade', action='store_true')
run_test_parser.add_argument('test_name')
run_test_parser.add_argument('branch_path')
run_test_parser.add_argument('bootstrap_pip_spec')
run_test_parser.add_argument('test_files', nargs='+')
show_logs_parser = subparsers.add_parser('show-logs')
@@ -170,7 +170,7 @@ def main():
image_name = 'tljh-systemd'
if args.action == 'run-test':
run_test(image_name, args.test_name, args.branch_path, args.test_files, args.upgrade, args.installer_args)
run_test(image_name, args.test_name, args.bootstrap_pip_spec, args.test_files, args.upgrade, args.installer_args)
elif args.action == 'show-logs':
show_logs(args.container_name)
elif args.action == 'run':
@@ -178,7 +178,7 @@ def main():
elif args.action == 'copy':
copy_to_container(args.container_name, args.src, args.dest)
elif args.action == 'start-container':
run_systemd_image(image_name, args.container_name, args.branch_path)
run_systemd_image(image_name, args.container_name, args.bootstrap_pip_spec)
elif args.action == 'stop-container':
stop_container(args.container_name)
elif args.action == 'build-image':