Skip to content

Commit

Permalink
Update Anaconda WebUI plugin to reflect changes made in anaconda repo
Browse files Browse the repository at this point in the history
  • Loading branch information
velezd committed Nov 27, 2023
1 parent a16ade1 commit bbf217d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
42 changes: 21 additions & 21 deletions libpermian/plugins/anaconda_webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def __init__(self, testRuns, crcList, setup_lock, vm_semaphore):
self.debug = self.settings.getboolean('AnacondaWebUI', 'debug')
self.test_timeout = self.settings.getint('AnacondaWebUI', 'test_timeout')

self.git_anaconda_repo = self.settings.get('AnacondaWebUI', 'anaconda_repo')
self.git_anaconda_branch = self.crc.configuration['branch']
self.git_webui_repo = self.settings.get('AnacondaWebUI', 'webui_repo')
self.git_webui_branch = self.crc.configuration['branch']
self.git_cockpit_repo = self.settings.get('AnacondaWebUI', 'cockpit_repo')
self.git_cockpit_branch = self.settings.get('AnacondaWebUI', 'cockpit_branch')
self.git_bots_repo = self.settings.get('AnacondaWebUI', 'bots_repo')
Expand Down Expand Up @@ -213,20 +213,19 @@ def setup(self):
self.container = ExecutionContainer(container_build_log)

# Add self to instances using this branch setup
if self.git_anaconda_branch in self.instances:
self.instances[self.git_anaconda_branch].append(self)
if self.git_webui_branch in self.instances:
self.instances[self.git_webui_branch].append(self)
else:
self.instances[self.git_anaconda_branch] = [self]
self.instances[self.git_webui_branch] = [self]

# Create temporary directory for this branch setup - if it doesn't exists
if self.git_anaconda_branch not in self.temp_dirs.keys():
self.temp_dirs[self.git_anaconda_branch] = tempfile.TemporaryDirectory(dir='/var/tmp/', prefix="pipeline_awebui_")
if self.git_webui_branch not in self.temp_dirs.keys():
self.temp_dirs[self.git_webui_branch] = tempfile.TemporaryDirectory(dir='/var/tmp/', prefix="pipeline_awebui_")
clone_common = True

self.temp_dir = self.temp_dirs[self.git_anaconda_branch].name
self.temp_dir = self.temp_dirs[self.git_webui_branch].name
os.chmod(self.temp_dir, 755)
self.anaconda_dir = os.path.join(self.temp_dir, 'anaconda')
self.webui_dir = os.path.join(self.anaconda_dir, 'ui/webui')
self.webui_dir = os.path.join(self.temp_dir, 'anaconda-webui')

if self.test_repo_name:
self._clone_test_repo()
Expand All @@ -240,7 +239,7 @@ def setup(self):
if self.installation_source is None:
self._set_boot_iso_path()

self.test_workdir = self.anaconda_dir # CWD where the test is going to run
self.test_workdir = self.webui_dir # CWD where the test is going to run
if self.test_repo_name:
self.test_workdir = self.test_repo_dir

Expand Down Expand Up @@ -305,6 +304,7 @@ def execute(self):

test_env = {'WEBUI_TEST_DIR': os.path.abspath(os.path.join(self.webui_dir, 'test'))}
test_env['TEST_AUDIT_NO_SELINUX'] = '1'
test_env['EXTENDED_LOGGING'] = '1'
test_output = self.crc.openLogfile('output.txt', 'w', True)

time.sleep(10) # Workaround, there is a race-condition, where WebUI is accessible but /run/anaconda/bus.address doesn't exist yet
Expand Down Expand Up @@ -387,11 +387,11 @@ def teardown(self):

with self.setup_lock:
# If this instance is the last one using temp dir -> remove it
self.instances[self.git_anaconda_branch].remove(self)
if len(self.instances[self.git_anaconda_branch]) == 0:
self.temp_dirs[self.git_anaconda_branch].cleanup()
self.instances[self.git_webui_branch].remove(self)
if len(self.instances[self.git_webui_branch]) == 0:
self.temp_dirs[self.git_webui_branch].cleanup()

