Skip to content

Commit

Permalink
Fix teardown
Browse files Browse the repository at this point in the history
It was not working because I was using params from the wrong object.
Needs to be on the metal.
  • Loading branch information
Callisto13 committed Nov 11, 2021
1 parent 99c3956 commit 63e8bf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
20 changes: 10 additions & 10 deletions test/tools/metal.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ def run_ssh_command(self, cmd, cwd, allow_error=True):
raise result.to_error()
self.logger.info("command exited with code %d", result.return_code)

def delete_all(self, project, device, key):
if device != None:
device.delete()
self.logger.info(f"deleted device {device.hostname}")
def delete_all(self):
if self.device is not None:
self.device.delete()
self.logger.info(f"deleted device {self.device.hostname}")

if key != None:
key.delete()
if self.key is not None:
self.key.delete()
os.remove(self.private_key_path)
os.remove(self.public_key_path)
self.logger.info(f"deleted key {key.label}")
self.logger.info(f"deleted key {self.key.label}")

if project != None:
project.delete()
self.logger.info(f"deleted project {project.name}")
if self.project is not None:
self.project.delete()
self.logger.info(f"deleted project {self.project.name}")

def new_shell(self, ip):
shell = spur.SshShell(
Expand Down
12 changes: 5 additions & 7 deletions test/tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ def __init__(self, auth_token, config):
self.skip_teardown = self.testCfg['skip_teardown']
self.dev_id = devCfg['id']
self.dev_ip = None
self.project = None
self.key = None
self.device = None

def __enter__(self):
return self

def __exit__(self, *args, **kwargs):
if self.skip_teardown == False:
self.teardown()
self.teardown()

def setup(self):
if self.dev_id != None:
if self.dev_id is not None:
self.fetch_infra()
else:
self.create_infra()
Expand All @@ -46,7 +42,9 @@ def run_tests(self):
pass

def teardown(self):
self.welder.delete_all(self.project, self.device, self.key)
if self.skip_teardown:
return
self.welder.delete_all()

def create_infra(self):
self.dev_ip = self.welder.create_all()
Expand Down

0 comments on commit 63e8bf5

Please sign in to comment.