Commit 12a61739 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Heptapod: generic implementaion for apply_hashed_storage_setting

It will work for any subclass that implements `gitlab_ctl` and
`rake` (currently corresponding to the `@needs.services` generator),
hence for `GdkHeptapod` as well as `DockerHeptapod`.

This implementation is tighter in that we make sure that Redis,
where the annoying cache should reside, is stopped before
restarting everything. The restart of Rails dominates execution
time anyway.

Of course, at some point we could find a gentler way to force
the previous setting out of the caches, but at least we can now
run hashed storage related tests in GDK context.

We don't need `restart_rails()` anymore, a more controlled style
is wishable anyway.
parent a88a65e5c368
......@@ -269,11 +269,6 @@ class Heptapod:
logger.info("All preparations done in %.2f seconds. "
"Proceeding with tests.", time.time() - start)
def restart_rails(self):
logger.info("Restarting the Rails application.")
self.gitlab_ctl('restart', services=self.RAILS_SERVICES)
self.wait_startup()
def set_application_settings(self, **settings):
"""Change GitLab application settings and update :attr:`settings`."""
resp = requests.put(
......@@ -390,6 +385,27 @@ class Heptapod:
self.prepare(self.users['root']['password'])
raise
def apply_hashed_storage_setting(self, hashed_storage):
# TODO it would be tempting not to restart if the setting is already
# at the wished value, but this currently cannot take into account
# rollbacked values that aren't followed by a restart. This will
# be more complicated and take more time than we can afford right now
# to really make work.
self.set_application_settings(hashed_storage_enabled=hashed_storage)
# let's be sure that redis is restarted when the Rails services
# start
self.gitlab_ctl('stop', self.RAILS_SERVICES)
self.gitlab_ctl('stop', ['redis'])
# we restart everything in case a service would depend on Redis
# and would fail to reconnect automatically
self.gitlab_ctl('restart')
self.wait_startup()
# recheck that the setting is applied
self.sync_application_settings()
assert self.settings['hashed_storage_enabled'] is hashed_storage
class DockerHeptapod(Heptapod):
......@@ -481,18 +497,6 @@ class DockerHeptapod(Heptapod):
for service in services:
self.run_shell(base_cmd + (service, ))
def apply_hashed_storage_setting(self, hashed_storage):
# TODO it would be tempting not to restart if the setting is already
# at the wished value, but this currently cannot take into account
# rollbacked values that aren't followed by a restart. This will
# be more complicated and take more time than we can afford right now
# to really make work.
self.set_application_settings(hashed_storage_enabled=hashed_storage)
self.restart_rails()
# recheck that the setting is applied
self.sync_application_settings()
assert self.settings['hashed_storage_enabled'] is hashed_storage
class SourceHeptapod(Heptapod):
"""An Heptapod server installed from source on the same system.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment