You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IssuesModeTest.java 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2016 SonarSource SA
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonarsource.sonarqube.perf.scanner.suite;
  21. import com.sonar.orchestrator.Orchestrator;
  22. import com.sonar.orchestrator.build.SonarRunner;
  23. import org.sonarsource.sonarqube.perf.PerfRule;
  24. import org.sonarsource.sonarqube.perf.PerfTestCase;
  25. import java.io.File;
  26. import java.io.IOException;
  27. import org.junit.Before;
  28. import org.junit.ClassRule;
  29. import org.junit.Rule;
  30. import org.junit.Test;
  31. import org.junit.rules.TemporaryFolder;
  32. public class IssuesModeTest extends PerfTestCase {
  33. @ClassRule
  34. public static Orchestrator orchestrator = ScannerPerfTestSuite.ORCHESTRATOR;
  35. @ClassRule
  36. public static TemporaryFolder temp = new TemporaryFolder();
  37. @Rule
  38. public PerfRule perfRule = new PerfRule(4) {
  39. @Override
  40. protected void beforeEachRun() {
  41. orchestrator.resetData();
  42. }
  43. };
  44. @Before
  45. public void cleanDatabase() {
  46. orchestrator.resetData();
  47. }
  48. @Test
  49. public void issues_mode_scan_xoo_project() throws IOException {
  50. File userHome = temp.newFolder();
  51. orchestrator.getServer().provisionProject("sample", "xoo-sample");
  52. orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-xoo-issue-per-line");
  53. SonarRunner runner = newScanner(
  54. "-Xmx512m -server -XX:MaxPermSize=64m",
  55. "sonar.analysis.mode", "issues",
  56. "sonar.userHome", userHome.getAbsolutePath(),
  57. "sonar.showProfiling", "true");
  58. long start = System.currentTimeMillis();
  59. orchestrator.executeBuild(runner);
  60. long duration = System.currentTimeMillis() - start;
  61. System.out.println("Issues analysis: " + duration + "ms");
  62. perfRule.assertDurationAround(duration, 4450L);
  63. }
  64. @Test
  65. public void issues_mode_with_cache_scan_xoo_project() throws IOException {
  66. File userHome = temp.newFolder();
  67. orchestrator.getServer().provisionProject("sample", "xoo-sample");
  68. orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-xoo-issue-per-line");
  69. SonarRunner runner = newScanner(
  70. "-Xmx512m -server -XX:MaxPermSize=64m",
  71. "sonar.analysis.mode", "issues",
  72. "sonar.useWsCache", "true",
  73. "sonar.userHome", userHome.getAbsolutePath(),
  74. "sonar.showProfiling", "true");
  75. long start = System.currentTimeMillis();
  76. orchestrator.executeBuild(runner);
  77. long firstDuration = System.currentTimeMillis() - start;
  78. System.out.println("First issues analysis: " + firstDuration + "ms");
  79. // caches are warmed
  80. start = System.currentTimeMillis();
  81. orchestrator.executeBuild(runner);
  82. long secondDuration = System.currentTimeMillis() - start;
  83. System.out.println("Second issues analysis: " + secondDuration + "ms");
  84. perfRule.assertDurationAround(secondDuration, 3350L);
  85. }
  86. }