diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-08-28 13:24:15 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-13 15:50:48 +0200 |
commit | d42dbb96cbcefb6f631fc9ddb52ec8755e26f19e (patch) | |
tree | 28b33a5ef3cf44fae7a99a200d95640c31c4692d /tests/plugins | |
parent | c7697d5366690c86f4a772c74fc621ee5d7b3edb (diff) | |
download | sonarqube-d42dbb96cbcefb6f631fc9ddb52ec8755e26f19e.tar.gz sonarqube-d42dbb96cbcefb6f631fc9ddb52ec8755e26f19e.zip |
SONAR-9739 improve integration tests of api/system/status
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/server-plugin/src/main/java/ServerPlugin.java | 2 | ||||
-rw-r--r-- | tests/plugins/server-plugin/src/main/java/ServerStartupLock.java | 61 |
2 files changed, 62 insertions, 1 deletions
diff --git a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java index 9ab0dd987de..c7f4c560a25 100644 --- a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java +++ b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java @@ -88,6 +88,6 @@ import static org.sonar.api.PropertyType.USER_LOGIN; public class ServerPlugin extends SonarPlugin { public List getExtensions() { return Arrays.asList( - StartupCrash.class, TempFolderExtension.class, PauseMetric.class, CePauseStep.class); + StartupCrash.class, ServerStartupLock.class, TempFolderExtension.class, PauseMetric.class, CePauseStep.class); } } diff --git a/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java b/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java new file mode 100644 index 00000000000..85aaef2213d --- /dev/null +++ b/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import java.io.File; +import java.util.Optional; +import org.sonar.api.Startable; +import org.sonar.api.config.Configuration; +import org.sonar.api.server.ServerSide; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; + +@ServerSide +public class ServerStartupLock implements Startable { + + private final Configuration configuration; + private static final Logger LOGGER = Loggers.get(ServerStartupLock.class); + + public ServerStartupLock(Configuration configuration) { + this.configuration = configuration; + } + + @Override + public void start() { + Optional<String> path = configuration.get("sonar.test.serverStartupLock.path"); + if (path.isPresent()) { + File lock = new File(path.get()); + try { + while (lock.exists()) { + LOGGER.info("ServerStartupLock - Waiting for file to be deleted: " + lock.getAbsolutePath()); + Thread.sleep(100L); + } + LOGGER.info("ServerStartupLock - File deleted. Resuming startup."); + } catch (InterruptedException e) { + LOGGER.info("ServerStartupLock - interrupted"); + Thread.currentThread().interrupt(); + } + } + } + + @Override + public void stop() { + // nothing to do + } +} |