diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-10-28 18:04:29 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-10-30 11:25:31 +0100 |
commit | bb5e1718510207c0b3b2159fca12a5867a5e4603 (patch) | |
tree | e470d24f9d2312f531166df557cf67a80bae31b6 /it | |
parent | 86b031b91a3e6f96bb919666aa36ed85bd4af4e7 (diff) | |
download | sonarqube-bb5e1718510207c0b3b2159fca12a5867a5e4603.tar.gz sonarqube-bb5e1718510207c0b3b2159fca12a5867a5e4603.zip |
SONAR-6355 Fix IT
Diffstat (limited to 'it')
10 files changed, 319 insertions, 183 deletions
diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java index 8c4aca7b0ba..6cb1b658a8a 100644 --- a/it/it-tests/src/test/java/it/Category1Suite.java +++ b/it/it-tests/src/test/java/it/Category1Suite.java @@ -51,6 +51,7 @@ import it.projectAdministration.BulkDeletionTest; import it.projectAdministration.ProjectAdministrationTest; import it.qualityGate.QualityGateNotificationTest; import it.qualityGate.QualityGateTest; +import it.qualityGate.QualityGateUiTest; import it.settings.PropertySetsTest; import it.settings.SettingsTest; import it.settings.SettingsTestRestartingOrchestrator; @@ -76,6 +77,7 @@ import static util.ItUtils.xooPlugin; I18nTest.class, // quality gate QualityGateTest.class, + QualityGateUiTest.class, QualityGateNotificationTest.class, // permission IssuePermissionTest.class, diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java index d59e2e4d154..b943c962b54 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java @@ -35,11 +35,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.wsclient.SonarClient; import org.sonar.wsclient.base.HttpException; -import org.sonar.wsclient.qualitygate.NewCondition; -import org.sonar.wsclient.qualitygate.QualityGate; -import org.sonar.wsclient.qualitygate.QualityGateClient; -import org.sonar.wsclient.qualitygate.QualityGateCondition; -import org.sonar.wsclient.qualitygate.UpdateCondition; import org.sonar.wsclient.services.PropertyQuery; import org.sonar.wsclient.services.ResourceQuery; import org.sonar.wsclient.user.UserParameters; @@ -162,59 +157,6 @@ public class ProjectAdministrationTest { assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(7); } - // SONAR-3326 - // TODO should be moved to qualityGate - @Test - public void display_alerts_correctly_in_history_page() { - QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient(); - QualityGate qGate = qgClient.create("AlertsForHistory"); - qgClient.setDefault(qGate.id()); - - // with this configuration, project should have an Orange alert - QualityGateCondition lowThresholds = qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("GT").warningThreshold("5").errorThreshold("50")); - scanSampleWithDate("2012-01-01"); - // with this configuration, project should have a Green alert - qgClient.updateCondition(UpdateCondition.create(lowThresholds.id()).metricKey("lines").operator("GT").warningThreshold("5000").errorThreshold("5000")); - scanSampleWithDate("2012-01-02"); - - Selenese selenese = Selenese.builder() - .setHtmlTestsInClasspath("display-alerts-history-page", - "/projectAdministration/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); - - qgClient.unsetDefault(); - qgClient.destroy(qGate.id()); - } - - /** - * SONAR-1352 - */ - // TODO should be moved to qualityGate - @Test - public void display_period_alert_on_project_dashboard() { - QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient(); - QualityGate qGate = qgClient.create("AlertsForDashboard"); - qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("LT").warningThreshold("0").errorThreshold("10") - .period(1)); - qgClient.setDefault(qGate.id()); - - // No alert - scanSampleWithDate("2012-01-01"); - - // Red alert because lines number has not changed since previous analysis - scanSample(); - - Selenese selenese = Selenese.builder() - .setHtmlTestsInClasspath("display-period-alerts", - "/projectAdministration/ProjectAdministrationTest/display-alerts/should-display-period-alerts-correctly.html" - ).build(); - new SeleneseTest(selenese).runOn(orchestrator); - - qgClient.unsetDefault(); - qgClient.destroy(qGate.id()); - } - /** * SONAR-3425 */ diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java index 74ca965d61b..94f1b365f3d 100644 --- a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java @@ -11,7 +11,9 @@ import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; import java.util.Iterator; import javax.mail.internet.MimeMessage; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.sonar.wsclient.Sonar; @@ -24,11 +26,13 @@ import org.sonar.wsclient.services.Resource; import org.sonar.wsclient.services.ResourceQuery; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; +import util.ItUtils; import util.NetworkUtils; import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; public class QualityGateNotificationTest { @@ -37,6 +41,18 @@ public class QualityGateNotificationTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + @BeforeClass + public static void initPeriods() throws Exception { + setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis"); + setServerProperty(orchestrator, "sonar.timemachine.period2", "30"); + setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version"); + } + + @AfterClass + public static void resetPeriods() throws Exception { + ItUtils.resetPeriods(orchestrator); + } + @Before public void cleanUp() { orchestrator.resetData(); @@ -57,8 +73,8 @@ public class QualityGateNotificationTest { Selenese selenese = Selenese .builder() .setHtmlTestsInClasspath("notifications", - "/qualitygate/notifications/email_configuration.html", - "/qualitygate/notifications/activate_notification_channels.html").build(); + "/qualityGate/notifications/email_configuration.html", + "/qualityGate/notifications/activate_notification_channels.html").build(); new SeleneseTest(selenese).runOn(orchestrator); // Create quality gate with conditions on variations diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java new file mode 100644 index 00000000000..94fc1646481 --- /dev/null +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java @@ -0,0 +1,136 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 it.qualityGate; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.selenium.Selenese; +import it.Category1Suite; +import javax.annotation.Nullable; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.qualitygate.NewCondition; +import org.sonar.wsclient.qualitygate.QualityGate; +import org.sonar.wsclient.qualitygate.QualityGateClient; +import org.sonar.wsclient.qualitygate.QualityGateCondition; +import org.sonar.wsclient.qualitygate.UpdateCondition; +import util.ItUtils; +import util.selenium.SeleneseTest; + +import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; + +public class QualityGateUiTest { + + @ClassRule + public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + + @BeforeClass + public static void initPeriods() throws Exception { + setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis"); + setServerProperty(orchestrator, "sonar.timemachine.period2", "30"); + setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version"); + } + + @AfterClass + public static void resetPeriods() throws Exception { + ItUtils.resetPeriods(orchestrator); + } + + @Before + public void cleanUp() { + orchestrator.resetData(); + } + + /** + * SONAR-3326 + */ + @Test + public void display_alerts_correctly_in_history_page() { + QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient(); + QualityGate qGate = qgClient.create("AlertsForHistory"); + qgClient.setDefault(qGate.id()); + + // with this configuration, project should have an Orange alert + QualityGateCondition lowThresholds = qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("GT").warningThreshold("5").errorThreshold("50")); + scanSampleWithDate("2012-01-01"); + // with this configuration, project should have a Green alert + qgClient.updateCondition(UpdateCondition.create(lowThresholds.id()).metricKey("lines").operator("GT").warningThreshold("5000").errorThreshold("5000")); + scanSampleWithDate("2012-01-02"); + + new SeleneseTest(Selenese.builder() + .setHtmlTestsInClasspath("display-alerts-history-page", + "/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html" + ).build()).runOn(orchestrator); + + qgClient.unsetDefault(); + qgClient.destroy(qGate.id()); + } + + /** + * SONAR-1352 + */ + @Test + public void display_period_alert_on_project_dashboard() { + QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient(); + QualityGate qGate = qgClient.create("AlertsForDashboard"); + qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("LT").warningThreshold("0").errorThreshold("10") + .period(1)); + qgClient.setDefault(qGate.id()); + + // No alert + scanSampleWithDate("2012-01-01"); + + // Red alert because lines number has not changed since previous analysis + scanSample(); + + new SeleneseTest(Selenese.builder() + .setHtmlTestsInClasspath("display-period-alerts", + "/qualityGate/QualityGateUiTest/should-display-period-alerts-correctly.html" + ).build()).runOn(orchestrator); + + qgClient.unsetDefault(); + qgClient.destroy(qGate.id()); + } + + private void scanSample() { + scanSample(null, null); + } + + private void scanSampleWithDate(String date) { + scanSample(date, null); + } + + private void scanSample(@Nullable String date, @Nullable String profile) { + SonarRunner scan = SonarRunner.create(projectDir("shared/xoo-sample")) + .setProperties("sonar.cpd.skip", "true"); + if (date != null) { + scan.setProperty("sonar.projectDate", date); + } + if (profile != null) { + scan.setProfile(profile); + } + orchestrator.executeBuild(scan); + } + +} diff --git a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html b/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html deleted file mode 100644 index 4d0d7ac99c6..00000000000 --- a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <title>should-display-alerts-correctly-history-page</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> - <thead> - <tr> - <td rowspan="1" colspan="3">should-display-alerts-correctly-history-page</td> - </tr> - </thead> - <tbody> - <tr> - <td>open</td> - <td>/sonar/sessions/login</td> - <td></td> - </tr> - <tr> - <td>type</td> - <td>login</td> - <td>admin</td> - </tr> - <tr> - <td>type</td> - <td>password</td> - <td>admin</td> - </tr> - <tr> - <td>clickAndWait</td> - <td>commit</td> - <td></td> - </tr> - <tr> - <td>open</td> - <td>/sonar/dashboard/index/sample</td> - <td></td> - </tr> - <tr> - <td>click</td> - <td>css=#context-navigation .navbar-admin-link</td> - <td></td> - </tr> - <tr> - <td>waitForElementPresent</td> - <td>link=History</td> - <td></td> - </tr> - <tr> - <td>clickAndWait</td> - <td>link=History</td> - <td></td> - </tr> - <tr> - <td>assertElementPresent</td> - <td>//img[@title='Quality Gate Status: Green (was Orange). ']</td> - <td></td> - </tr> - <tr> - <td>assertElementPresent</td> - <td>//img[@title='Quality Gate Status: Orange. Lines > 5']</td> - <td></td> - </tr> - </tbody> -</table> -</body> -</html> diff --git a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts/should-display-period-alerts-correctly.html b/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts/should-display-period-alerts-correctly.html deleted file mode 100644 index 9c4db5c8779..00000000000 --- a/it/it-tests/src/test/resources/projectAdministration/ProjectAdministrationTest/display-alerts/should-display-period-alerts-correctly.html +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <title>should-display-alerts-correctly-history-page</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> - <thead> - <tr> - <td rowspan="1" colspan="3">should-display-alerts-correctly-history-page</td> - </tr> - </thead> - <tbody> - <tr> - <td>open</td> - <td>/sonar/sessions/login</td> - <td></td> -</tr> -<tr> - <td>type</td> - <td>login</td> - <td>admin</td> -</tr> -<tr> - <td>type</td> - <td>password</td> - <td>admin</td> -</tr> -<tr> - <td>clickAndWait</td> - <td>commit</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/sonar/widget?id=alerts&resource=sample</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>class=alerts</td> - <td>glob:*Lines*0 < 10*since previous analysis*</td> -</tr> -<tr> - <td>assertText</td> - <td>class=alert_ERROR</td> - <td>0</td> -</tr> -</tbody> -</table> -</body> -</html> diff --git a/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html b/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html new file mode 100644 index 00000000000..42633d4b900 --- /dev/null +++ b/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ SonarQube, open source software quality management tool. + ~ Copyright (C) 2008-2014 SonarSource + ~ mailto:contact AT sonarsource DOT com + ~ + ~ SonarQube 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. + ~ + ~ SonarQube 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. + --> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-display-alerts-correctly-history-page</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-display-alerts-correctly-history-page</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/sessions/login</td> + <td></td> + </tr> + <tr> + <td>type</td> + <td>login</td> + <td>admin</td> + </tr> + <tr> + <td>type</td> + <td>password</td> + <td>admin</td> + </tr> + <tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> + </tr> + <tr> + <td>open</td> + <td>/sonar/dashboard/index/sample</td> + <td></td> + </tr> + <tr> + <td>click</td> + <td>css=#context-navigation .navbar-admin-link</td> + <td></td> + </tr> + <tr> + <td>waitForElementPresent</td> + <td>link=History</td> + <td></td> + </tr> + <tr> + <td>clickAndWait</td> + <td>link=History</td> + <td></td> + </tr> + <tr> + <td>assertElementPresent</td> + <td>//img[@title='Quality Gate Status: Green (was Orange). ']</td> + <td></td> + </tr> + <tr> + <td>assertElementPresent</td> + <td>//img[@title='Quality Gate Status: Orange. Lines > 5']</td> + <td></td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-period-alerts-correctly.html b/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-period-alerts-correctly.html new file mode 100644 index 00000000000..bf5cbf12acc --- /dev/null +++ b/it/it-tests/src/test/resources/qualityGate/QualityGateUiTest/should-display-period-alerts-correctly.html @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ SonarQube, open source software quality management tool. + ~ Copyright (C) 2008-2014 SonarSource + ~ mailto:contact AT sonarsource DOT com + ~ + ~ SonarQube 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. + ~ + ~ SonarQube 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. + --> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-display-alerts-correctly-history-page</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-display-alerts-correctly-history-page</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/sessions/login</td> + <td></td> + </tr> + <tr> + <td>type</td> + <td>login</td> + <td>admin</td> + </tr> + <tr> + <td>type</td> + <td>password</td> + <td>admin</td> + </tr> + <tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> + </tr> + <tr> + <td>open</td> + <td>/sonar/widget?id=alerts&resource=sample</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>class=alerts</td> + <td>glob:*Lines*0 < 10*since previous analysis*</td> + </tr> + <tr> + <td>assertText</td> + <td>class=alert_ERROR</td> + <td>0</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/qualitygate/notifications/activate_notification_channels.html b/it/it-tests/src/test/resources/qualityGate/notifications/activate_notification_channels.html index ce8cfc27691..ce8cfc27691 100644 --- a/it/it-tests/src/test/resources/qualitygate/notifications/activate_notification_channels.html +++ b/it/it-tests/src/test/resources/qualityGate/notifications/activate_notification_channels.html diff --git a/it/it-tests/src/test/resources/qualitygate/notifications/email_configuration.html b/it/it-tests/src/test/resources/qualityGate/notifications/email_configuration.html index 67b10d78c2f..67b10d78c2f 100644 --- a/it/it-tests/src/test/resources/qualitygate/notifications/email_configuration.html +++ b/it/it-tests/src/test/resources/qualityGate/notifications/email_configuration.html |