del self.instances[self.git_anaconda_branch]
del self.instances[self.git_webui_branch]
# Remove container image, if this was the last anacoda-webui workflow
if not self.instances:
self.container.remove_image()
Expand Down Expand Up @@ -579,21 +579,21 @@ def _clone_test_repo(self):
self.test_repo_dir = os.path.join(self.temp_dir, self.test_repo_name)
if not os.path.isdir(self.test_repo_dir):
self.log(f'Clonning test repo {self.test_repo_url}')
self._clone_repo(self.test_repo_url, self.git_anaconda_branch, self.test_repo_dir)
self._clone_repo(self.test_repo_url, self.git_webui_branch, self.test_repo_dir)

def _clone_common(self):
""" Clones repositories common to all Anaconda WebUI tests """
self.log(f'Clonning common repositories')
bots_dir = os.path.join(self.webui_dir, 'bots')
cockpit_common_dir = os.path.join(self.anaconda_dir, 'ui/webui/test/common')
parsed_anaconda_url = urllib.parse.urlparse(self.git_anaconda_repo)
cockpit_common_dir = os.path.join(self.webui_dir, 'test/common')
parsed_webui_url = urllib.parse.urlparse(self.git_webui_repo)

if parsed_anaconda_url.scheme == 'file':
if parsed_webui_url.scheme == 'file':
# Create copy of anaconda repo
shutil.copytree(parsed_anaconda_url.path, self.anaconda_dir, symlinks=True, ignore_dangling_symlinks=True)
shutil.copytree(parsed_webui_url.path, self.webui_dir, symlinks=True, ignore_dangling_symlinks=True)
else:
# clone anaconda
self._clone_repo(self.git_anaconda_repo, self.git_anaconda_branch, self.anaconda_dir)
self._clone_repo(self.git_webui_repo, self.git_webui_branch, self.webui_dir)

if not os.path.exists(cockpit_common_dir):
with tempfile.TemporaryDirectory() as temp_dir:
Expand Down
10 changes: 5 additions & 5 deletions libpermian/plugins/anaconda_webui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
@api.cli.register_command_parser('run_awebui_tc')
def run_awebui_tc_command(base_parser, args):
parser = base_parser
parser.add_argument('path_to_anaconda',
help='Path to local Anaconda git repository where the test case is located')
parser.add_argument('path_to_webui',
help='Path to local Anaconda-webui git repository where the test case is located')
parser.add_argument('test_case_name',
help='Name of the test case as specified in tc.yaml')
source_group = parser.add_mutually_exclusive_group()
source_group.add_argument('--install-source',
default='https://fedorapeople.org/groups/anaconda/webui_permian_tests/sources/periodic/x86_64/',
help='URL of the installation source (compose os directory or unpack iso')
help='URL of the installation source (compose os directory or iso')
source_group.add_argument('--compose',
help='Compose ID of a compose that should be used as installation source')
parser.add_argument('--compose-url',
Expand Down Expand Up @@ -64,11 +64,11 @@ def run_awebui_tc_command(base_parser, args):

os.environ.setdefault(
"PIPELINE_library_directPath",
os.path.join(options.path_to_anaconda, 'ui/webui/test/end2end/'),
os.path.join(options.path_to_webui, 'test/test_cases/'),
)
os.environ.setdefault(
"PIPELINE_AnacondaWebUI_anaconda_repo",
'file://' + os.path.abspath(options.path_to_anaconda),
'file://' + os.path.abspath(options.path_to_webui),
)

return options, json.dumps(event)
2 changes: 1 addition & 1 deletion libpermian/plugins/anaconda_webui/settings.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[AnacondaWebUI]
# Anaconda repo, use file:// to copy local directory or anything else to clone git repo
anaconda_repo=https://github.com/rhinstaller/anaconda.git
webui_repo=https://github.com/rhinstaller/anaconda-webui.git
cockpit_repo=https://github.com/cockpit-project/cockpit.git
cockpit_branch=289
bots_repo=https://github.com/cockpit-project/bots.git
Expand Down

0 comments on commit bbf217d

Please sign in to comment.