]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10690 make fake-governance-plugin a core extension
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 7 Jun 2018 14:50:08 +0000 (16:50 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 12 Jun 2018 18:21:04 +0000 (20:21 +0200)
94 files changed:
run-integration-tests.sh
settings.gradle
tests/build.gradle
tests/plugins/core-extension-it-tests/build.gradle [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ItTestsCoreExtension.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/BombConfig.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/IseTaskProcessor.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/OOMGenerator.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/OkTaskProcessor.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/OomTaskProcessor.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/ws/BombActivatorAction.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGoVWsAction.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGovWs.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/ce/ws/SubmitAction.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/systemPasscode/SystemPasscodeWebService.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/workerCount/FakeWorkerCountProviderImpl.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/workerCount/RefreshWorkerCountAction.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/java/workerlatch/WorkerLatchMetrics.java [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension [new file with mode: 0644]
tests/plugins/core-extension-it-tests/src/main/resources/org/sonar/l10n/billing.properties [new file with mode: 0644]
tests/plugins/fake-governance-plugin/build.gradle [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/BombConfig.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/IseTaskProcessor.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/OOMGenerator.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/OkTaskProcessor.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/OomTaskProcessor.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/ws/BombActivatorAction.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGoVWsAction.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGovWs.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/ce/ws/SubmitAction.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/systemPasscode/SystemPasscodeWebService.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/workerCount/FakeWorkerCountProviderImpl.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/workerCount/RefreshWorkerCountAction.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/java/workerlatch/WorkerLatchMetrics.java [deleted file]
tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties [deleted file]
tests/src/test/java/org/sonarqube/tests/Byteman.java
tests/src/test/java/org/sonarqube/tests/Category1Suite.java
tests/src/test/java/org/sonarqube/tests/Category3Suite.java
tests/src/test/java/org/sonarqube/tests/Category4Suite.java
tests/src/test/java/org/sonarqube/tests/Category6Suite.java
tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/authorization/AuthorizationSuite.java
tests/src/test/java/org/sonarqube/tests/authorization/SystemPasscodeTest.java
tests/src/test/java/org/sonarqube/tests/ce/CeShutdownTest.java
tests/src/test/java/org/sonarqube/tests/ce/CeWorkersTest.java
tests/src/test/java/org/sonarqube/tests/component/ComponentSuite.java
tests/src/test/java/org/sonarqube/tests/duplication/DuplicationSuite.java
tests/src/test/java/org/sonarqube/tests/issue/ExternalIssueSuite.java
tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDatePluginChangedTest.java
tests/src/test/java/org/sonarqube/tests/issue/IssueSuite.java
tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueSuite.java
tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java
tests/src/test/java/org/sonarqube/tests/marketplace/UpdateCenterTest.java
tests/src/test/java/org/sonarqube/tests/measure/MeasureSuite.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java
tests/src/test/java/org/sonarqube/tests/performance/scanner/ScannerPerformanceSuite.java
tests/src/test/java/org/sonarqube/tests/performance/server/ComputeEnginePerfTest.java
tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java
tests/src/test/java/org/sonarqube/tests/project/OrganizationProjectSuite.java
tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java
tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateSuite.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateSuite.java
tests/src/test/java/org/sonarqube/tests/qualityModel/QualityModelSuite.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfileUpdateTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleReKeyingTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/BlueGreenTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/RestartTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/ServerSystemRestartingOrchestrator.java
tests/src/test/java/org/sonarqube/tests/serverSystem/SystemStateTest.java
tests/src/test/java/org/sonarqube/tests/settings/SettingsSuite.java
tests/src/test/java/org/sonarqube/tests/settings/SettingsTestRestartingOrchestrator.java
tests/src/test/java/org/sonarqube/tests/source/SourceSuite.java
tests/src/test/java/org/sonarqube/tests/startup/StartupIndexationTest.java
tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryOptOutTest.java
tests/src/test/java/org/sonarqube/tests/telemetry/TelemetryUploadTest.java
tests/src/test/java/org/sonarqube/tests/test/TestSuite.java
tests/src/test/java/org/sonarqube/tests/ui/UiSuite.java
tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java
tests/src/test/java/org/sonarqube/tests/user/HttpHeadersAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/OnboardingTest.java
tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java
tests/src/test/java/org/sonarqube/tests/user/SonarCloudUserSuite.java
tests/src/test/java/org/sonarqube/tests/user/UserEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/user/UserSuite.java
tests/src/test/java/org/sonarqube/tests/webhook/WebhooksSuite.java
tests/src/test/java/util/ItUtils.java

index 476782962c4ee80a98681b31430a60bc84c84d48..938cd9bd6f7410eb3786bec7cc31f74b4b3d719a 100755 (executable)
@@ -16,7 +16,8 @@ CATEGORY=$1
 ORCHESTRATOR_CONFIG_URL=$2
 shift 2
 
-./gradlew --no-daemon --console plain \
+./gradlew  \
+  :tests:clean \
   :tests:integrationTest \
   -Dcategory="$CATEGORY" \
   -Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL  \
index d15f0d6f31c77868927664e2a968d592e5c1e4ec..10d2f7309416ecb51235ca74c734fa933ead9536 100644 (file)
@@ -41,7 +41,7 @@ include 'tests:plugins:blue-green-plugin-v1'
 include 'tests:plugins:blue-green-plugin-v2'
 include 'tests:plugins:extension-lifecycle-plugin'
 include 'tests:plugins:fake-billing-plugin'
-include 'tests:plugins:fake-governance-plugin'
+include 'tests:plugins:core-extension-it-tests'
 include 'tests:plugins:foo-plugin-v1'
 include 'tests:plugins:foo-plugin-v2'
 include 'tests:plugins:foo-plugin-v3'
index 3b357654511f6c728abc53aca82c87b78d07c7a9..da55a4f03cf0438dc5b9319427d8a5395aba6cee 100644 (file)
@@ -20,7 +20,7 @@ def pluginsForITs = [
     ':tests:plugins:blue-green-plugin-v2',
     ':tests:plugins:extension-lifecycle-plugin',
     ':tests:plugins:fake-billing-plugin',
-    ':tests:plugins:fake-governance-plugin',
+    ':tests:plugins:core-extension-it-tests',
     ':tests:plugins:foo-plugin-v1',
     ':tests:plugins:foo-plugin-v2',
     ':tests:plugins:foo-plugin-v3',
diff --git a/tests/plugins/core-extension-it-tests/build.gradle b/tests/plugins/core-extension-it-tests/build.gradle
new file mode 100644 (file)
index 0000000..3dc8a90
--- /dev/null
@@ -0,0 +1,4 @@
+dependencies {
+  compileOnly project(path: ':sonar-plugin-api', configuration: 'shadow')
+  compileOnly project(':server:sonar-server')
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ItTestsCoreExtension.java b/tests/plugins/core-extension-it-tests/src/main/java/ItTestsCoreExtension.java
new file mode 100644 (file)
index 0000000..f38bf27
--- /dev/null
@@ -0,0 +1,73 @@
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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 ce.BombConfig;
+import ce.ComponentBombReportAnalysisComponentProvider;
+import ce.IseTaskProcessor;
+import ce.OkTaskProcessor;
+import ce.OomTaskProcessor;
+import ce.ws.BombActivatorAction;
+import ce.ws.FakeGovWs;
+import ce.ws.SubmitAction;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.core.extension.CoreExtension;
+import systemPasscode.SystemPasscodeWebService;
+import workerCount.FakeWorkerCountProviderImpl;
+import workerCount.RefreshWorkerCountAction;
+import workerlatch.LatchControllerWorkerMeasureComputer;
+import workerlatch.WorkerLatchMetrics;
+
+import static org.sonar.api.SonarQubeSide.COMPUTE_ENGINE;
+import static org.sonar.api.SonarQubeSide.SERVER;
+
+public class ItTestsCoreExtension implements CoreExtension {
+  @Override
+  public String getName() {
+    return "it-tests";
+  }
+
+  @Override
+  public void load(Context context) {
+    // Nothing should be loaded when the plugin is running within by the scanner
+    SonarQubeSide sonarQubeSide = context.getRuntime().getSonarQubeSide();
+    if (sonarQubeSide == COMPUTE_ENGINE || sonarQubeSide == SERVER) {
+      context.addExtension(FakeWorkerCountProviderImpl.class);
+      context.addExtension(WorkerLatchMetrics.class);
+      context.addExtension(LatchControllerWorkerMeasureComputer.class);
+      context.addExtension(RefreshWorkerCountAction.class);
+      context.addExtension(SystemPasscodeWebService.class);
+
+      // WS api/fake_gov
+      context.addExtension(FakeGovWs.class);
+
+      // failing CE tasks
+      context.addExtension(SubmitAction.class);
+      context.addExtension(OomTaskProcessor.class);
+      context.addExtension(IseTaskProcessor.class);
+      context.addExtension(OkTaskProcessor.class);
+
+      // component bombs injection into the Report Analysis processing container in the CE
+      context.addExtension(BombConfig.class);
+      context.addExtension(ComponentBombReportAnalysisComponentProvider.class);
+      context.addExtension(BombActivatorAction.class);
+    }
+  }
+
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/BombConfig.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/BombConfig.java
new file mode 100644 (file)
index 0000000..d6fdd5d
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.server.ServerSide;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+
+@ServerSide
+@ComputeEngineSide
+public class BombConfig {
+  private static final String OOM_START_BOMB_KEY = "oomStartBomb";
+  private static final String ISE_START_BOMB_KEY = "iseStartBomb";
+  private static final String OOM_STOP_BOMB_KEY = "oomStopBomb";
+  private static final String ISE_STOP_BOMB_KEY = "iseStopBomb";
+
+  private final DbClient dbClient;
+
+  public BombConfig(DbClient dbClient) {
+    this.dbClient = dbClient;
+  }
+
+  public void reset() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.internalPropertiesDao().save(dbSession, OOM_START_BOMB_KEY, String.valueOf(false));
+      dbClient.internalPropertiesDao().save(dbSession, ISE_START_BOMB_KEY, String.valueOf(false));
+      dbClient.internalPropertiesDao().save(dbSession, OOM_STOP_BOMB_KEY, String.valueOf(false));
+      dbClient.internalPropertiesDao().save(dbSession, ISE_STOP_BOMB_KEY, String.valueOf(false));
+      dbSession.commit();
+    }
+  }
+
+  public boolean isOomStartBomb() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      return dbClient.internalPropertiesDao().selectByKey(dbSession, OOM_START_BOMB_KEY).map(Boolean::valueOf).orElse(false);
+    }
+  }
+
+  public void setOomStartBomb(boolean oomStartBomb) {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.internalPropertiesDao().save(dbSession, OOM_START_BOMB_KEY, String.valueOf(oomStartBomb));
+      dbSession.commit();
+    }
+  }
+
+  public boolean isIseStartBomb() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      return dbClient.internalPropertiesDao().selectByKey(dbSession, ISE_START_BOMB_KEY).map(Boolean::valueOf).orElse(false);
+    }
+  }
+
+  public void setIseStartBomb(boolean iseStartBomb) {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.internalPropertiesDao().save(dbSession, ISE_START_BOMB_KEY, String.valueOf(iseStartBomb));
+      dbSession.commit();
+    }
+  }
+
+  public boolean isOomStopBomb() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      return dbClient.internalPropertiesDao().selectByKey(dbSession, OOM_STOP_BOMB_KEY).map(Boolean::valueOf).orElse(false);
+    }
+  }
+
+  public void setOomStopBomb(boolean oomStopBomb) {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.internalPropertiesDao().save(dbSession, OOM_STOP_BOMB_KEY, String.valueOf(oomStopBomb));
+      dbSession.commit();
+    }
+  }
+
+  public boolean isIseStopBomb() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      return dbClient.internalPropertiesDao().selectByKey(dbSession, ISE_STOP_BOMB_KEY).map(Boolean::valueOf).orElse(false);
+    }
+  }
+
+  public void setIseStopBomb(boolean iseStopBomb) {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.internalPropertiesDao().save(dbSession, ISE_STOP_BOMB_KEY, String.valueOf(iseStopBomb));
+      dbSession.commit();
+    }
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java
new file mode 100644 (file)
index 0000000..2b2ea4e
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import java.util.List;
+import org.picocontainer.Startable;
+import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
+import org.sonar.server.computation.task.container.EagerStart;
+
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
+
+public class ComponentBombReportAnalysisComponentProvider implements ReportAnalysisComponentProvider {
+  private final BombConfig bombConfig;
+
+  public ComponentBombReportAnalysisComponentProvider(BombConfig bombConfig) {
+    this.bombConfig = bombConfig;
+  }
+
+  @Override
+  public List<Object> getComponents() {
+    if (bombConfig.isOomStartBomb()) {
+      return singletonList(OOMFailingStartComponent.class);
+    }
+    if (bombConfig.isIseStartBomb()) {
+      return singletonList(ISEFailingStartComponent.class);
+    }
+    if (bombConfig.isOomStopBomb()) {
+      return singletonList(OOMFailingStopComponent.class);
+    }
+    if (bombConfig.isIseStopBomb()) {
+      return singletonList(ISEFailingStopComponent.class);
+    }
+    return emptyList();
+  }
+
+  @EagerStart
+  public static final class OOMFailingStartComponent implements Startable {
+
+    @Override
+    public void start() {
+      OOMGenerator.consumeAvailableMemory();
+    }
+
+    @Override
+    public void stop() {
+      // nothing to do
+    }
+  }
+
+  @EagerStart
+  public static final class ISEFailingStartComponent implements Startable {
+
+    @Override
+    public void start() {
+      throw new IllegalStateException("Faking an IllegalStateException thrown by a startable component in the Analysis Report processing container");
+    }
+
+    @Override
+    public void stop() {
+      // nothing to do
+    }
+  }
+
+  @EagerStart
+  public static final class OOMFailingStopComponent implements Startable {
+
+    @Override
+    public void start() {
+      // nothing to do
+    }
+
+    @Override
+    public void stop() {
+      OOMGenerator.consumeAvailableMemory();
+    }
+  }
+
+  @EagerStart
+  public static final class ISEFailingStopComponent implements Startable {
+
+    @Override
+    public void start() {
+      // nothing to do
+    }
+
+    @Override
+    public void stop() {
+      throw new IllegalStateException("Faking an IllegalStateException thrown by a stoppable component in the Analysis Report processing container");
+    }
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/IseTaskProcessor.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/IseTaskProcessor.java
new file mode 100644 (file)
index 0000000..40b11ec
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import java.util.Collections;
+import java.util.Set;
+import org.sonar.ce.queue.CeTask;
+import org.sonar.ce.queue.CeTaskResult;
+import org.sonar.ce.taskprocessor.CeTaskProcessor;
+
+public class IseTaskProcessor implements CeTaskProcessor {
+  @Override
+  public Set<String> getHandledCeTaskTypes() {
+    return Collections.singleton("ISE");
+  }
+
+  @Override
+  public CeTaskResult process(CeTask task) {
+    throw new IllegalStateException("Faking an IllegalStateException thrown processing a task");
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/OOMGenerator.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/OOMGenerator.java
new file mode 100644 (file)
index 0000000..e867341
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public final class OOMGenerator {
+  private OOMGenerator() {
+    // prevents instantiation
+  }
+
+  public static List<Object> consumeAvailableMemory() {
+    List<Object> holder = new ArrayList<>();
+    while (true) {
+      holder.add(new byte[128 * 1024]);
+    }
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/OkTaskProcessor.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/OkTaskProcessor.java
new file mode 100644 (file)
index 0000000..88d9aba
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import java.util.Collections;
+import java.util.Optional;
+import java.util.Set;
+import org.sonar.ce.queue.CeTask;
+import org.sonar.ce.queue.CeTaskResult;
+import org.sonar.ce.taskprocessor.CeTaskProcessor;
+
+public class OkTaskProcessor implements CeTaskProcessor {
+  @Override
+  public Set<String> getHandledCeTaskTypes() {
+    return Collections.singleton("OK");
+  }
+
+  @Override
+  public CeTaskResult process(CeTask task) {
+    return Optional::empty;
+  }
+
+
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/OomTaskProcessor.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/OomTaskProcessor.java
new file mode 100644 (file)
index 0000000..a79c71f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce;
+
+import java.util.Collections;
+import java.util.Set;
+import org.sonar.ce.queue.CeTask;
+import org.sonar.ce.queue.CeTaskResult;
+import org.sonar.ce.taskprocessor.CeTaskProcessor;
+
+public class OomTaskProcessor implements CeTaskProcessor {
+  @Override
+  public Set<String> getHandledCeTaskTypes() {
+    return Collections.singleton("OOM");
+  }
+
+  @Override
+  public CeTaskResult process(CeTask task) {
+    OOMGenerator.consumeAvailableMemory();
+    return null;
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/BombActivatorAction.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/BombActivatorAction.java
new file mode 100644 (file)
index 0000000..31be2ce
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce.ws;
+
+import ce.BombConfig;
+import java.util.Arrays;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+
+import static java.util.stream.Collectors.toList;
+
+public class BombActivatorAction implements FakeGoVWsAction {
+
+  private static final String PARAM_BOMB_TYPE = "type";
+
+  private final BombConfig bombConfig;
+
+  public BombActivatorAction(BombConfig bombConfig) {
+    this.bombConfig = bombConfig;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("activate_bomb")
+      .setPost(true)
+      .setHandler(this);
+    action.createParam(PARAM_BOMB_TYPE)
+      .setRequired(true)
+      .setPossibleValues(Arrays.stream(BombType.values()).map(Enum::toString).collect(toList()));
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    BombType bombType = BombType.valueOf(request.mandatoryParam(PARAM_BOMB_TYPE));
+
+    bombConfig.reset();
+    switch (bombType) {
+      case ISE_START:
+        bombConfig.setIseStartBomb(true);
+        break;
+      case OOM_START:
+        bombConfig.setOomStartBomb(true);
+        break;
+      case ISE_STOP:
+        bombConfig.setIseStopBomb(true);
+        break;
+      case OOM_STOP:
+        bombConfig.setOomStopBomb(true);
+        break;
+      case NONE:
+        break;
+      default:
+        throw new IllegalArgumentException("Unsupported bomb type " + bombType);
+    }
+
+    response.noContent();
+  }
+
+  enum BombType {
+    NONE, OOM_START, ISE_START, OOM_STOP, ISE_STOP
+
+  }
+
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGoVWsAction.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGoVWsAction.java
new file mode 100644 (file)
index 0000000..58fb69a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce.ws;
+
+import org.sonar.server.ws.WsAction;
+
+public interface FakeGoVWsAction extends WsAction {
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGovWs.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/FakeGovWs.java
new file mode 100644 (file)
index 0000000..41a4984
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce.ws;
+
+import java.util.Arrays;
+import org.sonar.api.server.ws.WebService;
+
+public class FakeGovWs implements WebService {
+  private final FakeGoVWsAction[] actions;
+
+  public FakeGovWs(FakeGoVWsAction[] actions) {
+    this.actions = actions;
+  }
+
+  @Override
+  public void define(Context context) {
+    NewController controller = context.createController("api/fake_gov");
+    Arrays.stream(actions).forEach(action -> action.define(controller));
+    controller.done();
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/SubmitAction.java b/tests/plugins/core-extension-it-tests/src/main/java/ce/ws/SubmitAction.java
new file mode 100644 (file)
index 0000000..fb47686
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package ce.ws;
+
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.ce.queue.CeQueue;
+import org.sonar.ce.queue.CeTaskSubmit;
+
+public class SubmitAction implements FakeGoVWsAction {
+
+  private static final String PARAM_TYPE = "type";
+
+  private final CeQueue ceQueue;
+
+  public SubmitAction(CeQueue ceQueue) {
+    this.ceQueue = ceQueue;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("submit")
+      .setPost(true)
+      .setHandler(this);
+    action.createParam(PARAM_TYPE)
+      .setRequired(true)
+      .setPossibleValues("OOM", "OK", "ISE");
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    String type = request.mandatoryParam(PARAM_TYPE);
+
+    CeTaskSubmit.Builder submit = ceQueue.prepareSubmit();
+    submit.setType(type);
+
+    ceQueue.submit(submit.build());
+    response.noContent();
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/systemPasscode/SystemPasscodeWebService.java b/tests/plugins/core-extension-it-tests/src/main/java/systemPasscode/SystemPasscodeWebService.java
new file mode 100644 (file)
index 0000000..b1682ae
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package systemPasscode;
+
+import java.net.HttpURLConnection;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.RequestHandler;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.user.SystemPasscode;
+
+public class SystemPasscodeWebService implements WebService, RequestHandler {
+  private final SystemPasscode passcode;
+
+  public SystemPasscodeWebService(SystemPasscode passcode) {
+    this.passcode = passcode;
+  }
+
+  @Override
+  public void define(Context context) {
+    NewController controller = context.createController("api/system_passcode");
+    controller.createAction("check").setHandler(this);
+    controller.done();
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    if (!passcode.isValid(request)) {
+      response.stream().setStatus(HttpURLConnection.HTTP_UNAUTHORIZED);
+    }
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/workerCount/FakeWorkerCountProviderImpl.java b/tests/plugins/core-extension-it-tests/src/main/java/workerCount/FakeWorkerCountProviderImpl.java
new file mode 100644 (file)
index 0000000..4e05ecd
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package workerCount;
+/*
+ * 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 org.sonar.api.config.Configuration;
+import org.sonar.ce.configuration.WorkerCountProvider;
+
+public class FakeWorkerCountProviderImpl implements WorkerCountProvider {
+
+  static final String PROPERTY_WORKER_COUNT = "fakeGovernance.workerCount";
+
+  private final Configuration configuration;
+
+  public FakeWorkerCountProviderImpl(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  @Override
+  public int get() {
+    return configuration.get(PROPERTY_WORKER_COUNT).map(Integer::valueOf).orElse(1);
+  }
+
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/workerCount/RefreshWorkerCountAction.java b/tests/plugins/core-extension-it-tests/src/main/java/workerCount/RefreshWorkerCountAction.java
new file mode 100644 (file)
index 0000000..df37590
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package workerCount;
+
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.ce.http.CeHttpClient;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.property.PropertyDto;
+import org.sonar.server.ce.ws.CeWsAction;
+
+import static workerCount.FakeWorkerCountProviderImpl.PROPERTY_WORKER_COUNT;
+
+@ServerSide
+public class RefreshWorkerCountAction implements CeWsAction {
+  private static final String PARAM_COUNT = "count";
+
+  private final CeHttpClient ceHttpClient;
+  private final DbClient dbClient;
+
+  public RefreshWorkerCountAction(CeHttpClient ceHttpClient, DbClient dbClient) {
+    this.ceHttpClient = ceHttpClient;
+    this.dbClient = dbClient;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    controller.createAction("refreshWorkerCount")
+      .setPost(true)
+      .setHandler(this)
+      .createParam(PARAM_COUNT)
+      .setPossibleValues("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
+      .setRequired(true);
+  }
+
+  @Override
+  public void handle(Request request, Response response) {
+    String count = request.getParam(PARAM_COUNT).getValue();
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      dbClient.propertiesDao().saveProperty(new PropertyDto()
+        .setKey(PROPERTY_WORKER_COUNT)
+        .setValue(count));
+      dbSession.commit();
+    }
+    ceHttpClient.refreshCeWorkerCount();
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java b/tests/plugins/core-extension-it-tests/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java
new file mode 100644 (file)
index 0000000..6529754
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package workerlatch;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import org.sonar.api.ce.measure.Component;
+import org.sonar.api.ce.measure.MeasureComputer;
+import org.sonar.api.config.Configuration;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class LatchControllerWorkerMeasureComputer implements MeasureComputer {
+  private static final Logger LOG = Loggers.get(LatchControllerWorkerMeasureComputer.class);
+  private static final String WORKER_LATCH_SHARED_MEMORY_FILE_PATH = "itTests.workerLatch.sharedMemoryFile";
+
+  private static final int WAIT = 200; // ms
+  private static final int MAX_WAIT_ROUND = 5 * 60 * 2; // 2 minutes
+
+  private static final int MAX_SHARED_MEMORY = 1;
+  private static final byte UNLATCHED = (byte) 0x01;
+
+  private final File sharedMemory;
+
+  public LatchControllerWorkerMeasureComputer(Configuration configuration) {
+    this.sharedMemory = configuration.get(WORKER_LATCH_SHARED_MEMORY_FILE_PATH)
+      .map(path -> {
+        File file = new File(path);
+        if (file.exists() && file.isFile()) {
+          return file;
+        }
+        LOG.info("Latch sharedMemory file {} is not a file or does not exist", path);
+        return null;
+      })
+      .orElse(null);
+  }
+
+  private boolean isLatchEnabled() {
+    return sharedMemory != null;
+  }
+
+  @Override
+  public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
+    return defContext.newDefinitionBuilder()
+      .setOutputMetrics(WorkerLatchMetrics.METRIC_KEY)
+      .build();
+  }
+
+  @Override
+  public void compute(MeasureComputerContext context) {
+    Component component = context.getComponent();
+    if (isLatchEnabled() && component.getType() == Component.Type.PROJECT) {
+      context.addMeasure(WorkerLatchMetrics.METRIC_KEY, waitForUnlatched(component.getKey()));
+    } else {
+      context.addMeasure(WorkerLatchMetrics.METRIC_KEY, false);
+    }
+  }
+
+  private boolean waitForUnlatched(String key) {
+    RandomAccessFile randomAccessFile = null;
+    try {
+      randomAccessFile = new RandomAccessFile(sharedMemory, "rw");
+      MappedByteBuffer mappedByteBuffer = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, MAX_SHARED_MEMORY);
+      int i = 0;
+      boolean unlatched = isUnlatched(mappedByteBuffer);
+      while (!unlatched && i < MAX_WAIT_ROUND) {
+        waitInterruptedly();
+        i++;
+        unlatched = isUnlatched(mappedByteBuffer);
+      }
+      LOG.info("Project {} unlatched={} i={}",  key, unlatched, i);
+
+      return true;
+    } catch (IOException e) {
+      LOG.error("Failed to read or write to shared memory", e);
+      return false;
+    } finally {
+      if (randomAccessFile != null) {
+        try {
+          randomAccessFile.close();
+        } catch (IOException e) {
+          LOG.error("Failed to close randomAccessFile", e);
+        }
+      }
+    }
+  }
+
+  private static void waitInterruptedly() {
+    try {
+      Thread.sleep(WAIT);
+    } catch (InterruptedException e) {
+      LOG.error("Wait was interrupted");
+    }
+  }
+
+  private boolean isUnlatched(MappedByteBuffer mappedByteBuffer) {
+    return mappedByteBuffer.get(0) == UNLATCHED;
+  }
+
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/java/workerlatch/WorkerLatchMetrics.java b/tests/plugins/core-extension-it-tests/src/main/java/workerlatch/WorkerLatchMetrics.java
new file mode 100644 (file)
index 0000000..7b31a6c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.
+ */
+package workerlatch;
+
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+
+public class WorkerLatchMetrics implements Metrics {
+  static final String METRIC_KEY = "WORKER_LATCH";
+
+  @Override
+  public List<Metric> getMetrics() {
+    return Collections.singletonList(
+      new Metric.Builder(METRIC_KEY, "Worker latch", Metric.ValueType.BOOL)
+        .setHidden(true)
+        .create());
+  }
+}
diff --git a/tests/plugins/core-extension-it-tests/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension b/tests/plugins/core-extension-it-tests/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension
new file mode 100644 (file)
index 0000000..0587227
--- /dev/null
@@ -0,0 +1 @@
+ItTestsCoreExtension
diff --git a/tests/plugins/core-extension-it-tests/src/main/resources/org/sonar/l10n/billing.properties b/tests/plugins/core-extension-it-tests/src/main/resources/org/sonar/l10n/billing.properties
new file mode 100644 (file)
index 0000000..f8ac8fc
--- /dev/null
@@ -0,0 +1,2 @@
+billing.upgrade_box.header=The fake billing plugin is installed
+billing.upgrade_box.text=It shows how to change the wording and hide the "Upgrade" button.
\ No newline at end of file
diff --git a/tests/plugins/fake-governance-plugin/build.gradle b/tests/plugins/fake-governance-plugin/build.gradle
deleted file mode 100644 (file)
index 77e1a9d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-dependencies {
-  compileOnly project(path: ':sonar-plugin-api', configuration: 'shadow')
-  compileOnly project(':server:sonar-server')
-}
-
-jar {
-  manifest {
-    attributes(
-      'Plugin-Key': 'governance',
-      'Plugin-Version': version,
-      'Plugin-Class': 'FakeGovernancePlugin',
-      'Plugin-ChildFirstClassLoader': 'false',
-      'Sonar-Version': version,
-      'SonarLint-Supported': 'false',
-      'Plugin-Name': 'Plugins :: Fake Governance Plugin',
-      'Plugin-License': 'GNU LGPL 3'
-    )
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java b/tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java
deleted file mode 100644 (file)
index df27964..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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 ce.BombConfig;
-import ce.ComponentBombReportAnalysisComponentProvider;
-import ce.IseTaskProcessor;
-import ce.OkTaskProcessor;
-import ce.OomTaskProcessor;
-import ce.ws.BombActivatorAction;
-import ce.ws.FakeGovWs;
-import ce.ws.SubmitAction;
-import org.sonar.api.Plugin;
-import systemPasscode.SystemPasscodeWebService;
-import workerCount.FakeWorkerCountProviderImpl;
-import workerCount.RefreshWorkerCountAction;
-import workerlatch.LatchControllerWorkerMeasureComputer;
-import workerlatch.WorkerLatchMetrics;
-
-public class FakeGovernancePlugin implements Plugin {
-
-  @Override
-  public void define(Context context) {
-    // Nothing should be loaded when the plugin is running within by the scanner
-    if (isRunningInSQ()) {
-      context.addExtension(FakeWorkerCountProviderImpl.class);
-      context.addExtension(WorkerLatchMetrics.class);
-      context.addExtension(LatchControllerWorkerMeasureComputer.class);
-      context.addExtension(RefreshWorkerCountAction.class);
-      context.addExtension(SystemPasscodeWebService.class);
-
-      // WS api/fake_gov
-      context.addExtension(FakeGovWs.class);
-
-      // failing CE tasks
-      context.addExtension(SubmitAction.class);
-      context.addExtension(OomTaskProcessor.class);
-      context.addExtension(IseTaskProcessor.class);
-      context.addExtension(OkTaskProcessor.class);
-
-      // component bombs injection into the Report Analysis processing container in the CE
-      context.addExtension(BombConfig.class);
-      context.addExtension(ComponentBombReportAnalysisComponentProvider.class);
-      context.addExtension(BombActivatorAction.class);
-    }
-  }
-
-  private static boolean isRunningInSQ() {
-    try {
-      Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
-      return true;
-    } catch (ClassNotFoundException e) {
-      return false;
-    }
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/BombConfig.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/BombConfig.java
deleted file mode 100644 (file)
index d6fdd5d..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import org.sonar.api.ce.ComputeEngineSide;
-import org.sonar.api.server.ServerSide;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-
-@ServerSide
-@ComputeEngineSide
-public class BombConfig {
-  private static final String OOM_START_BOMB_KEY = "oomStartBomb";
-  private static final String ISE_START_BOMB_KEY = "iseStartBomb";
-  private static final String OOM_STOP_BOMB_KEY = "oomStopBomb";
-  private static final String ISE_STOP_BOMB_KEY = "iseStopBomb";
-
-  private final DbClient dbClient;
-
-  public BombConfig(DbClient dbClient) {
-    this.dbClient = dbClient;
-  }
-
-  public void reset() {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.internalPropertiesDao().save(dbSession, OOM_START_BOMB_KEY, String.valueOf(false));
-      dbClient.internalPropertiesDao().save(dbSession, ISE_START_BOMB_KEY, String.valueOf(false));
-      dbClient.internalPropertiesDao().save(dbSession, OOM_STOP_BOMB_KEY, String.valueOf(false));
-      dbClient.internalPropertiesDao().save(dbSession, ISE_STOP_BOMB_KEY, String.valueOf(false));
-      dbSession.commit();
-    }
-  }
-
-  public boolean isOomStartBomb() {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      return dbClient.internalPropertiesDao().selectByKey(dbSession, OOM_START_BOMB_KEY).map(Boolean::valueOf).orElse(false);
-    }
-  }
-
-  public void setOomStartBomb(boolean oomStartBomb) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.internalPropertiesDao().save(dbSession, OOM_START_BOMB_KEY, String.valueOf(oomStartBomb));
-      dbSession.commit();
-    }
-  }
-
-  public boolean isIseStartBomb() {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      return dbClient.internalPropertiesDao().selectByKey(dbSession, ISE_START_BOMB_KEY).map(Boolean::valueOf).orElse(false);
-    }
-  }
-
-  public void setIseStartBomb(boolean iseStartBomb) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.internalPropertiesDao().save(dbSession, ISE_START_BOMB_KEY, String.valueOf(iseStartBomb));
-      dbSession.commit();
-    }
-  }
-
-  public boolean isOomStopBomb() {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      return dbClient.internalPropertiesDao().selectByKey(dbSession, OOM_STOP_BOMB_KEY).map(Boolean::valueOf).orElse(false);
-    }
-  }
-
-  public void setOomStopBomb(boolean oomStopBomb) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.internalPropertiesDao().save(dbSession, OOM_STOP_BOMB_KEY, String.valueOf(oomStopBomb));
-      dbSession.commit();
-    }
-  }
-
-  public boolean isIseStopBomb() {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      return dbClient.internalPropertiesDao().selectByKey(dbSession, ISE_STOP_BOMB_KEY).map(Boolean::valueOf).orElse(false);
-    }
-  }
-
-  public void setIseStopBomb(boolean iseStopBomb) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.internalPropertiesDao().save(dbSession, ISE_STOP_BOMB_KEY, String.valueOf(iseStopBomb));
-      dbSession.commit();
-    }
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/ComponentBombReportAnalysisComponentProvider.java
deleted file mode 100644 (file)
index 2b2ea4e..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.List;
-import org.picocontainer.Startable;
-import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
-import org.sonar.server.computation.task.container.EagerStart;
-
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singletonList;
-
-public class ComponentBombReportAnalysisComponentProvider implements ReportAnalysisComponentProvider {
-  private final BombConfig bombConfig;
-
-  public ComponentBombReportAnalysisComponentProvider(BombConfig bombConfig) {
-    this.bombConfig = bombConfig;
-  }
-
-  @Override
-  public List<Object> getComponents() {
-    if (bombConfig.isOomStartBomb()) {
-      return singletonList(OOMFailingStartComponent.class);
-    }
-    if (bombConfig.isIseStartBomb()) {
-      return singletonList(ISEFailingStartComponent.class);
-    }
-    if (bombConfig.isOomStopBomb()) {
-      return singletonList(OOMFailingStopComponent.class);
-    }
-    if (bombConfig.isIseStopBomb()) {
-      return singletonList(ISEFailingStopComponent.class);
-    }
-    return emptyList();
-  }
-
-  @EagerStart
-  public static final class OOMFailingStartComponent implements Startable {
-
-    @Override
-    public void start() {
-      OOMGenerator.consumeAvailableMemory();
-    }
-
-    @Override
-    public void stop() {
-      // nothing to do
-    }
-  }
-
-  @EagerStart
-  public static final class ISEFailingStartComponent implements Startable {
-
-    @Override
-    public void start() {
-      throw new IllegalStateException("Faking an IllegalStateException thrown by a startable component in the Analysis Report processing container");
-    }
-
-    @Override
-    public void stop() {
-      // nothing to do
-    }
-  }
-
-  @EagerStart
-  public static final class OOMFailingStopComponent implements Startable {
-
-    @Override
-    public void start() {
-      // nothing to do
-    }
-
-    @Override
-    public void stop() {
-      OOMGenerator.consumeAvailableMemory();
-    }
-  }
-
-  @EagerStart
-  public static final class ISEFailingStopComponent implements Startable {
-
-    @Override
-    public void start() {
-      // nothing to do
-    }
-
-    @Override
-    public void stop() {
-      throw new IllegalStateException("Faking an IllegalStateException thrown by a stoppable component in the Analysis Report processing container");
-    }
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/IseTaskProcessor.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/IseTaskProcessor.java
deleted file mode 100644 (file)
index 40b11ec..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.Collections;
-import java.util.Set;
-import org.sonar.ce.queue.CeTask;
-import org.sonar.ce.queue.CeTaskResult;
-import org.sonar.ce.taskprocessor.CeTaskProcessor;
-
-public class IseTaskProcessor implements CeTaskProcessor {
-  @Override
-  public Set<String> getHandledCeTaskTypes() {
-    return Collections.singleton("ISE");
-  }
-
-  @Override
-  public CeTaskResult process(CeTask task) {
-    throw new IllegalStateException("Faking an IllegalStateException thrown processing a task");
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/OOMGenerator.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/OOMGenerator.java
deleted file mode 100644 (file)
index e867341..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public final class OOMGenerator {
-  private OOMGenerator() {
-    // prevents instantiation
-  }
-
-  public static List<Object> consumeAvailableMemory() {
-    List<Object> holder = new ArrayList<>();
-    while (true) {
-      holder.add(new byte[128 * 1024]);
-    }
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/OkTaskProcessor.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/OkTaskProcessor.java
deleted file mode 100644 (file)
index 88d9aba..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.Collections;
-import java.util.Optional;
-import java.util.Set;
-import org.sonar.ce.queue.CeTask;
-import org.sonar.ce.queue.CeTaskResult;
-import org.sonar.ce.taskprocessor.CeTaskProcessor;
-
-public class OkTaskProcessor implements CeTaskProcessor {
-  @Override
-  public Set<String> getHandledCeTaskTypes() {
-    return Collections.singleton("OK");
-  }
-
-  @Override
-  public CeTaskResult process(CeTask task) {
-    return Optional::empty;
-  }
-
-
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/OomTaskProcessor.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/OomTaskProcessor.java
deleted file mode 100644 (file)
index a79c71f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.Collections;
-import java.util.Set;
-import org.sonar.ce.queue.CeTask;
-import org.sonar.ce.queue.CeTaskResult;
-import org.sonar.ce.taskprocessor.CeTaskProcessor;
-
-public class OomTaskProcessor implements CeTaskProcessor {
-  @Override
-  public Set<String> getHandledCeTaskTypes() {
-    return Collections.singleton("OOM");
-  }
-
-  @Override
-  public CeTaskResult process(CeTask task) {
-    OOMGenerator.consumeAvailableMemory();
-    return null;
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/BombActivatorAction.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/BombActivatorAction.java
deleted file mode 100644 (file)
index 31be2ce..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce.ws;
-
-import ce.BombConfig;
-import java.util.Arrays;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-
-import static java.util.stream.Collectors.toList;
-
-public class BombActivatorAction implements FakeGoVWsAction {
-
-  private static final String PARAM_BOMB_TYPE = "type";
-
-  private final BombConfig bombConfig;
-
-  public BombActivatorAction(BombConfig bombConfig) {
-    this.bombConfig = bombConfig;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("activate_bomb")
-      .setPost(true)
-      .setHandler(this);
-    action.createParam(PARAM_BOMB_TYPE)
-      .setRequired(true)
-      .setPossibleValues(Arrays.stream(BombType.values()).map(Enum::toString).collect(toList()));
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    BombType bombType = BombType.valueOf(request.mandatoryParam(PARAM_BOMB_TYPE));
-
-    bombConfig.reset();
-    switch (bombType) {
-      case ISE_START:
-        bombConfig.setIseStartBomb(true);
-        break;
-      case OOM_START:
-        bombConfig.setOomStartBomb(true);
-        break;
-      case ISE_STOP:
-        bombConfig.setIseStopBomb(true);
-        break;
-      case OOM_STOP:
-        bombConfig.setOomStopBomb(true);
-        break;
-      case NONE:
-        break;
-      default:
-        throw new IllegalArgumentException("Unsupported bomb type " + bombType);
-    }
-
-    response.noContent();
-  }
-
-  enum BombType {
-    NONE, OOM_START, ISE_START, OOM_STOP, ISE_STOP
-
-  }
-
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGoVWsAction.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGoVWsAction.java
deleted file mode 100644 (file)
index 58fb69a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce.ws;
-
-import org.sonar.server.ws.WsAction;
-
-public interface FakeGoVWsAction extends WsAction {
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGovWs.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/FakeGovWs.java
deleted file mode 100644 (file)
index 41a4984..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce.ws;
-
-import java.util.Arrays;
-import org.sonar.api.server.ws.WebService;
-
-public class FakeGovWs implements WebService {
-  private final FakeGoVWsAction[] actions;
-
-  public FakeGovWs(FakeGoVWsAction[] actions) {
-    this.actions = actions;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context.createController("api/fake_gov");
-    Arrays.stream(actions).forEach(action -> action.define(controller));
-    controller.done();
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/SubmitAction.java b/tests/plugins/fake-governance-plugin/src/main/java/ce/ws/SubmitAction.java
deleted file mode 100644 (file)
index fb47686..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.ce.queue.CeQueue;
-import org.sonar.ce.queue.CeTaskSubmit;
-
-public class SubmitAction implements FakeGoVWsAction {
-
-  private static final String PARAM_TYPE = "type";
-
-  private final CeQueue ceQueue;
-
-  public SubmitAction(CeQueue ceQueue) {
-    this.ceQueue = ceQueue;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("submit")
-      .setPost(true)
-      .setHandler(this);
-    action.createParam(PARAM_TYPE)
-      .setRequired(true)
-      .setPossibleValues("OOM", "OK", "ISE");
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    String type = request.mandatoryParam(PARAM_TYPE);
-
-    CeTaskSubmit.Builder submit = ceQueue.prepareSubmit();
-    submit.setType(type);
-
-    ceQueue.submit(submit.build());
-    response.noContent();
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/systemPasscode/SystemPasscodeWebService.java b/tests/plugins/fake-governance-plugin/src/main/java/systemPasscode/SystemPasscodeWebService.java
deleted file mode 100644 (file)
index b1682ae..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package systemPasscode;
-
-import java.net.HttpURLConnection;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.server.user.SystemPasscode;
-
-public class SystemPasscodeWebService implements WebService, RequestHandler {
-  private final SystemPasscode passcode;
-
-  public SystemPasscodeWebService(SystemPasscode passcode) {
-    this.passcode = passcode;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context.createController("api/system_passcode");
-    controller.createAction("check").setHandler(this);
-    controller.done();
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    if (!passcode.isValid(request)) {
-      response.stream().setStatus(HttpURLConnection.HTTP_UNAUTHORIZED);
-    }
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/workerCount/FakeWorkerCountProviderImpl.java b/tests/plugins/fake-governance-plugin/src/main/java/workerCount/FakeWorkerCountProviderImpl.java
deleted file mode 100644 (file)
index 4e05ecd..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package workerCount;
-/*
- * 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 org.sonar.api.config.Configuration;
-import org.sonar.ce.configuration.WorkerCountProvider;
-
-public class FakeWorkerCountProviderImpl implements WorkerCountProvider {
-
-  static final String PROPERTY_WORKER_COUNT = "fakeGovernance.workerCount";
-
-  private final Configuration configuration;
-
-  public FakeWorkerCountProviderImpl(Configuration configuration) {
-    this.configuration = configuration;
-  }
-
-  @Override
-  public int get() {
-    return configuration.get(PROPERTY_WORKER_COUNT).map(Integer::valueOf).orElse(1);
-  }
-
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/workerCount/RefreshWorkerCountAction.java b/tests/plugins/fake-governance-plugin/src/main/java/workerCount/RefreshWorkerCountAction.java
deleted file mode 100644 (file)
index df37590..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package workerCount;
-
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.ce.http.CeHttpClient;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.property.PropertyDto;
-import org.sonar.server.ce.ws.CeWsAction;
-
-import static workerCount.FakeWorkerCountProviderImpl.PROPERTY_WORKER_COUNT;
-
-@ServerSide
-public class RefreshWorkerCountAction implements CeWsAction {
-  private static final String PARAM_COUNT = "count";
-
-  private final CeHttpClient ceHttpClient;
-  private final DbClient dbClient;
-
-  public RefreshWorkerCountAction(CeHttpClient ceHttpClient, DbClient dbClient) {
-    this.ceHttpClient = ceHttpClient;
-    this.dbClient = dbClient;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    controller.createAction("refreshWorkerCount")
-      .setPost(true)
-      .setHandler(this)
-      .createParam(PARAM_COUNT)
-      .setPossibleValues("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
-      .setRequired(true);
-  }
-
-  @Override
-  public void handle(Request request, Response response) {
-    String count = request.getParam(PARAM_COUNT).getValue();
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      dbClient.propertiesDao().saveProperty(new PropertyDto()
-        .setKey(PROPERTY_WORKER_COUNT)
-        .setValue(count));
-      dbSession.commit();
-    }
-    ceHttpClient.refreshCeWorkerCount();
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java b/tests/plugins/fake-governance-plugin/src/main/java/workerlatch/LatchControllerWorkerMeasureComputer.java
deleted file mode 100644 (file)
index c6d2391..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package workerlatch;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import org.sonar.api.ce.measure.Component;
-import org.sonar.api.ce.measure.MeasureComputer;
-import org.sonar.api.config.Configuration;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-
-public class LatchControllerWorkerMeasureComputer implements MeasureComputer {
-  private static final Logger LOG = Loggers.get(LatchControllerWorkerMeasureComputer.class);
-  private static final String WORKER_LATCH_SHARED_MEMORY_FILE_PATH = "fakeGoverance.workerLatch.sharedMemoryFile";
-
-  private static final int WAIT = 200; // ms
-  private static final int MAX_WAIT_ROUND = 5 * 60 * 2; // 2 minutes
-
-  private static final int MAX_SHARED_MEMORY = 1;
-  private static final byte UNLATCHED = (byte) 0x01;
-
-  private final File sharedMemory;
-
-  public LatchControllerWorkerMeasureComputer(Configuration configuration) {
-    this.sharedMemory = configuration.get(WORKER_LATCH_SHARED_MEMORY_FILE_PATH)
-      .map(path -> {
-        File file = new File(path);
-        if (file.exists() && file.isFile()) {
-          return file;
-        }
-        LOG.info("Latch sharedMemory file {} is not a file or does not exist", path);
-        return null;
-      })
-      .orElse(null);
-  }
-
-  private boolean isLatchEnabled() {
-    return sharedMemory != null;
-  }
-
-  @Override
-  public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
-    return defContext.newDefinitionBuilder()
-      .setOutputMetrics(WorkerLatchMetrics.METRIC_KEY)
-      .build();
-  }
-
-  @Override
-  public void compute(MeasureComputerContext context) {
-    Component component = context.getComponent();
-    if (isLatchEnabled() && component.getType() == Component.Type.PROJECT) {
-      context.addMeasure(WorkerLatchMetrics.METRIC_KEY, waitForUnlatched(component.getKey()));
-    } else {
-      context.addMeasure(WorkerLatchMetrics.METRIC_KEY, false);
-    }
-  }
-
-  private boolean waitForUnlatched(String key) {
-    RandomAccessFile randomAccessFile = null;
-    try {
-      randomAccessFile = new RandomAccessFile(sharedMemory, "rw");
-      MappedByteBuffer mappedByteBuffer = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, MAX_SHARED_MEMORY);
-      int i = 0;
-      boolean unlatched = isUnlatched(mappedByteBuffer);
-      while (!unlatched && i < MAX_WAIT_ROUND) {
-        waitInterruptedly();
-        i++;
-        unlatched = isUnlatched(mappedByteBuffer);
-      }
-      LOG.info("Project {} unlatched={} i={}",  key, unlatched, i);
-
-      return true;
-    } catch (IOException e) {
-      LOG.error("Failed to read or write to shared memory", e);
-      return false;
-    } finally {
-      if (randomAccessFile != null) {
-        try {
-          randomAccessFile.close();
-        } catch (IOException e) {
-          LOG.error("Failed to close randomAccessFile", e);
-        }
-      }
-    }
-  }
-
-  private static void waitInterruptedly() {
-    try {
-      Thread.sleep(WAIT);
-    } catch (InterruptedException e) {
-      LOG.error("Wait was interrupted");
-    }
-  }
-
-  private boolean isUnlatched(MappedByteBuffer mappedByteBuffer) {
-    return mappedByteBuffer.get(0) == UNLATCHED;
-  }
-
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/workerlatch/WorkerLatchMetrics.java b/tests/plugins/fake-governance-plugin/src/main/java/workerlatch/WorkerLatchMetrics.java
deleted file mode 100644 (file)
index 7b31a6c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package workerlatch;
-
-import java.util.Collections;
-import java.util.List;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.Metrics;
-
-public class WorkerLatchMetrics implements Metrics {
-  static final String METRIC_KEY = "WORKER_LATCH";
-
-  @Override
-  public List<Metric> getMetrics() {
-    return Collections.singletonList(
-      new Metric.Builder(METRIC_KEY, "Worker latch", Metric.ValueType.BOOL)
-        .setHidden(true)
-        .create());
-  }
-}
diff --git a/tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties b/tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties
deleted file mode 100644 (file)
index f8ac8fc..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-billing.upgrade_box.header=The fake billing plugin is installed
-billing.upgrade_box.text=It shows how to change the wording and hide the "Upgrade" button.
\ No newline at end of file
index 26e21b4a31bcf21d3493241995729500410f9168..c6d4f1bf61ff13d020485e99058af0a900853a2a 100644 (file)
@@ -35,7 +35,6 @@ import static java.lang.String.format;
 public class Byteman {
 
   private final int port;
-  private final OrchestratorBuilder builder;
 
   public enum Process {
     WEB("sonar.web.javaAdditionalOpts"), CE("sonar.ce.javaAdditionalOpts");
@@ -47,10 +46,12 @@ public class Byteman {
     }
   }
 
-  public Byteman(OrchestratorBuilder builder, Process process) {
-    this.builder = builder;
-    String jar = findBytemanJar();
+  public Byteman() {
     port = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
+  }
+
+  public void install(OrchestratorBuilder builder, Process process) {
+    String jar = findBytemanJar();
     String bytemanArg = format("-javaagent:%s=boot:%s,port:%d", jar, jar, port);
     builder.setServerProperty(process.argument, bytemanArg);
   }
@@ -89,7 +90,4 @@ public class Byteman {
     }
   }
 
-    public OrchestratorBuilder getOrchestratorBuilder() {
-      return builder;
-    }
 }
index 09e1edb94d46532beb0e6edcc436b7f7b5466769..0a22aa2353acbafb65bf25ceb5ec6cab73acc65a 100644 (file)
@@ -49,26 +49,26 @@ import static util.ItUtils.xooPlugin;
 public class Category1Suite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .setServerProperty("sonar.notifications.delay", "1")
-    .addPlugin(pluginArtifact("property-sets-plugin"))
-    .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .setServerProperty("sonar.notifications.delay", "1")
+      .addPlugin(pluginArtifact("property-sets-plugin"))
+      .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
 
-    // Used in SettingsTest.global_property_change_extension_point
-    .addPlugin(pluginArtifact("global-property-change-plugin"))
+      // Used in SettingsTest.global_property_change_extension_point
+      .addPlugin(pluginArtifact("global-property-change-plugin"))
 
-    // Used in SettingsTest.should_get_settings_default_value
-    .addPlugin(pluginArtifact("server-plugin"))
+      // Used in SettingsTest.should_get_settings_default_value
+      .addPlugin(pluginArtifact("server-plugin"))
 
-    // Used in I18nTest
-    .addPlugin(pluginArtifact("l10n-fr-pack"))
+      // Used in I18nTest
+      .addPlugin(pluginArtifact("l10n-fr-pack"))
 
-    // 1 second. Required for notification test.
-    .setServerProperty("sonar.notifications.delay", "1")
+      // 1 second. Required for notification test.
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    .addPlugin(pluginArtifact("posttask-plugin"))
+      .addPlugin(pluginArtifact("posttask-plugin"))
 
-    .addPlugin(xooPlugin())
-    .build();
+      .addPlugin(xooPlugin()));
 
 }
index 6cec2f483b3e7bcddd8eac4acec39b0b25b41dcc..468dbf14999090d7d1ef28239a92f5acfe1b2738 100644 (file)
@@ -73,29 +73,28 @@ import static util.ItUtils.xooPlugin;
 public class Category3Suite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "LATEST_RELEASE"))
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "LATEST_RELEASE"))
 
-    // Used by SettingsEncryptionTest
-    .addPlugin(pluginArtifact("settings-encryption-plugin"))
+      // Used by SettingsEncryptionTest
+      .addPlugin(pluginArtifact("settings-encryption-plugin"))
 
-    // Used by IssuesModeTest
-    .addPlugin(pluginArtifact("access-secured-props-plugin"))
+      // Used by IssuesModeTest
+      .addPlugin(pluginArtifact("access-secured-props-plugin"))
 
-    // used by TempFolderTest and DecimalScaleMetricTest
-    .addPlugin(pluginArtifact("batch-plugin"))
+      // used by TempFolderTest and DecimalScaleMetricTest
+      .addPlugin(pluginArtifact("batch-plugin"))
 
-    // used by ExtensionLifecycleTest
-    .addPlugin(pluginArtifact("extension-lifecycle-plugin"))
+      // used by ExtensionLifecycleTest
+      .addPlugin(pluginArtifact("extension-lifecycle-plugin"))
 
-    // used by ProjectBuilderTest
-    .addPlugin(pluginArtifact("project-builder-plugin"))
+      // used by ProjectBuilderTest
+      .addPlugin(pluginArtifact("project-builder-plugin"))
 
-    // used by ProjectWithoutSourceTest
-    .addPlugin(pluginArtifact("save-measure-on-project-plugin"))
+      // used by ProjectWithoutSourceTest
+      .addPlugin(pluginArtifact("save-measure-on-project-plugin"))
 
-    .setServerProperty("sonar.ce.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
-
-    .build();
+      .setServerProperty("sonar.ce.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"));
 }
index 7e3ccedbc2ab05da9c7e0c744d9a7fe31e432d6e..b738d047fa7665344b9bccea6ebc9d3f0d417996 100644 (file)
@@ -35,8 +35,6 @@ import org.sonarqube.tests.serverSystem.LogsTest;
 import org.sonarqube.tests.serverSystem.PingTest;
 import org.sonarqube.tests.serverSystem.ServerSystemTest;
 import org.sonarqube.tests.serverSystem.SystemInfoTest;
-import org.sonarqube.tests.ui.UiExtensionsTest;
-import org.sonarqube.tests.ui.UiTest;
 import org.sonarqube.tests.ws.WsLocalCallTest;
 import org.sonarqube.tests.ws.WsTest;
 
@@ -74,19 +72,18 @@ import static util.ItUtils.xooPlugin;
 public class Category4Suite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    // Used in UiExtensionsTest
-    .addPlugin(pluginArtifact("ui-extensions-plugin"))
+      // Used in UiExtensionsTest
+      .addPlugin(pluginArtifact("ui-extensions-plugin"))
 
-    // Used by WsLocalCallTest
-    .addPlugin(pluginArtifact("ws-plugin"))
+      // Used by WsLocalCallTest
+      .addPlugin(pluginArtifact("ws-plugin"))
 
-    // Used by LogsTest
-    .setServerProperty("sonar.web.accessLogs.pattern", LogsTest.ACCESS_LOGS_PATTERN)
+      // Used by LogsTest
+      .setServerProperty("sonar.web.accessLogs.pattern", LogsTest.ACCESS_LOGS_PATTERN)
 
-    .setServerProperty("sonar.web.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8001")
-
-    .build();
+      .setServerProperty("sonar.web.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8001"));
 }
index bcb9a3159f7c80ef5fd7314df0cd1ee5e6164d98..123ab4aeb6f3afdd5054fa6585e3d342f6809070 100644 (file)
@@ -67,18 +67,16 @@ public class Category6Suite {
   public static final int SEARCH_HTTP_PORT = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      // for ES resiliency tests
+      .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
+      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
+      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    // for ES resiliency tests
-    .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
-    .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-    .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-    .setServerProperty("sonar.notifications.delay", "1")
+      .addPlugin(xooPlugin())
+      .addPlugin(pluginArtifact("ui-extensions-plugin"))
 
-    .addPlugin(xooPlugin())
-    .addPlugin(pluginArtifact("ui-extensions-plugin"))
-
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
-
-    .build();
+      .setServerProperty("sonar.sonarcloud.enabled", "true"));
 }
index 9cb1c5d39ddf48c1edcc5f32c46e74d92c4ec44a..2829597e2869b974aa1dba8ccce9a7d167f8710a 100644 (file)
@@ -64,13 +64,15 @@ public class AnalysisEsResilienceTest {
   private static final int esHttpPort = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
 
   static {
-    byteman = new Byteman(newOrchestratorBuilder(), CE);
-    orchestrator = byteman
-      .getOrchestratorBuilder()
-      .addPlugin(ItUtils.xooPlugin())
-      .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
-      .setServerProperty("sonar.sonarcloud.enabled", "true")
-      .build();
+    byteman = new Byteman();
+    orchestrator = newOrchestratorBuilder(
+      builder -> {
+        byteman.install(builder, CE);
+        builder
+          .addPlugin(ItUtils.xooPlugin())
+          .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
+          .setServerProperty("sonar.sonarcloud.enabled", "true");
+      });
   }
 
   @Rule
@@ -183,8 +185,7 @@ public class AnalysisEsResilienceTest {
         tuple("CONFIRMED", 0L),
         tuple("REOPENED", 0L),
         tuple("RESOLVED", 0L),
-        tuple("CLOSED", 0L)
-      );
+        tuple("CLOSED", 0L));
 
     tester.elasticsearch().unlockWrites("issues");
 
@@ -202,8 +203,7 @@ public class AnalysisEsResilienceTest {
         tuple("CONFIRMED", 0L),
         tuple("REOPENED", 0L),
         tuple("RESOLVED", 0L),
-        tuple("CLOSED", 0L)
-      );
+        tuple("CLOSED", 0L));
   }
 
   @Test
index 7e0c8cb864c499f1c6f578ec7762d1ac10572f99..2c92f49dfb73ed5ba4bcfa19491e6d71f10159da 100644 (file)
@@ -24,8 +24,8 @@ import org.junit.ClassRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
+import static util.ItUtils.installCoreExtension;
 import static util.ItUtils.newOrchestratorBuilder;
-import static util.ItUtils.pluginArtifact;
 import static util.ItUtils.xooPlugin;
 
 @RunWith(Suite.class)
@@ -42,13 +42,14 @@ import static util.ItUtils.xooPlugin;
 public class AuthorizationSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    // for SystemPasscodeTest
-    // this privileged plugin provides the WS api/system_passcode/check
-    // that is used by the tests
-    .addPlugin(pluginArtifact("fake-governance-plugin"))
-    .setServerProperty("sonar.web.systemPasscode", SystemPasscodeTest.VALID_PASSCODE)
-
-    .addPlugin(xooPlugin())
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .setServerProperty("sonar.web.systemPasscode", SystemPasscodeTest.VALID_PASSCODE)
+      .addPlugin(xooPlugin()),
+    server -> {
+      // for SystemPasscodeTest
+      // this core-extension provides the WS api/system_passcode/check
+      // that is used by the tests
+      installCoreExtension(server, "core-extension-it-tests");
+    });
 }
index 233c2662d208f618f0288d8ec7908d8db3f68440..fbdafe3697c9f4c8f318ab094494e7ff8e4c6f41 100644 (file)
@@ -22,7 +22,6 @@ package org.sonarqube.tests.authorization;
 import com.sonar.orchestrator.Orchestrator;
 import java.util.Arrays;
 import org.junit.ClassRule;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
@@ -32,7 +31,6 @@ import org.sonarqube.ws.client.WsResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-@Ignore("FIXME IT disabled because it relies on a WS getting injected with core class, ie. a privileged plugin (fake-governance-plugin)")
 public class SystemPasscodeTest {
 
   static final String VALID_PASSCODE = "123456";
index ce8678dc292083b0e7d1647b739c4088a735fb6c..a2253f43bcca45481993cc1fa2ba70324ec48a1e 100644 (file)
@@ -116,12 +116,12 @@ public class CeShutdownTest {
       pauseFile = temp.newFile();
       FileUtils.touch(pauseFile);
 
-      orchestrator = newOrchestratorBuilder()
-        .setServerProperty("sonar.ce.pauseTask.path", pauseFile.getAbsolutePath())
-        .setServerProperty("sonar.ce.gracefulStopTimeOutInMs", "" + timeOutInMs)
-        .addPlugin(ItUtils.xooPlugin())
-        .addPlugin(ItUtils.pluginArtifact("server-plugin"))
-        .build();
+      orchestrator = newOrchestratorBuilder(
+        builder -> builder
+          .setServerProperty("sonar.ce.pauseTask.path", pauseFile.getAbsolutePath())
+          .setServerProperty("sonar.ce.gracefulStopTimeOutInMs", "" + timeOutInMs)
+          .addPlugin(ItUtils.xooPlugin())
+          .addPlugin(ItUtils.pluginArtifact("server-plugin")));
       orchestrator.start();
       adminWsClient = ItUtils.newAdminWsClient(orchestrator);
       logsTailer = LogsTailer.builder()
index e70d3377bd990f0fbca13ba3768a8c7fdd03d710..2bfb2edbbb855aeac802748db08c6076538848b3 100644 (file)
@@ -21,7 +21,6 @@ package org.sonarqube.tests.ce;
 
 import com.google.common.collect.ImmutableList;
 import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.OrchestratorBuilder;
 import com.sonar.orchestrator.build.SonarScanner;
 import com.sonar.orchestrator.http.HttpMethod;
 import java.io.File;
@@ -43,7 +42,6 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonarqube.ws.Ce;
@@ -57,12 +55,11 @@ import static java.lang.String.valueOf;
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toSet;
 import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.installCoreExtension;
 import static util.ItUtils.newAdminWsClient;
 import static util.ItUtils.newOrchestratorBuilder;
-import static util.ItUtils.pluginArtifact;
 import static util.ItUtils.xooPlugin;
 
-@Ignore("FIXME IT disabled because it relies on a privileged plugin (fake-governance-plugin)")
 public class CeWorkersTest {
   private static final int WAIT = 200; // ms
   private static final int MAX_WAIT_LOOP = 5 * 60 * 5; // 5 minutes
@@ -84,13 +81,13 @@ public class CeWorkersTest {
   public static void setUp() throws Exception {
     sharedMemory = temporaryFolder.newFile();
 
-    OrchestratorBuilder builder = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("fake-governance-plugin"))
-      .setServerProperty("fakeGoverance.workerLatch.sharedMemoryFile", sharedMemory.getAbsolutePath())
-      // overwrite default value to display heap dump on OOM and reduce max heap
-      .setServerProperty("sonar.ce.javaOpts", "-Xmx256m -Xms128m")
-      .addPlugin(xooPlugin());
-    orchestrator = builder.build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .setServerProperty("itTests.workerLatch.sharedMemoryFile", sharedMemory.getAbsolutePath())
+        // overwrite default value to display heap dump on OOM and reduce max heap
+        .setServerProperty("sonar.ce.javaOpts", "-Xmx256m -Xms128m")
+        .addPlugin(xooPlugin()),
+      server -> installCoreExtension(server, "core-extension-it-tests"));
     orchestrator.start();
 
     adminWsClient = newAdminWsClient(orchestrator);
index 9d08069bc36800eaa1a455a9cecf0e1c17f51c2f..cce0e2ad99b187af0ec299c005fe42976ca6d36a 100644 (file)
@@ -37,8 +37,10 @@ import static util.ItUtils.xooPlugin;
 public class ComponentSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    .build();
+  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+
+  );
 
 }
index e8c1833f4021dc7794d2917ffe7d8a015c81bffd..e0f4bd3c9ba60a30dea1ad72ff493fa2d6cb3d7b 100644 (file)
@@ -37,8 +37,9 @@ import static util.ItUtils.xooPlugin;
 })
 public class DuplicationSuite {
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    .build();
+  );
 }
index c5aa35f5f5474d35110c090219c9894fd331c261..e5d78462f05d37ffa87b7bee2baf892eb7b322b2 100644 (file)
@@ -36,7 +36,9 @@ import util.ItUtils;
 public class ExternalIssueSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder()
-    .addPlugin(ItUtils.xooPlugin())
-    .build();
+  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(ItUtils.xooPlugin())
+
+  );
 }
index c085dfa1f727d85e634efccd56d211b404f5fa82..fcd3d9e4d4da2209c1308cf494c8e0ed152693f7 100644 (file)
@@ -69,11 +69,13 @@ public class IssueCreationDatePluginChangedTest {
   private static final String USER_EMAIL = "tester@example.org";
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    .addPlugin(ItUtils.pluginArtifact("backdating-plugin-v1"))
-    .addPlugin(ItUtils.pluginArtifact("backdating-customplugin"))
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      .addPlugin(ItUtils.pluginArtifact("backdating-plugin-v1"))
+      .addPlugin(ItUtils.pluginArtifact("backdating-customplugin"))
+
+  );
   @Rule
   public Tester tester = new Tester(ORCHESTRATOR);
 
index cc6a0097e410ccf87615d932c3c20fd5a12dc668..5d700760a77e7b46d838e0b9c77d6c136808ccc9 100644 (file)
@@ -53,16 +53,17 @@ import static util.ItUtils.xooPlugin;
 public class IssueSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .setServerProperty("sonar.search.httpPort", "9025")
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .setServerProperty("sonar.search.httpPort", "9025")
+      .addPlugin(xooPlugin())
 
-    // issue
-    .addPlugin(pluginArtifact("issue-filter-plugin"))
+      // issue
+      .addPlugin(pluginArtifact("issue-filter-plugin"))
 
-    // 1 second. Required for notification test.
-    .setServerProperty("sonar.notifications.delay", "1")
+      // 1 second. Required for notification test.
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    .build();
+  );
 
 }
index 943657e0721cb7f44e3b498edf48b01a233082d4..3cfc081c2edfd5eb03b09ea186594fe06b7d0c0a 100644 (file)
@@ -34,11 +34,12 @@ import static util.ItUtils.xooPlugin;
 public class OrganizationIssueSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
 
-    .build();
+  );
 
 }
index 0c89f7cd8fe08c29f90e8fa4db2ebe2b236fb74d..87a49287b39f4802ab68c52365cfbb00655f0ded 100644 (file)
@@ -25,14 +25,14 @@ import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.Components;
+import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.Measures;
 import org.sonarqube.ws.client.components.TreeRequest;
 import org.sonarqube.ws.client.issues.IssuesService;
 import org.sonarqube.ws.client.issues.SearchRequest;
-import org.sonarqube.ws.client.measures.ComponentTreeRequest;
 import org.sonarqube.ws.client.measures.ComponentRequest;
+import org.sonarqube.ws.client.measures.ComponentTreeRequest;
 import org.sonarqube.ws.client.measures.MeasuresService;
 
 import static java.util.Arrays.asList;
@@ -46,10 +46,10 @@ public class LiteTest {
 
   private static final String PROJECT_KEY = "com.sonarsource.it.samples:multi-modules-sample";
 
-  private static Orchestrator orchestrator = newOrchestratorBuilder()
-    .setOrchestratorProperty("sonar.web.context", "/sonarqube")
-    .addPlugin(xooPlugin())
-    .build();
+  private static Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
+      .setOrchestratorProperty("sonar.web.context", "/sonarqube")
+      .addPlugin(xooPlugin()));
 
   private static Tester tester = new Tester(orchestrator);
 
index 8e50a0804519987df8789c665ea6ce275fb4cc7f..e64590cb23ec9d4534b8fbed2588477180382c3a 100644 (file)
@@ -37,10 +37,12 @@ import static util.ItUtils.pluginArtifact;
 public class UpdateCenterTest {
 
   @ClassRule
-  public static final Orchestrator orchestrator = newOrchestratorBuilder()
-    .setServerProperty("sonar.updatecenter.url", UpdateCenterTest.class.getResource("/marketplace/UpdateCenterTest/update-center.properties").toString())
-    .addPlugin(pluginArtifact("sonar-fake-plugin"))
-    .build();
+  public static final Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
+      .setServerProperty("sonar.updatecenter.url", UpdateCenterTest.class.getResource("/marketplace/UpdateCenterTest/update-center.properties").toString())
+      .addPlugin(pluginArtifact("sonar-fake-plugin"))
+
+  );
 
   @Rule
   public UserRule userRule = UserRule.from(orchestrator);
@@ -57,10 +59,10 @@ public class UpdateCenterTest {
     MarketplacePage page = nav.logIn().submitCredentials(userRule.createAdminUser()).openMarketplace();
     page
       .hasPluginsCount(2)
-      .hasPluginWithText("Fake","installed")
-      .hasPluginWithText("Fake","Uninstall")
-      .hasPluginWithText("Fake","Licensed under GNU LGPL 3")
-      .hasPluginWithText("Fake","Developed by SonarSource");
+      .hasPluginWithText("Fake", "installed")
+      .hasPluginWithText("Fake", "Uninstall")
+      .hasPluginWithText("Fake", "Licensed under GNU LGPL 3")
+      .hasPluginWithText("Fake", "Developed by SonarSource");
 
     page
       .searchPlugin("fa")
index ea6ad5d0e7faac2ffd2287a453cfa725f10ed22b..ee937ed365860f4c3e2152eacf00e5bf2abdadb4 100644 (file)
@@ -45,12 +45,13 @@ import static util.ItUtils.xooPlugin;
 public class MeasureSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    // used by DecimalScaleMetricTest
-    .addPlugin(pluginArtifact("batch-plugin"))
+      // used by DecimalScaleMetricTest
+      .addPlugin(pluginArtifact("batch-plugin"))
 
-    .build();
+  );
 
 }
index 0e77d7c2854b4c65cd08ee3b22d23ae0ff67332e..a2b6c311e4377834a934271181756a1ebb57769a 100644 (file)
@@ -41,13 +41,14 @@ import static util.ItUtils.xooPlugin;
 public class OrganizationSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
 
-    .addPlugin(xooPlugin())
-    .addPlugin(pluginArtifact("fake-billing-plugin"))
-    .addPlugin(pluginArtifact("ui-extensions-plugin"))
+      .addPlugin(xooPlugin())
+      .addPlugin(pluginArtifact("fake-billing-plugin"))
+      .addPlugin(pluginArtifact("ui-extensions-plugin"))
 
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
 
-    .build();
+  );
 }
index 24eab925762c1cae8351e1618b614ed96ed605e6..e7143961452282be84356a38e67a3c869d7de6ad 100644 (file)
@@ -43,14 +43,14 @@ import static util.ItUtils.xooPlugin;
 public class ScannerPerformanceSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    // should not be so high, but required as long embedded h2 is used -> requires more memory on server
-    .setServerProperty("sonar.web.javaOpts", "-Xmx1G -XX:+HeapDumpOnOutOfMemoryError")
-    // Needed by DuplicationTest::hugeJavaFile
-    .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "LATEST_RELEASE"))
-    .restoreProfileAtStartup(FileLocation.ofClasspath("/one-xoo-issue-per-line.xml"))
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      // should not be so high, but required as long embedded h2 is used -> requires more memory on server
+      .setServerProperty("sonar.web.javaOpts", "-Xmx1G -XX:+HeapDumpOnOutOfMemoryError")
+      // Needed by DuplicationTest::hugeJavaFile
+      .addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", "LATEST_RELEASE"))
+      .restoreProfileAtStartup(FileLocation.ofClasspath("/one-xoo-issue-per-line.xml")));
 
   @BeforeClass
   public static void setUp() {
index f6e15a279a1ff156210038e770ca2d20312e118e..864aba6512a0739cb71a00389cc157d18a022617 100644 (file)
@@ -44,13 +44,13 @@ public class ComputeEnginePerfTest extends AbstractPerfTest {
   public static TemporaryFolder temp = new TemporaryFolder();
 
   @ClassRule
-  public static Orchestrator orchestrator = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    .setServerProperty(
-      "sonar.web.javaOpts",
-      String.format("-Xms%dm -Xmx%dm -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true", MAX_HEAP_SIZE_IN_MEGA, MAX_HEAP_SIZE_IN_MEGA))
-    .restoreProfileAtStartup(FileLocation.ofClasspath("/one-xoo-issue-per-line.xml"))
-    .build();
+  public static Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      .setServerProperty(
+        "sonar.web.javaOpts",
+        String.format("-Xms%dm -Xmx%dm -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true", MAX_HEAP_SIZE_IN_MEGA, MAX_HEAP_SIZE_IN_MEGA))
+      .restoreProfileAtStartup(FileLocation.ofClasspath("/one-xoo-issue-per-line.xml")));
 
   private static File bigProjectBaseDir;
 
index 2d147551db5d9874ec2bd2f564a941e32af43cd9..0b99aeaa36d262128386c50ed49489901e0c0caf 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonarqube.tests.performance.server;
 
 import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.locator.FileLocation;
-import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Date;
@@ -46,15 +44,17 @@ public class ServerPerfTest extends AbstractPerfTest {
   @Test
   public void server_startup_and_shutdown() throws Exception {
     String defaultWebJavaOptions = "-Xmx768m -XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF-8";
-    Orchestrator orchestrator = newOrchestratorBuilder()
-      .addPlugin(xooPlugin())
+    Orchestrator orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(xooPlugin())
 
-      // See http://wiki.apache.org/tomcat/HowTo/FasterStartUp
-      // Sometimes source of entropy is too small and Tomcat spends ~20 seconds on the step :
-      // "Creation of SecureRandom instance for session ID generation using [SHA1PRNG]"
-      // Using /dev/urandom fixes the issue on linux
-      .setServerProperty("sonar.web.javaOpts", defaultWebJavaOptions + " -Djava.security.egd=file:/dev/./urandom")
-      .build();
+        // See http://wiki.apache.org/tomcat/HowTo/FasterStartUp
+        // Sometimes source of entropy is too small and Tomcat spends ~20 seconds on the step :
+        // "Creation of SecureRandom instance for session ID generation using [SHA1PRNG]"
+        // Using /dev/urandom fixes the issue on linux
+        .setServerProperty("sonar.web.javaOpts", defaultWebJavaOptions + " -Djava.security.egd=file:/dev/./urandom")
+
+    );
     try {
       ServerLogs.clear(orchestrator);
       orchestrator.start();
index 75dc194bac26a74d771249fa158ceb5de99780d5..7aae5bd8be34b69d518280c9b7a8ba05b05844c5 100644 (file)
@@ -52,20 +52,21 @@ public class OrganizationProjectSuite {
   static final int SEARCH_HTTP_PORT = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    // for ES resiliency tests
-    .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
-    .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-    .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-    .setServerProperty("sonar.notifications.delay", "1")
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      // for ES resiliency tests
+      .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
+      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
+      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
 
-    .addPlugin(xooPlugin())
+      .addPlugin(xooPlugin())
 
-    // for ProjectSettingsTest
-    .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
+      // for ProjectSettingsTest
+      .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
 
-    .build();
+  );
 
 }
index b469378dce40f3211ee8860b72dc084534b25dc7..79975d347155c5f745592871700f14987449b6e6 100644 (file)
@@ -40,18 +40,19 @@ public class ProjectSuite {
   static final int SEARCH_HTTP_PORT = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    // for ES resiliency tests
-    .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
-    .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-    .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-    .setServerProperty("sonar.notifications.delay", "1")
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      // for ES resiliency tests
+      .setServerProperty("sonar.search.httpPort", "" + SEARCH_HTTP_PORT)
+      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
+      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    .addPlugin(xooPlugin())
+      .addPlugin(xooPlugin())
 
-    // for ProjectSettingsTest
-    .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
+      // for ProjectSettingsTest
+      .addPlugin(pluginArtifact("sonar-subcategories-plugin"))
 
-    .build();
+  );
 
 }
index f91b9cdfbba7b77d22fa8e06173906997e2a417f..d3c1a816e6a9d471c790a2bb5efa6b325c5c741c 100644 (file)
@@ -37,13 +37,15 @@ import static util.ItUtils.xooPlugin;
 public class OrganizationQualityGateSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    // required for notification tests
-    .setServerProperty("sonar.notifications.delay", "1")
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      // required for notification tests
+      .setServerProperty("sonar.notifications.delay", "1")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
 
-    .addPlugin(pluginArtifact("posttask-plugin"))
-    .addPlugin(xooPlugin())
-    .build();
+      .addPlugin(pluginArtifact("posttask-plugin"))
+      .addPlugin(xooPlugin())
+
+  );
 
 }
index 910144e75cbd2bbdf8edf6e92a29ab195a9a4c5d..3cb1b8a9205974321f6160bf0b7e296d0463049a 100644 (file)
@@ -39,12 +39,14 @@ import static util.ItUtils.xooPlugin;
 public class QualityGateSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    // required for notification tests
-    .setServerProperty("sonar.notifications.delay", "1")
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      // required for notification tests
+      .setServerProperty("sonar.notifications.delay", "1")
 
-    .addPlugin(pluginArtifact("posttask-plugin"))
-    .addPlugin(xooPlugin())
-    .build();
+      .addPlugin(pluginArtifact("posttask-plugin"))
+      .addPlugin(xooPlugin())
+
+  );
 
 }
index b796cfe6b847b3bc575d3c9e15ad1a775b388581..ee286940e76b8e56080f9b30ac7d208f6abb2d09 100644 (file)
@@ -41,9 +41,10 @@ import static util.ItUtils.xooPlugin;
 public class QualityModelSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    .build();
+  );
 
 }
index 1320f6447fe05e2fab09545f60d8c2244b20e491..9ba5c3505c7adb58c8a8b4e76188c3c324cdac19 100644 (file)
@@ -48,14 +48,15 @@ public class ActiveRuleEsResilienceTest {
   private static final Byteman byteman;
 
   static {
-    byteman = new Byteman(newOrchestratorBuilder(), WEB);
-    orchestrator = byteman
-      .getOrchestratorBuilder()
-      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-      .setServerProperty("sonar.sonarcloud.enabled", "true")
-      .addPlugin(ItUtils.xooPlugin())
-      .build();
+    byteman = new Byteman();
+    orchestrator = newOrchestratorBuilder(
+      builder -> {
+        byteman.install(builder, WEB);
+        builder.setServerProperty("sonar.search.recovery.delayInMs", "1000")
+          .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+          .setServerProperty("sonar.sonarcloud.enabled", "true")
+          .addPlugin(ItUtils.xooPlugin());
+      });
   }
 
   @Before
index 91b687b2d949848207e0d4664db4b5c18887eb29..4001581cc8fbb64d3c9f553b5a8d8af3214f4786 100644 (file)
@@ -68,11 +68,11 @@ public class BuiltInQualityProfilesNotificationTest {
 
   @Test
   public void does_not_send_mail_if_no_quality_profile_is_updated() throws Exception {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("foo-plugin-v1"))
-      .setServerProperty("email.smtp_host.secured", "localhost")
-      .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort()))
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("foo-plugin-v1"))
+        .setServerProperty("email.smtp_host.secured", "localhost")
+        .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort())));
     orchestrator.start();
     userRule = UserRule.from(orchestrator);
     Users.CreateWsResponse.User profileAdmin1 = userRule.generate();
@@ -87,12 +87,12 @@ public class BuiltInQualityProfilesNotificationTest {
 
   @Test
   public void send_mail_if_quality_profile_is_updated() throws Exception {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("foo-plugin-v1"))
-      .setServerProperty("sonar.notifications.delay", "1")
-      .setServerProperty("email.smtp_host.secured", "localhost")
-      .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort()))
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("foo-plugin-v1"))
+        .setServerProperty("sonar.notifications.delay", "1")
+        .setServerProperty("email.smtp_host.secured", "localhost")
+        .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort())));
     orchestrator.start();
 
     userRule = UserRule.from(orchestrator);
@@ -143,7 +143,6 @@ public class BuiltInQualityProfilesNotificationTest {
         "This is a good time to review your quality profiles and update them to benefit from the latest evolutions: " + url + "/profiles")
       .isEqualTo(messages.get(1).getMimeMessage().getContent().toString());
 
-
     // uninstall plugin V2
     wsClient.wsConnector().call(new PostRequest("api/plugins/uninstall").setParam("key", "foo")).failIfNotSuccessful();
     // install plugin V1
@@ -175,12 +174,12 @@ public class BuiltInQualityProfilesNotificationTest {
 
   @Test
   public void do_not_send_mail_if_notifications_are_disabled_in_settings() throws Exception {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("foo-plugin-v1"))
-      .setServerProperty("sonar.builtInQualityProfiles.disableNotificationOnUpdate", "true")
-      .setServerProperty("email.smtp_host.secured", "localhost")
-      .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort()))
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("foo-plugin-v1"))
+        .setServerProperty("sonar.builtInQualityProfiles.disableNotificationOnUpdate", "true")
+        .setServerProperty("email.smtp_host.secured", "localhost")
+        .setServerProperty("email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort())));
     orchestrator.start();
     userRule = UserRule.from(orchestrator);
     Users.CreateWsResponse.User profileAdmin1 = userRule.generate();
index be34df9fccdec49a51e7924b8e9b7280eea6fc79..f0a66d8ca5e97570ac9dd599d6ffac78d7daeaf2 100644 (file)
@@ -54,10 +54,11 @@ public class QualityProfileUpdateTest {
   @Test
   // SONAR-10363
   public void updating_an_analyzer_must_update_default_quality_profile() {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("foo-plugin-v1"))
-//      .setServerProperty("sonar.sonarcloud.enabled", "true")
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("foo-plugin-v1"))
+    // .setServerProperty("sonar.sonarcloud.enabled", "true"))
+    );
     orchestrator.start();
     tester = new Tester(orchestrator);
     tester.before();
index 1163564bbba04fa2e6097658c2c609c0c950e3fe..4749cb897905c24d526936b81a998689ae50cd31 100644 (file)
@@ -47,13 +47,15 @@ public class RuleEsResilienceTest {
   private static final Byteman byteman;
 
   static {
-    byteman = new Byteman(newOrchestratorBuilder(), WEB);
-    orchestrator = byteman
-      .getOrchestratorBuilder()
-      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-      .addPlugin(ItUtils.xooPlugin())
-      .build();
+    byteman = new Byteman();
+    orchestrator = newOrchestratorBuilder(
+      builder -> {
+        byteman.install(builder, WEB);
+        builder
+          .setServerProperty("sonar.search.recovery.delayInMs", "1000")
+          .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+          .addPlugin(ItUtils.xooPlugin());
+      });
   }
 
   @Before
index db88a57a092a2ada920dbc000aba42d0c0be8d22..7508cdd8a3764a4f2c5696b2702f92dbc1e9ce5c 100644 (file)
@@ -61,9 +61,9 @@ public class RuleReKeyingTest {
 
   @Test
   public void rules_are_re_keyed_when_upgrading_and_downgrading_plugin() {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("foo-plugin-v1"))
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("foo-plugin-v1")));
     orchestrator.start();
 
     tester = new Tester(orchestrator);
index 5a9c01d65fee1c36923cc1dc8c83c25dcbc7e210..041bc71e12868d71cec7810ca94dbbdc2fb716b7 100644 (file)
@@ -69,10 +69,10 @@ public class BlueGreenTest {
 
   @Test
   public void upgrade_analyzer_when_analysis_is_pending_in_compute_engine_queue() throws Exception {
-    orchestrator = newOrchestratorBuilder()
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
       .addPlugin(pluginArtifact("blue-green-plugin-v1"))
-      .addPlugin(xooPlugin())
-      .build();
+      .addPlugin(xooPlugin()));
     tester = new Tester(orchestrator).disableOrganizations();
     orchestrator.start();
     tester.before();
index 532925b7c503d70ad6c91f75b106fa44f6bec028..52d45e8193314ec98e4130d2bc918fd7fc3cb473 100644 (file)
@@ -64,9 +64,9 @@ public class RestartTest {
   public void restart_in_prod_mode_requires_sysadmin_permission_and_restarts() throws Exception {
     // server classloader locks Jar files on Windows
     if (!SystemUtils.IS_OS_WINDOWS) {
-      orchestrator = newOrchestratorBuilder()
-        .setOrchestratorProperty("orchestrator.keepWorkspace", "true")
-        .build();
+      orchestrator = newOrchestratorBuilder(
+        builder -> builder
+          .setOrchestratorProperty("orchestrator.keepWorkspace", "true"));
       orchestrator.start();
 
       verifyFailWith403(() -> newWsClient(orchestrator).system().restart());
index ed4fd75d91489282e1e412c5e3f98ab1618e5673..593a06215e30cd1ac6600d0ffc8b89e284fd68fc 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonarqube.tests.serverSystem;
 
 import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.locator.FileLocation;
 import java.io.File;
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
@@ -32,6 +31,7 @@ import util.ItUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
+import static util.ItUtils.locationOf;
 import static util.ItUtils.newAdminWsClient;
 import static util.ItUtils.newOrchestratorBuilder;
 
@@ -58,9 +58,9 @@ public class ServerSystemRestartingOrchestrator {
   @Test
   public void check_minimal_sonar_version_at_startup() throws Exception {
     try {
-      orchestrator = newOrchestratorBuilder()
-        .addPlugin(FileLocation.of(new File(ServerSystemRestartingOrchestrator.class.getResource("/serverSystem/ServerSystemTest/incompatible-plugin-1.0.jar").toURI())))
-        .build();
+      orchestrator = newOrchestratorBuilder(
+        builder -> builder
+          .addPlugin(locationOf(ServerSystemRestartingOrchestrator.class.getResource("/serverSystem/ServerSystemTest/incompatible-plugin-1.0.jar"))));
       orchestrator.start();
       fail();
     } catch (Exception e) {
@@ -73,9 +73,9 @@ public class ServerSystemRestartingOrchestrator {
   public void support_install_dir_with_whitespaces() throws Exception {
     String dirName = "build/distributions/has space";
     FileUtils.deleteDirectory(new File(dirName));
-    orchestrator = newOrchestratorBuilder()
-      .setOrchestratorProperty("orchestrator.workspaceDir", dirName)
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .setOrchestratorProperty("orchestrator.workspaceDir", dirName));
     orchestrator.start();
 
     assertThat(newAdminWsClient(orchestrator).system().status().getStatus()).isEqualTo(System.Status.UP);
@@ -84,10 +84,10 @@ public class ServerSystemRestartingOrchestrator {
   // SONAR-4748
   @Test
   public void should_create_in_temp_folder() throws Exception {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(ItUtils.pluginArtifact("server-plugin"))
-      .setServerProperty("sonar.createTempFiles", "true")
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(ItUtils.pluginArtifact("server-plugin"))
+        .setServerProperty("sonar.createTempFiles", "true"));
     orchestrator.start();
 
     File tempDir = new File(orchestrator.getServer().getHome(), "temp/tmp");
index 7a2ee2e42a5577cf2e7f052cef484c25198aaabb..14cf8137b5fccbba8e42e5ee11e0d96ca4f85cee 100644 (file)
@@ -129,13 +129,13 @@ public class SystemStateTest {
 
     void start(Lock lock) {
       checkState(orchestrator == null);
-      orchestrator = newOrchestratorBuilder()
-        .addPlugin(pluginArtifact("server-plugin"))
-        .setServerProperty("sonar.web.startupLock.path", lock.webFile.getAbsolutePath())
-        .setServerProperty("sonar.ce.startupLock.path", lock.ceFile.getAbsolutePath())
-        .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
-        .setServerProperty("sonar.web.systemPasscode", systemPassCode)
-        .build();
+      orchestrator = newOrchestratorBuilder(
+        builder -> builder
+          .addPlugin(pluginArtifact("server-plugin"))
+          .setServerProperty("sonar.web.startupLock.path", lock.webFile.getAbsolutePath())
+          .setServerProperty("sonar.ce.startupLock.path", lock.ceFile.getAbsolutePath())
+          .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
+          .setServerProperty("sonar.web.systemPasscode", systemPassCode));
       elasticsearch = new Elasticsearch(esHttpPort);
 
       starter = new Thread(orchestrator::start);
index 0b73df2a4367fd12bac529646cf604717870acb6..d987479b1d0947dfd99b68447dc4bab45a6ac72c 100644 (file)
@@ -34,10 +34,8 @@ import static util.ItUtils.xooPlugin;
 public class SettingsSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder()
-
-    .addPlugin(xooPlugin())
-
-    .build();
+  public static final Orchestrator ORCHESTRATOR = ItUtils.newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin()));
 
 }
index 1c4f5a88e3eb6b1c3db60b4128ef1bdc7771a7af..5360e463b55a2f456bf5eb66e74e80fb044f542b 100644 (file)
@@ -60,11 +60,11 @@ public class SettingsTestRestartingOrchestrator {
   @Test
   public void test_settings() {
     URL secretKeyUrl = getClass().getResource("/settings/SettingsTest/sonar-secret.txt");
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(pluginArtifact("settings-plugin"))
-      .addPlugin(pluginArtifact("license-plugin"))
-      .setServerProperty("sonar.secretKeyPath", secretKeyUrl.getFile())
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(pluginArtifact("settings-plugin"))
+        .addPlugin(pluginArtifact("license-plugin"))
+        .setServerProperty("sonar.secretKeyPath", secretKeyUrl.getFile()));
     startOrchestrator();
 
     String adminUser = userRule.createAdminUser();
@@ -86,11 +86,11 @@ public class SettingsTestRestartingOrchestrator {
 
   @Test
   public void property_relocation() {
-    orchestrator = newOrchestratorBuilder()
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
       .addPlugin(pluginArtifact("property-relocation-plugin"))
       .addPlugin(xooPlugin())
-      .setServerProperty("sonar.deprecatedKey", "true")
-      .build();
+      .setServerProperty("sonar.deprecatedKey", "true"));
     startOrchestrator();
 
     SonarScanner withDeprecatedKey = SonarScanner.create(projectDir("shared/xoo-sample"))
index 11b0f7f8a6d12e76f7d8b3a29d2822ba766fdf00..075ffdf6d64c2b50e26748d43b4e007f68556f46 100644 (file)
@@ -39,9 +39,9 @@ import static util.ItUtils.xooPlugin;
 public class SourceSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-    .addPlugin(MavenLocation.of("org.sonarsource.scm.git", "sonar-scm-git-plugin", "LATEST_RELEASE"))
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      .addPlugin(MavenLocation.of("org.sonarsource.scm.git", "sonar-scm-git-plugin", "LATEST_RELEASE")));
 
 }
index f654949bd266f75dcad91fbe3a0de2720b5b98f5..47a5eb16fe6614505c1176991bc20dc091b4b447 100644 (file)
@@ -50,8 +50,8 @@ public class StartupIndexationTest {
   @Test
   public void elasticsearch_error_at_startup_must_shutdown_node() throws Exception {
     try (SonarQube sonarQube = new SonarQube();
-         LogsTailer.Watch failedInitialization = sonarQube.logsTailer.watch("Background initialization failed. Stopping SonarQube");
-         LogsTailer.Watch stopWatcher = sonarQube.logsTailer.watch("SonarQube is stopped")) {
+      LogsTailer.Watch failedInitialization = sonarQube.logsTailer.watch("Background initialization failed. Stopping SonarQube");
+      LogsTailer.Watch stopWatcher = sonarQube.logsTailer.watch("SonarQube is stopped")) {
       sonarQube.lockAllElasticsearchWrites();
       sonarQube.resume();
       stopWatcher.waitForLog(10, TimeUnit.SECONDS);
@@ -61,7 +61,7 @@ public class StartupIndexationTest {
 
     // Restarting is recreating the indexes
     try (SonarQube sonarQube = new SonarQube();
-         LogsTailer.Watch sonarQubeIsUpWatcher = sonarQube.logsTailer.watch("SonarQube is up")) {
+      LogsTailer.Watch sonarQubeIsUpWatcher = sonarQube.logsTailer.watch("SonarQube is up")) {
       sonarQube.resume();
       sonarQubeIsUpWatcher.waitForLog(20, TimeUnit.SECONDS);
       SearchRequest searchRequest = new SearchRequest().setQ("admin");
@@ -82,12 +82,12 @@ public class StartupIndexationTest {
       pauseFile = temp.newFile();
       FileUtils.touch(pauseFile);
 
-      orchestrator = newOrchestratorBuilder()
-        .setServerProperty("sonar.web.pause.path", pauseFile.getAbsolutePath())
-        .addPlugin(pluginArtifact("wait-at-platform-level4-plugin"))
-        .setStartupLogWatcher(l -> l.contains("PlatformLevel4 initialization phase is paused"))
-        .setServerProperty("sonar.search.httpPort", "" + esHttpPort)
-        .build();
+      orchestrator = newOrchestratorBuilder(
+        builder -> builder
+          .setServerProperty("sonar.web.pause.path", pauseFile.getAbsolutePath())
+          .addPlugin(pluginArtifact("wait-at-platform-level4-plugin"))
+          .setStartupLogWatcher(l -> l.contains("PlatformLevel4 initialization phase is paused"))
+          .setServerProperty("sonar.search.httpPort", "" + esHttpPort));
 
       tester = new Tester(orchestrator);
       orchestrator.start();
index a827baa6282e20a17ad17a43a2cbc64691ad2981..120e4e55f3da89ebb57c2e2e0c68b5fafc9e800d 100644 (file)
@@ -39,12 +39,12 @@ public class TelemetryOptOutTest {
 
   public static MockWebServer server = new MockWebServer();
 
-  private static Orchestrator orchestrator = newOrchestratorBuilder()
+  private static Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
     .addPlugin(xooPlugin())
     .setServerProperty("sonar.telemetry.enable", "false")
     .setServerProperty("sonar.telemetry.url", server.url("").toString())
-    .setServerProperty("sonar.telemetry.frequencyInSeconds", "1")
-    .build();
+    .setServerProperty("sonar.telemetry.frequencyInSeconds", "1"));
   private static Tester tester = new Tester(orchestrator);
 
   @ClassRule
index 5257a8847cf6f8d45852a7f0232213f07b38b691..56790db2bdb7019022ec406cf395a47c8eef92be 100644 (file)
@@ -61,13 +61,14 @@ public class TelemetryUploadTest {
   @Test
   public void sent_telemetry_data() throws Exception {
     telemetryServer.enqueue(new MockResponse().setResponseCode(200));
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(xooPlugin())
-      .setServerProperty("sonar.telemetry.url", telemetryServer.url("").toString())
-      // increase frequency so that payload is sent quickly after startup
-      .setServerProperty("sonar.telemetry.frequencyInSeconds", "1")
-      //.setServerProperty("sonar.web.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8001")
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(xooPlugin())
+        .setServerProperty("sonar.telemetry.url", telemetryServer.url("").toString())
+        // increase frequency so that payload is sent quickly after startup
+        .setServerProperty("sonar.telemetry.frequencyInSeconds", "1")
+    // .setServerProperty("sonar.web.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8001")
+    );
     orchestrator.start();
     // Consume request to no block the telemetry daemon
     telemetryServer.takeRequest();
@@ -104,10 +105,10 @@ public class TelemetryUploadTest {
 
   @Test
   public void does_not_send_telemetry_data_right_away_by_Default() {
-    orchestrator = newOrchestratorBuilder()
-      .addPlugin(xooPlugin())
-      .setServerProperty("sonar.telemetry.url", telemetryServer.url("").toString())
-      .build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .addPlugin(xooPlugin())
+        .setServerProperty("sonar.telemetry.url", telemetryServer.url("").toString()));
     // by default telemetry payload is sent 6 hours after startup, once a week
     orchestrator.start();
 
@@ -127,7 +128,7 @@ public class TelemetryUploadTest {
     return (int) Math.round(value);
   }
 
-  private void resetTelemetryLastPing(){
+  private void resetTelemetryLastPing() {
     try (PreparedStatement preparedStatement = orchestrator.getDatabase().openConnection().prepareStatement("delete from internal_properties where kee='telemetry.lastPing'");) {
       preparedStatement.execute();
       preparedStatement.close();
index 9afbbfa2de97ac12dfba45f67f04ed26b61b57be..e4177ca8ab15a4e70c5269177477b7051bcaf2e2 100644 (file)
@@ -37,9 +37,8 @@ import static util.ItUtils.xooPlugin;
 public class TestSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin()));
 
 }
index e35917afc6949bbdfd622f536011778e80a3e12f..31338ac30310b5a0a10bcf9a540c017479bcad49 100644 (file)
@@ -37,11 +37,9 @@ import static util.ItUtils.xooPlugin;
 public class UiSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
-
-    // Used in UiExtensionsTest
-    .addPlugin(pluginArtifact("ui-extensions-plugin"))
-
-    .build();
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
+      // Used in UiExtensionsTest
+      .addPlugin(pluginArtifact("ui-extensions-plugin")));
 }
index 8f8977c47071536fb063a1a9a50acee2decd715d..2ec884365d3ba456f5266948c38623f085e2e36c 100644 (file)
@@ -156,11 +156,11 @@ public class UpgradeTest {
   }
 
   private void startAndUpgradeDevServer() {
-    OrchestratorBuilder builder = newOrchestratorBuilder()
-      .setOrchestratorProperty("orchestrator.keepDatabase", "true")
-      .keepBundledPlugins()
-      .setStartupLogWatcher(log -> log.contains("Database must be upgraded"));
-    orchestrator = builder.build();
+    orchestrator = newOrchestratorBuilder(
+      builder -> builder
+        .setOrchestratorProperty("orchestrator.keepDatabase", "true")
+        .keepBundledPlugins()
+        .setStartupLogWatcher(log -> log.contains("Database must be upgraded")));
     orchestrator.start();
     initSelenide(orchestrator);
 
index 300c60c0f603ffb062ffd2e75bcde947ef25983d..61659c545d57b06d02372c5f88b45c3e49c7d4c4 100644 (file)
@@ -55,13 +55,13 @@ public class HttpHeadersAuthenticationTest {
   private static final String GROUPS_HEADER = "H-Groups";
 
   @ClassRule
-  public static final Orchestrator orchestrator = newOrchestratorBuilder()
-    .setServerProperty("sonar.web.sso.enable", "true")
-    .setServerProperty("sonar.web.sso.loginHeader", LOGIN_HEADER)
-    .setServerProperty("sonar.web.sso.nameHeader", NAME_HEADER)
-    .setServerProperty("sonar.web.sso.emailHeader", EMAIL_HEADER)
-    .setServerProperty("sonar.web.sso.groupsHeader", GROUPS_HEADER)
-    .build();
+  public static final Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
+      .setServerProperty("sonar.web.sso.enable", "true")
+      .setServerProperty("sonar.web.sso.loginHeader", LOGIN_HEADER)
+      .setServerProperty("sonar.web.sso.nameHeader", NAME_HEADER)
+      .setServerProperty("sonar.web.sso.emailHeader", EMAIL_HEADER)
+      .setServerProperty("sonar.web.sso.groupsHeader", GROUPS_HEADER));
 
   @Rule
   public Tester tester = new Tester(orchestrator).disableOrganizations();
index 440e0d4bba6ef81b9b5e73c7611fb5f934d96b9c..515f813f2de716b3cb70b7eb7cc1182876a3d760 100644 (file)
@@ -37,7 +37,7 @@ public class OnboardingTest {
   private static final String ONBOARDING_TUTORIAL_SHOW_TO_NEW_USERS = "sonar.onboardingTutorial.showToNewUsers";
 
   @ClassRule
-  public static final Orchestrator orchestrator = newOrchestratorBuilder().build();
+  public static final Orchestrator orchestrator = newOrchestratorBuilder();
 
   @Rule
   public Tester tester = new Tester(orchestrator).disableOrganizations();
index e34e637116838b35bac04c9701275e348e959fd9..45f5c23eb97c8d622a7faabf0f4717675ab0a9d8 100644 (file)
@@ -57,10 +57,10 @@ public class RealmAuthenticationTest {
   public ExpectedException thrown = ExpectedException.none();
 
   @ClassRule
-  public static final Orchestrator orchestrator = newOrchestratorBuilder()
-    .addPlugin(pluginArtifact("security-plugin"))
-    .setServerProperty("sonar.security.realm", "FakeRealm")
-    .build();
+  public static final Orchestrator orchestrator = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(pluginArtifact("security-plugin"))
+      .setServerProperty("sonar.security.realm", "FakeRealm"));
 
   @Rule
   public Tester tester = new Tester(orchestrator).disableOrganizations();
index fa2d492d6ee2212afb3ff9aa37709a8e0c13223f..45c3e1436cd5bd3318b385b20ed86b9e803e2ece 100644 (file)
@@ -40,21 +40,22 @@ import static util.ItUtils.xooPlugin;
 public class SonarCloudUserSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    // Used by OrganizationBaseIdentityProviderTest
-    .addPlugin(pluginArtifact("base-auth-plugin"))
+      // Used by OrganizationBaseIdentityProviderTest
+      .addPlugin(pluginArtifact("base-auth-plugin"))
 
-    // Used in OrganizationOAuth2IdentityProviderTest
-    .addPlugin(pluginArtifact("oauth2-auth-plugin"))
+      // Used in OrganizationOAuth2IdentityProviderTest
+      .addPlugin(pluginArtifact("oauth2-auth-plugin"))
 
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
-    .setServerProperty("sonar.organizations.createPersonalOrg", "true")
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
+      .setServerProperty("sonar.organizations.createPersonalOrg", "true")
 
-    // reduce memory for Elasticsearch
-    .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+      // reduce memory for Elasticsearch
+      .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
 
-    .build();
+  );
 
 }
index 92ff670f0e3d464336c992e286a8e53617cb12ea..c0205324ebf254beb696389c8894e6396be816d4 100644 (file)
@@ -48,13 +48,15 @@ public class UserEsResilienceTest {
   private static final Byteman byteman;
 
   static {
-    byteman = new Byteman(newOrchestratorBuilder(), WEB);
-    orchestrator = byteman
-      .getOrchestratorBuilder()
-      .setServerProperty("sonar.search.recovery.delayInMs", "1000")
-      .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
-      .addPlugin(ItUtils.xooPlugin())
-      .build();
+    byteman = new Byteman();
+    orchestrator = newOrchestratorBuilder(
+      builder -> {
+        byteman.install(builder, WEB);
+        builder
+          .setServerProperty("sonar.search.recovery.delayInMs", "1000")
+          .setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+          .addPlugin(ItUtils.xooPlugin());
+      });
   }
 
   @Before
index e4e1b1c94f8fe8e8bda988449655e7a5df0f3bee..8e07ffe84048675f73a34bdc0933ee035219e775 100644 (file)
@@ -46,18 +46,19 @@ import static util.ItUtils.xooPlugin;
 public class UserSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    // Used in BaseIdentityProviderTest
-    .addPlugin(pluginArtifact("base-auth-plugin"))
+      // Used in BaseIdentityProviderTest
+      .addPlugin(pluginArtifact("base-auth-plugin"))
 
-    // Used in OAuth2IdentityProviderTest
-    .addPlugin(pluginArtifact("oauth2-auth-plugin"))
+      // Used in OAuth2IdentityProviderTest
+      .addPlugin(pluginArtifact("oauth2-auth-plugin"))
 
-    // reduce memory for Elasticsearch
-    .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+      // reduce memory for Elasticsearch
+      .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
 
-    .build();
+  );
 
 }
index 8e8d0023081a1f9179717afc5fa3d5b051ca1e90..ae1048dc5eb24603132be8f3f30ac18c78ce956f 100644 (file)
@@ -35,13 +35,13 @@ import static util.ItUtils.xooPlugin;
 public class WebhooksSuite {
 
   @ClassRule
-  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
-    .addPlugin(xooPlugin())
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
+    builder -> builder
+      .addPlugin(xooPlugin())
 
-    // reduce memory for Elasticsearch
-    .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+      // reduce memory for Elasticsearch
+      .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
 
-    .setServerProperty("sonar.sonarcloud.enabled", "true")
-
-    .build();
+      .setServerProperty("sonar.sonarcloud.enabled", "true")
+  );
 }
index d7451c66776c437cdca120a274d1dd032e7e4560..6daaeefcfd6851b3908e53af56ad582102372bb3 100644 (file)
@@ -44,6 +44,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -99,9 +100,22 @@ public class ItUtils {
   private ItUtils() {
   }
 
-  public static OrchestratorBuilder newOrchestratorBuilder() {
-    OrchestratorBuilder builder = Orchestrator.builderEnv();
-    builder.setEdition(COMMUNITY);
+  public static Orchestrator newOrchestratorBuilder() {
+    return newOrchestratorBuilder(t -> {}, server -> {});
+  }
+
+  public static Orchestrator newOrchestratorBuilder(Consumer<OrchestratorBuilder> beforeInstall) {
+    return newOrchestratorBuilder(beforeInstall, server -> {
+    });
+  }
+
+  public static Orchestrator newOrchestratorBuilder(Consumer<OrchestratorBuilder> beforeInstall, Consumer<Server> afterInstall) {
+    OrchestratorBuilder builder = Orchestrator.builderEnv()
+      .setEdition(COMMUNITY)
+      // reduce memory for Elasticsearch
+      .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+      .setOrchestratorProperty("orchestrator.workspaceDir", "build/it");
+
     String version = System.getProperty("sonar.runtimeVersion");
     if (StringUtils.isEmpty(version)) {
       Location zip = FileLocation.byWildcardMavenFilename(new File("../sonar-application/build/distributions"), "sonar-application-*.zip");
@@ -109,10 +123,33 @@ public class ItUtils {
     } else {
       builder.setSonarVersion(version);
     }
-    return builder
-      // reduce memory for Elasticsearch
-      .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
-      .setOrchestratorProperty("orchestrator.workspaceDir", "build/it");
+
+    beforeInstall.accept(builder);
+
+    Orchestrator orchestrator = builder.build();
+
+    Server server = orchestrator.install();
+    afterInstall.accept(server);
+
+    return orchestrator;
+  }
+
+  public static void installCoreExtension(Server server, String coreExtensionDirName) {
+    File coreExtensionFile = pluginArtifact(coreExtensionDirName).getFile();
+    File libDir = new File(server.getHome(), "lib/common");
+    try {
+      FileUtils.copyFile(coreExtensionFile, new File(libDir, coreExtensionFile.getName()));
+    } catch (IOException e) {
+      throw new IllegalStateException("Failed to install core extension", e);
+    }
+  }
+
+  public static Location locationOf(URL url) {
+    try {
+      return FileLocation.of(new File(url.toURI()));
+    } catch (URISyntaxException e) {
+      throw new IllegalStateException("File does not exist", e);
+    }
   }
 
   public static FileLocation xooPlugin() {