-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Bug 1150009 - Add cleanup functions to the gaia UI tests that install we... #29834
Conversation
@@ -1055,6 +1054,15 @@ def is_element_displayed(self, by, locator): | |||
def tearDown(self): | |||
if self.device.is_desktop_b2g and self.device.storage_path: | |||
shutil.rmtree(self.device.storage_path, ignore_errors=True) | |||
if self.device.is_android_build: | |||
file_items = self.device.file_manager.list_items('/data/local/webapps/') | |||
dirs_to_keep = ['{14750155-5f3d-41ab-a527-f16adf4c3293}', 'marketplace-dev.allizom.org', 'marketplace.allizom.org', 'marketplace.firefox.com'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one issue here is that some builds put the system apps into /data/local/webapps
, so we'd still be deleting them. I really don't like the idea of hardcoding the directories to keep. Looking at /data/local/webapps/webapps.json
is appears that we could identify the apps to delete using "removable": true
. Could you try a patch that reads in that file, identifies the removable apps and deletes them from the filesystem using "basePath" and the main key? Also, I'd like to move this back into setUp so our cleanup is all in the same place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that "removable": true
also applies to the Mochitest and Marketplace apps, so I don't think we can use that. Perhaps there's something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like all bundled apps have the same installTime, so we could get the value from an expected app (such as the homescreen), and delete any app that has a greater value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for looking into it, I'll try the installTime trick for this, then.
break | ||
if delete_file and self.device.file_manager.dir_exists('/data/local/webapps/' + dir): | ||
self.device.file_manager.remove('/data/local/webapps/' + dir) | ||
print('deleting dir for: ' + dir + ':: ' + str(apps[app]['installTime'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to list the items in /data/local/webapps
as we should be able to extract that from the basePath
from the JSON file. I haven't tested it, but the following should work:
apps = json.loads(self.device.file_manager.pull_file('/data/local/webapps/webapps.json'))
system_install_time = apps['system.gaiamobile.org']['installTime']
for app in apps.values():
if app.get('installTime') > system_install_time:
# removing any webapps installed since build time
path = posixpath.join(app.get('basePath'), app.get('id')
self.logger.debug('Removing %s' % path)
self.device.file_manager.remove(path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that works. I was afraid this wouldn't catch webapps that wouldn't be listed in the webapps.json file, for some reason, but it seems that doesn't happen (I thought it did, at some point).
Bug 1150009 - Add cleanup functions to the gaia UI tests that install we...
...bapps, part 2