diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-09 18:14:31 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-18 23:48:48 +0200 |
commit | 024672b883d5b81af0838106fe53df31365444f2 (patch) | |
tree | 0201950a25ec411bbcee9a87e4f21f9c021ae2d5 /sonar-db | |
parent | faf4df42facfd3175f4689f2ea3013e92bfe301e (diff) | |
download | sonarqube-024672b883d5b81af0838106fe53df31365444f2.tar.gz sonarqube-024672b883d5b81af0838106fe53df31365444f2.zip |
Replace table ANALYSIS_REPORTS by CE_QUEUE and CE_ACTIVITY
Diffstat (limited to 'sonar-db')
41 files changed, 1335 insertions, 844 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/Dao.java b/sonar-db/src/main/java/org/sonar/db/Dao.java index 99bd33d1eb5..adb259fbf70 100644 --- a/sonar-db/src/main/java/org/sonar/db/Dao.java +++ b/sonar-db/src/main/java/org/sonar/db/Dao.java @@ -19,5 +19,8 @@ */ package org.sonar.db; +/** + * All implementations must be declared in {@link DaoModule} + */ public interface Dao { } diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index dde96831544..38536bf226b 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -24,13 +24,14 @@ import com.google.common.collect.ImmutableList; import java.util.List; import org.sonar.core.platform.Module; import org.sonar.db.activity.ActivityDao; +import org.sonar.db.ce.CeActivityDao; +import org.sonar.db.ce.CeQueueDao; import org.sonar.db.component.ComponentDao; import org.sonar.db.component.ComponentLinkDao; import org.sonar.db.component.ResourceDao; import org.sonar.db.component.ResourceIndexDao; import org.sonar.db.component.ResourceKeyUpdaterDao; import org.sonar.db.component.SnapshotDao; -import org.sonar.db.compute.AnalysisReportDao; import org.sonar.db.dashboard.ActiveDashboardDao; import org.sonar.db.dashboard.DashboardDao; import org.sonar.db.dashboard.WidgetDao; @@ -74,9 +75,10 @@ public class DaoModule extends Module { ActionPlanStatsDao.class, ActiveDashboardDao.class, ActivityDao.class, - AnalysisReportDao.class, AuthorDao.class, AuthorizationDao.class, + CeActivityDao.class, + CeQueueDao.class, ComponentDao.class, ComponentLinkDao.class, CustomMeasureDao.class, diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index f6471e7388e..1759feb17be 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -23,13 +23,14 @@ import java.util.IdentityHashMap; import java.util.Map; import javax.annotation.Nullable; import org.sonar.db.activity.ActivityDao; +import org.sonar.db.ce.CeActivityDao; +import org.sonar.db.ce.CeQueueDao; import org.sonar.db.component.ComponentDao; import org.sonar.db.component.ComponentLinkDao; import org.sonar.db.component.ResourceDao; import org.sonar.db.component.ResourceIndexDao; import org.sonar.db.component.ResourceKeyUpdaterDao; import org.sonar.db.component.SnapshotDao; -import org.sonar.db.compute.AnalysisReportDao; import org.sonar.db.dashboard.ActiveDashboardDao; import org.sonar.db.dashboard.DashboardDao; import org.sonar.db.dashboard.WidgetDao; @@ -95,7 +96,8 @@ public class DbClient { private final IssueChangeDao issueChangeDao; private final ActionPlanDao actionPlanDao; private final ActionPlanStatsDao actionPlanStatsDao; - private final AnalysisReportDao analysisReportDao; + private final CeQueueDao ceQueueDao; + private final CeActivityDao ceActivityDao; private final DashboardDao dashboardDao; private final ActiveDashboardDao activeDashboardDao; private final WidgetDao widgetDao; @@ -148,7 +150,8 @@ public class DbClient { issueChangeDao = getDao(map, IssueChangeDao.class); actionPlanDao = getDao(map, ActionPlanDao.class); actionPlanStatsDao = getDao(map, ActionPlanStatsDao.class); - analysisReportDao = getDao(map, AnalysisReportDao.class); + ceQueueDao = getDao(map, CeQueueDao.class); + ceActivityDao = getDao(map, CeActivityDao.class); dashboardDao = getDao(map, DashboardDao.class); activeDashboardDao = getDao(map, ActiveDashboardDao.class); widgetDao = getDao(map, WidgetDao.class); @@ -280,8 +283,12 @@ public class DbClient { return actionPlanDao; } - public AnalysisReportDao analysisReportDao() { - return analysisReportDao; + public CeQueueDao ceQueueDao() { + return ceQueueDao; + } + + public CeActivityDao ceActivityDao() { + return ceActivityDao; } public DashboardDao dashboardDao() { diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index ea484ad78ef..5887b49c205 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -32,6 +32,8 @@ import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.sonar.api.utils.log.Loggers; import org.sonar.db.activity.ActivityDto; import org.sonar.db.activity.ActivityMapper; +import org.sonar.db.ce.CeActivityMapper; +import org.sonar.db.ce.CeQueueMapper; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentLinkDto; import org.sonar.db.component.ComponentLinkMapper; @@ -46,8 +48,6 @@ import org.sonar.db.component.SnapshotDto; import org.sonar.db.component.SnapshotMapper; import org.sonar.db.component.UuidWithProjectUuidDto; import org.sonar.db.component.ViewsSnapshotDto; -import org.sonar.db.compute.AnalysisReportDto; -import org.sonar.db.compute.AnalysisReportMapper; import org.sonar.db.dashboard.ActiveDashboardDto; import org.sonar.db.dashboard.ActiveDashboardMapper; import org.sonar.db.dashboard.DashboardDto; @@ -95,6 +95,7 @@ import org.sonar.db.permission.PermissionTemplateUserDto; import org.sonar.db.permission.UserWithPermissionDto; import org.sonar.db.property.PropertiesMapper; import org.sonar.db.property.PropertyDto; +import org.sonar.db.purge.IdUuidPair; import org.sonar.db.purge.PurgeMapper; import org.sonar.db.purge.PurgeableSnapshotDto; import org.sonar.db.qualitygate.ProjectQgateAssociationDto; @@ -204,7 +205,7 @@ public class MyBatis { confBuilder.loadAlias("ActiveRuleParam", ActiveRuleParamDto.class); confBuilder.loadAlias("RequirementMigration", RequirementMigrationDto.class); confBuilder.loadAlias("Activity", ActivityDto.class); - confBuilder.loadAlias("AnalysisReport", AnalysisReportDto.class); + confBuilder.loadAlias("IdUuidPair", IdUuidPair.class); confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class); confBuilder.loadAlias("UuidWithProjectUuid", UuidWithProjectUuidDto.class); confBuilder.loadAlias("Event", EventDto.class); @@ -230,7 +231,7 @@ public class MyBatis { GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class, MeasureMapper.class, MetricMapper.class, CustomMeasureMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class, ProjectQgateAssociationMapper.class, EventMapper.class, - AnalysisReportMapper.class, ComponentLinkMapper.class, + CeQueueMapper.class, CeActivityMapper.class, ComponentLinkMapper.class, Migration45Mapper.class, Migration50Mapper.class }; confBuilder.loadMappers(mappers); diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java new file mode 100644 index 00000000000..59b59d6e87a --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java @@ -0,0 +1,65 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Optional; +import java.util.List; +import org.apache.ibatis.session.RowBounds; +import org.sonar.api.utils.System2; +import org.sonar.db.Dao; +import org.sonar.db.DbSession; + +public class CeActivityDao implements Dao { + + private final System2 system2; + + public CeActivityDao(System2 system2) { + this.system2 = system2; + } + + public Optional<CeActivityDto> selectByUuid(DbSession dbSession, String uuid) { + return Optional.fromNullable(mapper(dbSession).selectByUuid(uuid)); + } + + public void insert(DbSession dbSession, CeActivityDto dto) { + dto.setCreatedAt(system2.now()); + dto.setUpdatedAt(system2.now()); + dto.setIsLast(false); + mapper(dbSession).insert(dto); + + List<String> uuids = mapper(dbSession).selectUuidsOfRecentlyCreatedByIsLastKey(dto.getIsLastKey(), new RowBounds(0, 1)); + // should never be empty, as a row was just inserted! + if (!uuids.isEmpty()) { + mapper(dbSession).updateIsLastToFalseForLastKey(dto.getIsLastKey(), dto.getUpdatedAt()); + mapper(dbSession).updateIsLastToTrueForUuid(uuids.get(0), dto.getUpdatedAt()); + } + } + + /** + * Ordered by id asc -> oldest to newest + */ + public List<CeActivityDto> selectByQuery(DbSession dbSession, CeActivityQuery query, RowBounds rowBounds) { + return mapper(dbSession).selectByQuery(query, rowBounds); + } + + private CeActivityMapper mapper(DbSession dbSession) { + return dbSession.getMapper(CeActivityMapper.class); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDto.java b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDto.java new file mode 100644 index 00000000000..db2f1a10c39 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDto.java @@ -0,0 +1,186 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Objects; +import com.google.common.base.Strings; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkArgument; +import static java.lang.String.format; + +public class CeActivityDto { + + public enum Status { + SUCCESS, FAILED, CANCELED + } + + private String uuid; + private String componentUuid; + private Status status; + private String taskType; + private boolean isLast; + private String isLastKey; + private String submitterLogin; + private long submittedAt; + private Long startedAt; + private Long finishedAt; + private long createdAt; + private long updatedAt; + private Long executionTimeMs; + + CeActivityDto() { + // required for MyBatis + } + + public CeActivityDto(CeQueueDto queueDto) { + this.uuid = queueDto.getUuid(); + this.taskType = queueDto.getTaskType(); + this.componentUuid = queueDto.getComponentUuid(); + this.isLastKey = format("%s%s", taskType, Strings.nullToEmpty(componentUuid)); + this.submitterLogin = queueDto.getSubmitterLogin(); + this.submittedAt = queueDto.getCreatedAt(); + this.startedAt = queueDto.getStartedAt(); + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String s) { + checkArgument(s.length() <= 40, "Value is too long for column CE_ACTIVITY.UUID: %s", s); + this.uuid = s; + } + + public String getTaskType() { + return taskType; + } + + public void setTaskType(String s) { + this.taskType = s; + } + + @CheckForNull + public String getComponentUuid() { + return componentUuid; + } + + public void setComponentUuid(@Nullable String s) { + checkArgument(s == null || s.length() <= 40, "Value is too long for column CE_ACTIVITY.COMPONENT_UUID: %s", s); + this.componentUuid = s; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status s) { + this.status = s; + } + + public boolean getIsLast() { + return isLast; + } + + void setIsLast(boolean b) { + this.isLast = b; + } + + public String getIsLastKey() { + return isLastKey; + } + + @CheckForNull + public String getSubmitterLogin() { + return submitterLogin; + } + + public long getSubmittedAt() { + return submittedAt; + } + + public void setSubmittedAt(long submittedAt) { + this.submittedAt = submittedAt; + } + + @CheckForNull + public Long getStartedAt() { + return startedAt; + } + + public void setStartedAt(@Nullable Long l) { + this.startedAt = l; + } + + @CheckForNull + public Long getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(@Nullable Long l) { + this.finishedAt = l; + } + + public long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(long l) { + this.createdAt = l; + } + + public long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(long l) { + this.updatedAt = l; + } + + @CheckForNull + public Long getExecutionTimeMs() { + return executionTimeMs; + } + + public void setExecutionTimeMs(@Nullable Long l) { + checkArgument(l == null || l >= 0, "Execution time must be positive: %s", l); + this.executionTimeMs = l; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("uuid", uuid) + .add("taskType", taskType) + .add("componentUuid", componentUuid) + .add("status", status) + .add("isLast", isLast) + .add("isLastKey", isLastKey) + .add("submitterLogin", submitterLogin) + .add("submittedAt", submittedAt) + .add("startedAt", startedAt) + .add("finishedAt", finishedAt) + .add("createdAt", createdAt) + .add("updatedAt", updatedAt) + .add("executionTimeMs", executionTimeMs) + .toString(); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityMapper.java b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityMapper.java new file mode 100644 index 00000000000..266094669fe --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityMapper.java @@ -0,0 +1,43 @@ +/* + * 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 org.sonar.db.ce; + +import java.util.List; +import javax.annotation.CheckForNull; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.session.RowBounds; + +public interface CeActivityMapper { + + List<String> selectUuidsOfRecentlyCreatedByIsLastKey(@Param("isLastKey") String isLastKey, RowBounds rowBounds); + + @CheckForNull + CeActivityDto selectByUuid(@Param("uuid") String uuid); + + List<CeActivityDto> selectByComponentUuid(@Param("componentUuid") String componentUuid); + + List<CeActivityDto> selectByQuery(@Param("query") CeActivityQuery query, RowBounds rowBounds); + + void insert(CeActivityDto dto); + + void updateIsLastToFalseForLastKey(@Param("isLastKey") String isLastKey, @Param("updatedAt") long updatedAt); + + void updateIsLastToTrueForUuid(@Param("uuid") String uuid, @Param("updatedAt") long updatedAt); +} diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityQuery.java b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityQuery.java new file mode 100644 index 00000000000..f0e57fdd0a0 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityQuery.java @@ -0,0 +1,64 @@ +/* + * 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 org.sonar.db.ce; + +public class CeActivityQuery { + + private boolean onlyCurrents = false; + private String componentUuid; + private CeActivityDto.Status status; + private String type; + + public String getComponentUuid() { + return componentUuid; + } + + public CeActivityQuery setComponentUuid(String componentUuid) { + this.componentUuid = componentUuid; + return this; + } + + public boolean isOnlyCurrents() { + return onlyCurrents; + } + + public CeActivityQuery setOnlyCurrents(boolean onlyCurrents) { + this.onlyCurrents = onlyCurrents; + return this; + } + + public CeActivityDto.Status getStatus() { + return status; + } + + public CeActivityQuery setStatus(CeActivityDto.Status status) { + this.status = status; + return this; + } + + public String getType() { + return type; + } + + public CeActivityQuery setType(String type) { + this.type = type; + return this; + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java new file mode 100644 index 00000000000..dc78ae8576c --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDao.java @@ -0,0 +1,108 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Optional; +import java.util.List; +import org.sonar.api.utils.System2; +import org.sonar.db.Dao; +import org.sonar.db.DbSession; + +import static org.sonar.db.ce.CeQueueDto.Status.PENDING; +import static org.sonar.db.ce.CeQueueDto.Status.IN_PROGRESS; + +public class CeQueueDao implements Dao { + + private final System2 system2; + + public CeQueueDao(System2 system2) { + this.system2 = system2; + } + + /** + * Ordered by ascending id: oldest to newest + */ + public List<CeQueueDto> selectAllInAscOrder(DbSession session) { + return mapper(session).selectAllInAscOrder(); + } + + /** + * Ordered by ascending id: oldest to newest + */ + public List<CeQueueDto> selectByComponentUuid(DbSession session, String componentUuid) { + return mapper(session).selectByComponentUuid(componentUuid); + } + + public Optional<CeQueueDto> selectByUuid(DbSession session, String uuid) { + return Optional.fromNullable(mapper(session).selectByUuid(uuid)); + } + + public CeQueueDto insert(DbSession session, CeQueueDto dto) { + dto.setCreatedAt(system2.now()); + dto.setUpdatedAt(system2.now()); + mapper(session).insert(dto); + return dto; + } + + public void deleteByUuid(DbSession session, String uuid) { + mapper(session).deleteByUuid(uuid); + } + + /** + * Update all rows with: STATUS='PENDING', STARTED_AT=NULL, UPDATED_AT={now} + */ + public void resetAllToPendingStatus(DbSession session) { + mapper(session).resetAllToPendingStatus(system2.now()); + } + + public int countByStatus(DbSession dbSession, CeQueueDto.Status status) { + return mapper(dbSession).countByStatus(status); + } + + public int countAll(DbSession dbSession) { + return mapper(dbSession).countAll(); + } + + public Optional<CeQueueDto> peek(DbSession session) { + List<String> taskUuids = mapper(session).selectEligibleForPeek(); + if (taskUuids.isEmpty()) { + return Optional.absent(); + } + + String taskUuid = taskUuids.get(0); + return tryToPeek(session, taskUuid); + } + + private Optional<CeQueueDto> tryToPeek(DbSession session, String taskUuid) { + int touchedRows = mapper(session).updateIfStatus(taskUuid, IN_PROGRESS, system2.now(), system2.now(), PENDING); + if (touchedRows != 1) { + session.rollback(); + return Optional.absent(); + } + + CeQueueDto result = mapper(session).selectByUuid(taskUuid); + session.commit(); + return Optional.of(result); + } + + private CeQueueMapper mapper(DbSession session) { + return session.getMapper(CeQueueMapper.class); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDto.java b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDto.java new file mode 100644 index 00000000000..559fa6fd64d --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueDto.java @@ -0,0 +1,145 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Objects; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkArgument; + +public class CeQueueDto { + + public enum Status { + PENDING, IN_PROGRESS + } + + private String uuid; + private String taskType; + private String componentUuid; + private Status status; + private String submitterLogin; + private Long startedAt; + private long createdAt; + private long updatedAt; + + public String getUuid() { + return uuid; + } + + public void setUuid(String s) { + checkArgument(s.length() <= 40, "Value is too long for column CE_QUEUE.UUID: %s", s); + this.uuid = s; + } + + @CheckForNull + public String getComponentUuid() { + return componentUuid; + } + + public void setComponentUuid(@Nullable String s) { + checkArgument(s == null || s.length() <= 40, "Value is too long for column CE_QUEUE.COMPONENT_UUID: %s", s); + this.componentUuid = s; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status s) { + this.status = s; + } + + public String getTaskType() { + return taskType; + } + + public void setTaskType(String s) { + checkArgument(s.length() <= 15, "Value is too long for column CE_QUEUE.TASK_TYPE: %s", s); + this.taskType = s; + } + + @CheckForNull + public String getSubmitterLogin() { + return submitterLogin; + } + + public void setSubmitterLogin(@Nullable String s) { + checkArgument(s == null || s.length() <= 255, "Value is too long for column CE_QUEUE.SUBMITTER_LOGIN: %s", s); + this.submitterLogin = s; + } + + @CheckForNull + public Long getStartedAt() { + return startedAt; + } + + public void setStartedAt(@Nullable Long l) { + this.startedAt = l; + } + + public long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(long l) { + this.createdAt = l; + } + + public long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(long l) { + this.updatedAt = l; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("uuid", uuid) + .add("taskType", taskType) + .add("componentUuid", componentUuid) + .add("status", status) + .add("submitterLogin", submitterLogin) + .add("startedAt", startedAt) + .add("createdAt", createdAt) + .add("updatedAt", updatedAt) + .toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CeQueueDto that = (CeQueueDto) o; + return uuid.equals(that.uuid); + + } + + @Override + public int hashCode() { + return uuid.hashCode(); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportMapper.java b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java index daa9e465a89..18c8d1dad76 100644 --- a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeQueueMapper.java @@ -17,33 +17,37 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.db.compute; +package org.sonar.db.ce; import java.util.List; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.ibatis.annotations.Param; -public interface AnalysisReportMapper { - List<AnalysisReportDto> selectByProjectKey(String projectKey); +public interface CeQueueMapper { - List<Long> selectAvailables( - @Param("availableStatus") AnalysisReportDto.Status availableStatus, - @Param("busyStatus") AnalysisReportDto.Status busyStatus); + List<CeQueueDto> selectByComponentUuid(@Param("componentUuid") String componentUuid); - void resetAllToPendingStatus(@Param("updatedAt") long updatedAt); + List<CeQueueDto> selectAllInAscOrder(); + + List<String> selectEligibleForPeek(); - void truncate(); + @CheckForNull + CeQueueDto selectByUuid(@Param("uuid") String uuid); - void insert(AnalysisReportDto reportDto); + int countByStatus(@Param("status") CeQueueDto.Status status); - int update(AnalysisReportDto report); + int countAll(); - int updateWithBookingReport(@Param("id") Long id, @Param("startedAt") long startedAt, - @Param("availableStatus") AnalysisReportDto.Status availableStatus, - @Param("busyStatus") AnalysisReportDto.Status busyStatus); + void insert(CeQueueDto dto); - AnalysisReportDto selectById(long id); + void resetAllToPendingStatus(@Param("updatedAt") long updatedAt); - void delete(long id); + int updateIfStatus(@Param("uuid") String uuid, + @Param("newStatus") CeQueueDto.Status newStatus, + @Nullable @Param("startedAt") Long startedAt, + @Param("updatedAt") long updatedAt, + @Param("oldStatus") CeQueueDto.Status oldStatus); - List<AnalysisReportDto> selectAll(); + void deleteByUuid(@Param("uuid") String uuid); } diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeTaskTypes.java b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskTypes.java new file mode 100644 index 00000000000..042ff5eec0e --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskTypes.java @@ -0,0 +1,30 @@ +/* + * 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 org.sonar.db.ce; + +public class CeTaskTypes { + + private CeTaskTypes() { + // only statics + } + + public static final String REPORT = "REPORT"; + +} diff --git a/sonar-db/src/main/java/org/sonar/db/compute/package-info.java b/sonar-db/src/main/java/org/sonar/db/ce/package-info.java index 240f322233d..0b22b7060d5 100644 --- a/sonar-db/src/main/java/org/sonar/db/compute/package-info.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/package-info.java @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - @ParametersAreNonnullByDefault -package org.sonar.db.compute; +package org.sonar.db.ce; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDao.java b/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDao.java deleted file mode 100644 index 10d6df66519..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDao.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 org.sonar.db.compute; - -import com.google.common.annotations.VisibleForTesting; -import java.util.List; -import javax.annotation.CheckForNull; -import org.sonar.api.utils.System2; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; - -import static org.sonar.db.compute.AnalysisReportDto.Status.PENDING; -import static org.sonar.db.compute.AnalysisReportDto.Status.WORKING; - -public class AnalysisReportDao implements Dao { - - private System2 system2; - - public AnalysisReportDao(System2 system2) { - this.system2 = system2; - } - - /** - * Update all rows with: STATUS='PENDING', STARTED_AT=NULL, UPDATED_AT={now} - */ - public void resetAllToPendingStatus(DbSession session) { - mapper(session).resetAllToPendingStatus(system2.now()); - } - - public void truncate(DbSession session) { - mapper(session).truncate(); - } - - public List<AnalysisReportDto> selectByProjectKey(DbSession session, String projectKey) { - return mapper(session).selectByProjectKey(projectKey); - } - - @VisibleForTesting - AnalysisReportDto selectById(DbSession session, long id) { - return mapper(session).selectById(id); - } - - @CheckForNull - public AnalysisReportDto pop(DbSession session) { - List<Long> reportIds = mapper(session).selectAvailables(PENDING, WORKING); - if (reportIds.isEmpty()) { - return null; - } - - long reportId = reportIds.get(0); - return tryToPop(session, reportId); - } - - public long countPending(DbSession session) { - return mapper(session).selectAvailables(PENDING, WORKING).size(); - } - - @VisibleForTesting - AnalysisReportDto tryToPop(DbSession session, long reportId) { - AnalysisReportMapper mapper = mapper(session); - int nbOfReportBooked = mapper.updateWithBookingReport(reportId, system2.now(), PENDING, WORKING); - if (nbOfReportBooked == 0) { - return null; - } - - AnalysisReportDto result = mapper.selectById(reportId); - session.commit(); - return result; - } - - public List<AnalysisReportDto> selectAll(DbSession session) { - return mapper(session).selectAll(); - } - - public AnalysisReportDto insert(DbSession session, AnalysisReportDto report) { - report.setCreatedAt(system2.now()); - report.setUpdatedAt(system2.now()); - mapper(session).insert(report); - return report; - } - - public void delete(DbSession session, long id) { - mapper(session).delete(id); - } - - private AnalysisReportMapper mapper(DbSession session) { - return session.getMapper(AnalysisReportMapper.class); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDto.java b/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDto.java deleted file mode 100644 index 010afe179e7..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/compute/AnalysisReportDto.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 org.sonar.db.compute; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Objects; -import javax.annotation.CheckForNull; - -public class AnalysisReportDto { - private Long id; - private String projectKey; - private String projectName; - private Status status; - private String uuid; - private Long createdAt; - private Long updatedAt; - private Long startedAt; - private Long finishedAt; - - @VisibleForTesting - public static AnalysisReportDto newForTests(Long id) { - AnalysisReportDto report = new AnalysisReportDto(); - report.id = id; - - return report; - } - - public String getProjectKey() { - return projectKey; - } - - public AnalysisReportDto setProjectKey(String projectKey) { - this.projectKey = projectKey; - return this; - } - - public String getProjectName() { - return projectName; - } - - public AnalysisReportDto setProjectName(String projectName) { - this.projectName = projectName; - return this; - } - - public Status getStatus() { - return status; - } - - public AnalysisReportDto setStatus(Status status) { - this.status = status; - return this; - } - - public String getUuid() { - return uuid; - } - - public AnalysisReportDto setUuid(String s) { - this.uuid = s; - return this; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("id", getId()) - .add("projectKey", getProjectKey()) - .add("uuid", getUuid()) - .add("status", getStatus()) - .add("createdAt", getCreatedAt()) - .add("startedAt", getStartedAt()) - .add("finishedAt", getFinishedAt()) - .toString(); - } - - @CheckForNull - public Long getStartedAt() { - return startedAt; - } - - public AnalysisReportDto setStartedAt(Long startedAt) { - this.startedAt = startedAt; - return this; - } - - @CheckForNull - public Long getFinishedAt() { - return finishedAt; - } - - public AnalysisReportDto setFinishedAt(Long finishedAt) { - this.finishedAt = finishedAt; - return this; - } - - public Long getCreatedAt() { - return createdAt; - } - - public AnalysisReportDto setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - return this; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public AnalysisReportDto setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public enum Status { - PENDING, WORKING, SUCCESS, FAILED, CANCELLED - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index c8a0ded3816..3e00526a1f0 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -29,7 +29,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 931; + public static final int LAST_VERSION = 934; /** * The minimum supported version which can be upgraded. Lower @@ -49,8 +49,9 @@ public class DatabaseVersion { "active_rules", "active_rule_parameters", "activities", - "analysis_reports", "authors", + "ce_activity", + "ce_queue", "characteristics", "dashboards", "duplications_index", diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java index 9f60c133660..30179824198 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java +++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java @@ -47,6 +47,7 @@ import org.sonar.db.version.v51.RemovePermissionsOnModulesMigrationStep; import org.sonar.db.version.v51.RenameComponentRelatedParamsInIssueFilters; import org.sonar.db.version.v51.UpdateProjectsModuleUuidPath; import org.sonar.db.version.v52.AddManualMeasuresComponentUuidColumn; +import org.sonar.db.version.v52.RemoveAnalysisReportsFromActivities; import org.sonar.db.version.v52.FeedEventsComponentUuid; import org.sonar.db.version.v52.FeedFileSourcesDataType; import org.sonar.db.version.v52.FeedManualMeasuresComponentUuid; @@ -105,6 +106,7 @@ public class MigrationStepModule extends Module { RemoveSnapshotLibraries.class, RemoveComponentLibraries.class, RemoveDuplicatedComponentKeys.class, - IncreasePrecisionOfNumerics.class); + IncreasePrecisionOfNumerics.class, + RemoveAnalysisReportsFromActivities.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivities.java b/sonar-db/src/main/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivities.java new file mode 100644 index 00000000000..74cfd448d4e --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivities.java @@ -0,0 +1,52 @@ +/* + * 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 org.sonar.db.version.v52; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.BaseDataChange; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; + +/** + * Items moved to table CE_ACTIVITY + * @since 5.2 + */ +public class RemoveAnalysisReportsFromActivities extends BaseDataChange { + + public RemoveAnalysisReportsFromActivities(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select id from activities where log_type='ANALYSIS_REPORT'"); + massUpdate.update("delete from activities where id=?"); + massUpdate.execute(new MassUpdate.Handler() { + @Override + public boolean handle(Select.Row row, SqlStatement update) throws SQLException { + update.setLong(1, row.getLong(1)); + return true; + } + }); + } +} diff --git a/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml b/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml new file mode 100644 index 00000000000..fcd588aa5e7 --- /dev/null +++ b/sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + +<mapper namespace="org.sonar.db.ce.CeActivityMapper"> + + <sql id="columns"> + ca.uuid, + ca.task_type as taskType, + ca.component_uuid as componentUuid, + ca.status as status, + ca.submitter_login as submitterLogin, + ca.submitted_at as submittedAt, + ca.started_at as startedAt, + ca.finished_at as finishedAt, + ca.created_at as createdAt, + ca.updated_at as updatedAt, + ca.is_last as isLast, + ca.is_last_key as isLastKey, + ca.execution_time_ms as executionTimeMs + </sql> + + <select id="selectByUuid" parameterType="String" resultType="org.sonar.db.ce.CeActivityDto"> + select + <include refid="columns"/> + from ce_activity ca + where ca.uuid=#{uuid} + </select> + + <select id="selectByComponentUuid" parameterType="String" resultType="org.sonar.db.ce.CeActivityDto"> + select + <include refid="columns"/> + from ce_activity ca + where ca.component_uuid=#{componentUuid} + order by ca.id asc + </select> + + <select id="selectUuidsOfRecentlyCreatedByIsLastKey" parameterType="String" resultType="String"> + select uuid + from ce_activity + where is_last_key=#{isLastKey} + order by id desc + </select> + + <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.ce.CeActivityDto"> + select + <include refid="columns"/> + from ce_activity ca + <where> + <if test="query.onlyCurrents"> + ca.is_last=${_true} + </if> + <if test="query.componentUuid != null"> + ca.component_uuid=#{query.componentUuid} + </if> + <if test="query.status != null"> + ca.status=#{query.status} + </if> + <if test="query.type != null"> + ca.task_type=#{query.type} + </if> + </where> + order by ca.id desc + </select> + + <insert id="insert" parameterType="org.sonar.db.ce.CeActivityDto" useGeneratedKeys="false"> + insert into ce_activity + (uuid, component_uuid, status, task_type, is_last, is_last_key, submitter_login, submitted_at, started_at, + finished_at, created_at, updated_at, execution_time_ms) + values ( + #{uuid,jdbcType=VARCHAR}, + #{componentUuid,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, + #{taskType,jdbcType=VARCHAR}, + #{isLast,jdbcType=BOOLEAN}, + #{isLastKey,jdbcType=VARCHAR}, + #{submitterLogin,jdbcType=VARCHAR}, + #{submittedAt,jdbcType=BIGINT}, + #{startedAt,jdbcType=BIGINT}, + #{finishedAt,jdbcType=BIGINT}, + #{createdAt,jdbcType=BIGINT}, + #{updatedAt,jdbcType=BIGINT}, + #{executionTimeMs,jdbcType=BIGINT} + ) + </insert> + + <update id="updateIsLastToFalseForLastKey" parameterType="map"> + update ce_activity + set is_last=${_false}, + updated_at=#{updatedAt,jdbcType=BIGINT} + where is_last=${_true} and is_last_key=#{isLastKey} + </update> + + <update id="updateIsLastToTrueForUuid" parameterType="map"> + update ce_activity + set is_last=${_true}, + updated_at=#{updatedAt,jdbcType=BIGINT} + where uuid=#{uuid} + </update> + +</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml b/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml new file mode 100644 index 00000000000..42b26d303c9 --- /dev/null +++ b/sonar-db/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + +<mapper namespace="org.sonar.db.ce.CeQueueMapper"> + + <sql id="columns"> + cq.uuid, + cq.task_type as taskType, + cq.component_uuid as componentUuid, + cq.status as status, + cq.submitter_login as submitterLogin, + cq.started_at as startedAt, + cq.created_at as createdAt, + cq.updated_at as updatedAt + </sql> + + <select id="selectByUuid" parameterType="String" resultType="org.sonar.db.ce.CeQueueDto"> + select + <include refid="columns"/> + from ce_queue cq + where cq.uuid=#{uuid} + </select> + + <select id="countByStatus" parameterType="org.sonar.db.ce.CeQueueDto$Status" resultType="int"> + select count(id) from ce_queue where status=#{status} + </select> + + <select id="countAll" resultType="int"> + select count(id) from ce_queue + </select> + + <select id="selectByComponentUuid" parameterType="String" resultType="org.sonar.db.ce.CeQueueDto"> + select + <include refid="columns"/> + from ce_queue cq + where cq.component_uuid=#{componentUuid} + order by cq.id asc + </select> + + <select id="selectAllInAscOrder" resultType="org.sonar.db.ce.CeQueueDto"> + select + <include refid="columns"/> + from ce_queue cq + order by cq.id asc + </select> + + <select id="selectEligibleForPeek" resultType="String"> + select cq.uuid + from ce_queue cq + where cq.status='PENDING' + and not exists( + select 1 + from ce_queue cq2 + where cq.component_uuid=cq2.component_uuid and cq2.status <> 'PENDING' + ) + order by cq.created_at asc, cq.id asc + </select> + + <insert id="insert" parameterType="org.sonar.db.ce.CeQueueDto" useGeneratedKeys="false"> + insert into ce_queue + (uuid, task_type, component_uuid, status, submitter_login, started_at, created_at, updated_at) + values ( + #{uuid,jdbcType=VARCHAR}, + #{taskType,jdbcType=VARCHAR}, + #{componentUuid,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, + #{submitterLogin,jdbcType=VARCHAR}, + #{startedAt,jdbcType=BIGINT}, + #{createdAt,jdbcType=BIGINT}, + #{updatedAt,jdbcType=BIGINT} + ) + </insert> + + <update id="resetAllToPendingStatus" parameterType="map"> + update ce_queue + set status='PENDING', started_at=NULL, updated_at=#{updatedAt,jdbcType=BIGINT} + where status <> 'PENDING' + </update> + + <update id="updateIfStatus" parameterType="map"> + update ce_queue + set status=#{newStatus,jdbcType=VARCHAR}, + started_at=#{startedAt,jdbcType=BIGINT}, + updated_at=#{updatedAt,jdbcType=BIGINT} + where uuid=#{uuid} and status=#{oldStatus} + </update> + + <delete id="deleteByUuid"> + delete from ce_queue where uuid=#{uuid} + </delete> + +</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/compute/AnalysisReportMapper.xml b/sonar-db/src/main/resources/org/sonar/db/compute/AnalysisReportMapper.xml deleted file mode 100644 index 2a3700186d4..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/compute/AnalysisReportMapper.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="org.sonar.db.compute.AnalysisReportMapper"> - <sql id="reportColumns"> - <!-- the data report is not brought back by default as it could be too big in memory --> - ar.id, - ar.project_key as projectKey, - ar.project_name as projectName, - ar.report_status as status, - ar.uuid as uuid, - ar.created_at as createdAt, - ar.updated_at as updatedAt, - ar.started_at as startedAt, - ar.finished_at as finishedAt - </sql> - - <insert id="insert" parameterType="AnalysisReport" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> - insert into analysis_reports - (project_key, project_name, uuid, report_status, created_at, updated_at, started_at, finished_at) - values ( - #{projectKey,jdbcType=VARCHAR}, #{projectName,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}, - #{status,jdbcType=VARCHAR}, - #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{startedAt,jdbcType=BIGINT}, - #{finishedAt,jdbcType=BIGINT} - ) - </insert> - - <update id="resetAllToPendingStatus" parameterType="map"> - update analysis_reports - set report_status='PENDING', updated_at=#{updatedAt,jdbcType=BIGINT}, started_at=NULL - </update> - - <update id="updateWithBookingReport" parameterType="map"> - update analysis_reports - set report_status=#{busyStatus,jdbcType=VARCHAR}, - started_at=#{startedAt,jdbcType=BIGINT} - where id=#{id} and report_status=#{availableStatus} - </update> - - <delete id="truncate"> - truncate table analysis_reports - </delete> - - <delete id="delete"> - delete from analysis_reports where id=#{id} - </delete> - - <select id="selectById" resultType="AnalysisReport"> - select - <include refid="reportColumns"/> - from analysis_reports ar - where id = #{id} - </select> - - <select id="selectByProjectKey" parameterType="String" resultType="AnalysisReport"> - select - <include refid="reportColumns"/> - from analysis_reports ar - where project_key = #{projectKey} - </select> - - <!-- TODO optimize by restricting results to first row (LIMIT 1 on most dbs) --> - <select id="selectAvailables" parameterType="map" resultType="Long"> - select ar.id - from analysis_reports ar - where ar.report_status=#{availableStatus} - and not exists( - select 1 - from analysis_reports ar2 - where ar.project_key = ar2.project_key - and ar2.report_status=#{busyStatus} - ) - order by ar.created_at asc, ar.id asc - </select> - - <select id="selectAll" resultType="AnalysisReport"> - select - <include refid="reportColumns"/> - from analysis_reports ar - </select> -</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index d8b4310588d..a2d75b28898 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -9,8 +9,9 @@ INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'pr INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (3, 1, null, 'shareDashboard'); INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, null, null, 'scan'); INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, null, null, 'dryRunScan'); -INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (6, 1, null, 'provisioning'); -ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 7; +INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (6, null, null, 'provisioning'); +INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (7, 1, null, 'provisioning'); +ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 8; INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1); INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 2); @@ -349,6 +350,9 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('927'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('929'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('930'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('931'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('932'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('933'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('934'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index a1a27b835e6..92e95d0cc2b 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -534,6 +534,35 @@ CREATE TABLE "FILE_SOURCES" ( "UPDATED_AT" BIGINT NOT NULL ); +CREATE TABLE "CE_QUEUE" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "STARTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); + +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "FINISHED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL +); + -- ---------------------------------------------- -- DDL Statements for indexes -- ---------------------------------------------- @@ -675,3 +704,7 @@ CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE_UNIQUE" ON "FILE_SOURCES" ("FILE_UUI CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); CREATE UNIQUE INDEX "PROJECT_QPROFILES_UNIQUE" ON "PROJECT_QPROFILES" ("PROJECT_UUID", "PROFILE_KEY"); + +CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); + +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index eb4d016d162..29e06e13da5 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -30,6 +30,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(46); + assertThat(container.size()).isEqualTo(47); } } diff --git a/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java new file mode 100644 index 00000000000..25d167afb5a --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java @@ -0,0 +1,129 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Optional; +import java.util.List; +import org.apache.ibatis.session.RowBounds; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.sonar.api.utils.System2; +import org.sonar.api.utils.internal.TestSystem2; +import org.sonar.db.DbTester; +import org.sonar.test.DbTests; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.db.ce.CeTaskTypes.REPORT; + +@Category(DbTests.class) +public class CeActivityDaoTest { + + System2 system2 = new TestSystem2().setNow(1_450_000_000_000L); + + @Rule + public DbTester db = DbTester.create(system2); + + CeActivityDao underTest = new CeActivityDao(system2); + + @Test + public void test_insert() { + insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS); + + Optional<CeActivityDto> saved = underTest.selectByUuid(db.getSession(), "TASK_1"); + assertThat(saved.isPresent()).isTrue(); + assertThat(saved.get().getUuid()).isEqualTo("TASK_1"); + assertThat(saved.get().getComponentUuid()).isEqualTo("PROJECT_1"); + assertThat(saved.get().getStatus()).isEqualTo(CeActivityDto.Status.SUCCESS); + assertThat(saved.get().getSubmitterLogin()).isEqualTo("henri"); + assertThat(saved.get().getIsLast()).isTrue(); + assertThat(saved.get().getIsLastKey()).isEqualTo("REPORTPROJECT_1"); + assertThat(saved.get().getSubmittedAt()).isEqualTo(1_300_000_000_000L); + assertThat(saved.get().getCreatedAt()).isEqualTo(1_450_000_000_000L); + assertThat(saved.get().getStartedAt()).isEqualTo(1_500_000_000_000L); + assertThat(saved.get().getFinishedAt()).isEqualTo(1_500_000_000_500L); + assertThat(saved.get().getExecutionTimeMs()).isEqualTo(500L); + } + + @Test + public void insert_must_set_relevant_is_last_field() { + // only a single task on PROJECT_1 -> is_last=true + insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").get().getIsLast()).isTrue(); + + // only a single task on PROJECT_2 -> is_last=true + insert("TASK_2", REPORT, "PROJECT_2", CeActivityDto.Status.SUCCESS); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_2").get().getIsLast()).isTrue(); + + // two tasks on PROJECT_1, the more recent one is TASK_3 + insert("TASK_3", REPORT, "PROJECT_1", CeActivityDto.Status.FAILED); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").get().getIsLast()).isFalse(); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_2").get().getIsLast()).isTrue(); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_3").get().getIsLast()).isTrue(); + } + + @Test + public void test_selectByQuery() throws Exception { + insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS); + insert("TASK_2", REPORT, "PROJECT_1", CeActivityDto.Status.FAILED); + insert("TASK_3", REPORT, "PROJECT_2", CeActivityDto.Status.SUCCESS); + insert("TASK_4", "views", null, CeActivityDto.Status.SUCCESS); + + // no filters + CeActivityQuery query = new CeActivityQuery(); + List<CeActivityDto> dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); + assertThat(dtos).extracting("uuid").containsExactly("TASK_4", "TASK_3", "TASK_2", "TASK_1"); + + // select by component uuid + query = new CeActivityQuery().setComponentUuid("PROJECT_1"); + dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); + assertThat(dtos).extracting("uuid").containsExactly("TASK_2", "TASK_1"); + + // select by status + query = new CeActivityQuery().setStatus(CeActivityDto.Status.SUCCESS); + dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); + assertThat(dtos).extracting("uuid").containsExactly("TASK_4", "TASK_3", "TASK_1"); + + // select by type + query = new CeActivityQuery().setType(REPORT); + dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); + assertThat(dtos).extracting("uuid").containsExactly("TASK_3", "TASK_2", "TASK_1"); + query = new CeActivityQuery().setType("views"); + dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); + assertThat(dtos).extracting("uuid").containsExactly("TASK_4"); + } + + private void insert(String uuid, String type, String componentUuid, CeActivityDto.Status status) { + CeQueueDto queueDto = new CeQueueDto(); + queueDto.setUuid(uuid); + queueDto.setTaskType(type); + queueDto.setComponentUuid(componentUuid); + queueDto.setSubmitterLogin("henri"); + queueDto.setCreatedAt(1_300_000_000_000L); + + CeActivityDto dto = new CeActivityDto(queueDto); + dto.setStatus(status); + dto.setStartedAt(1_500_000_000_000L); + dto.setFinishedAt(1_500_000_000_500L); + dto.setExecutionTimeMs(500L); + underTest.insert(db.getSession(), dto); + } +} diff --git a/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java new file mode 100644 index 00000000000..761c8bfb734 --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java @@ -0,0 +1,183 @@ +/* + * 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 org.sonar.db.ce; + +import com.google.common.base.Optional; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.sonar.api.utils.System2; +import org.sonar.api.utils.internal.TestSystem2; +import org.sonar.db.DbTester; +import org.sonar.test.DbTests; + +import static org.assertj.core.api.Assertions.assertThat; + +@Category(DbTests.class) +public class CeQueueDaoTest { + + System2 system2 = new TestSystem2().setNow(1_450_000_000_000L); + + @Rule + public DbTester db = DbTester.create(system2); + + CeQueueDao underTest = new CeQueueDao(system2); + + @Test + public void test_insert() { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + + Optional<CeQueueDto> saved = underTest.selectByUuid(db.getSession(), "TASK_1"); + assertThat(saved.isPresent()).isTrue(); + } + + @Test + public void test_selectByUuid() { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + + assertThat(underTest.selectByUuid(db.getSession(), "TASK_UNKNOWN").isPresent()).isFalse(); + CeQueueDto saved = underTest.selectByUuid(db.getSession(), "TASK_1").get(); + assertThat(saved.getUuid()).isEqualTo("TASK_1"); + assertThat(saved.getTaskType()).isEqualTo(CeTaskTypes.REPORT); + assertThat(saved.getComponentUuid()).isEqualTo("PROJECT_1"); + assertThat(saved.getStatus()).isEqualTo(CeQueueDto.Status.PENDING); + assertThat(saved.getSubmitterLogin()).isEqualTo("henri"); + assertThat(saved.getCreatedAt()).isEqualTo(1_450_000_000_000L); + assertThat(saved.getUpdatedAt()).isEqualTo(1_450_000_000_000L); + assertThat(saved.getStartedAt()).isNull(); + } + + @Test + public void test_selectByComponentUuid() { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_2", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_3", "PROJECT_2", CeQueueDto.Status.PENDING); + + assertThat(underTest.selectByComponentUuid(db.getSession(), "UNKNOWN")).isEmpty(); + assertThat(underTest.selectByComponentUuid(db.getSession(), "PROJECT_1")).extracting("uuid").containsOnly("TASK_1", "TASK_2"); + assertThat(underTest.selectByComponentUuid(db.getSession(), "PROJECT_2")).extracting("uuid").containsOnly("TASK_3"); + } + + @Test + public void test_selectAllInAscOrder() { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_2", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_3", "PROJECT_2", CeQueueDto.Status.PENDING); + + assertThat(underTest.selectAllInAscOrder(db.getSession())).extracting("uuid").containsOnly("TASK_1", "TASK_2", "TASK_3"); + } + + @Test + public void test_delete() { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + + underTest.deleteByUuid(db.getSession(), "UNKNOWN"); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isTrue(); + + underTest.deleteByUuid(db.getSession(), "TASK_1"); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isFalse(); + } + + @Test + public void test_resetAllToPendingStatus() throws Exception { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_2", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); + insert("TASK_3", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(1); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(2); + + underTest.resetAllToPendingStatus(db.getSession()); + + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(3); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(0); + } + + @Test + public void peek_none_if_no_pendings() throws Exception { + assertThat(underTest.peek(db.getSession()).isPresent()).isFalse(); + + // not pending, but in progress + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS); + assertThat(underTest.peek(db.getSession()).isPresent()).isFalse(); + } + + @Test + public void peek_oldest_pending() throws Exception { + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_2", "PROJECT_2", CeQueueDto.Status.PENDING); + assertThat(underTest.countAll(db.getSession())).isEqualTo(2); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(2); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(0); + + // peek first one + Optional<CeQueueDto> peek = underTest.peek(db.getSession()); + assertThat(peek.isPresent()).isTrue(); + assertThat(peek.get().getUuid()).isEqualTo("TASK_1"); + assertThat(peek.get().getStatus()).isEqualTo(CeQueueDto.Status.IN_PROGRESS); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(1); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(1); + + // peek second one + peek = underTest.peek(db.getSession()); + assertThat(peek.isPresent()).isTrue(); + assertThat(peek.get().getUuid()).isEqualTo("TASK_2"); + assertThat(peek.get().getStatus()).isEqualTo(CeQueueDto.Status.IN_PROGRESS); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(0); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(2); + + // no more pendings + assertThat(underTest.peek(db.getSession()).isPresent()).isFalse(); + } + + @Test + public void do_not_peek_multiple_tasks_on_same_project_at_the_same_time() throws Exception { + // two pending tasks on the same project + insert("TASK_1", "PROJECT_1", CeQueueDto.Status.PENDING); + insert("TASK_2", "PROJECT_1", CeQueueDto.Status.PENDING); + + Optional<CeQueueDto> peek = underTest.peek(db.getSession()); + assertThat(peek.isPresent()).isTrue(); + assertThat(peek.get().getUuid()).isEqualTo("TASK_1"); + assertThat(underTest.countAll(db.getSession())).isEqualTo(2); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.PENDING)).isEqualTo(1); + assertThat(underTest.countByStatus(db.getSession(), CeQueueDto.Status.IN_PROGRESS)).isEqualTo(1); + + // do not peek second task as long as the first one is in progress + peek = underTest.peek(db.getSession()); + assertThat(peek.isPresent()).isFalse(); + + // first one is finished + underTest.deleteByUuid(db.getSession(), "TASK_1"); + peek = underTest.peek(db.getSession()); + assertThat(peek.get().getUuid()).isEqualTo("TASK_2"); + } + + private void insert(String uuid, String componentUuid, CeQueueDto.Status status) { + CeQueueDto dto = new CeQueueDto(); + dto.setUuid(uuid); + dto.setTaskType(CeTaskTypes.REPORT); + dto.setComponentUuid(componentUuid); + dto.setStatus(status); + dto.setSubmitterLogin("henri"); + underTest.insert(db.getSession(), dto); + db.getSession().commit(); + } +} diff --git a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java b/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java deleted file mode 100644 index 0b93ee63253..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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 org.sonar.db.compute; - -import java.util.List; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; -import org.sonar.test.DbTests; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.sonar.db.compute.AnalysisReportDto.Status.PENDING; -import static org.sonar.db.compute.AnalysisReportDto.Status.WORKING; - -@Category(DbTests.class) -public class AnalysisReportDaoTest { - - static final String DEFAULT_PROJECT_KEY = "123456789-987654321"; - - static System2 system2 = mock(System2.class); - @Rule - public DbTester db = DbTester.create(system2); - DbSession session; - - AnalysisReportDao underTest = new AnalysisReportDao(system2); - - @Before - public void setUp() { - session = db.getSession(); - } - - @Test - public void insert_multiple_reports() { - db.prepareDbUnit(getClass(), "empty.xml"); - when(system2.now()).thenReturn(1_500_000_000_000L); - - AnalysisReportDto report1 = new AnalysisReportDto().setProjectKey("ProjectKey1").setProjectName("Project 1").setUuid("UUID_1").setStatus(PENDING); - AnalysisReportDto report2 = new AnalysisReportDto().setProjectKey("ProjectKey2").setProjectName("Project 2").setUuid("UUID_2").setStatus(PENDING); - - underTest.insert(session, report1); - underTest.insert(session, report2); - session.commit(); - - db.assertDbUnit(getClass(), "insert-result.xml", "analysis_reports"); - } - - @Test - public void resetAllToPendingStatus() { - db.prepareDbUnit(getClass(), "update-all-to-status-pending.xml"); - - underTest.resetAllToPendingStatus(session); - session.commit(); - - db.assertDbUnit(getClass(), "update-all-to-status-pending-result.xml", "analysis_reports"); - } - - @Test - public void truncate() { - db.prepareDbUnit(getClass(), "any-analysis-reports.xml"); - - underTest.truncate(session); - session.commit(); - - db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports"); - } - - @Test - public void find_one_report_by_project_key() { - db.prepareDbUnit(getClass(), "select.xml"); - - final String projectKey = "123456789-987654321"; - List<AnalysisReportDto> reports = underTest.selectByProjectKey(session, projectKey); - AnalysisReportDto report = reports.get(0); - - assertThat(reports).hasSize(1); - assertThat(report.getProjectKey()).isEqualTo(projectKey); - assertThat(report.getProjectName()).isEqualTo("Project 1"); - assertThat(report.getStatus()).isEqualTo(AnalysisReportDto.Status.WORKING); - assertThat(report.getId()).isEqualTo(1); - } - - @Test - public void find_several_reports_by_project_key() { - db.prepareDbUnit(getClass(), "select.xml"); - - final String projectKey = "987654321-123456789"; - List<AnalysisReportDto> reports = underTest.selectByProjectKey(session, projectKey); - - assertThat(reports).hasSize(2); - } - - @Test - public void pop_oldest_pending() { - db.prepareDbUnit(getClass(), "pop_oldest_pending.xml"); - - AnalysisReportDto nextAvailableReport = underTest.pop(session); - - assertThat(nextAvailableReport.getId()).isEqualTo(3); - assertThat(nextAvailableReport.getProjectKey()).isEqualTo("P2"); - } - - @Test - public void count_pending() { - db.prepareDbUnit(getClass(), "pop_oldest_pending.xml"); - - assertThat(underTest.countPending(db.getSession())).isEqualTo(2); - } - - @Test - public void pop_null_if_no_pending_reports() { - db.prepareDbUnit(getClass(), "pop_null_if_no_pending_reports.xml"); - - AnalysisReportDto nextAvailableReport = underTest.pop(session); - - assertThat(nextAvailableReport).isNull(); - } - - @Test - public void getById_maps_all_the_fields_except_the_data() { - db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - - AnalysisReportDto report = underTest.selectById(session, 1L); - - assertThat(report.getProjectKey()).isEqualTo(DEFAULT_PROJECT_KEY); - assertThat(report.getCreatedAt()).isEqualTo(1_500_000_000_001L); - assertThat(report.getUpdatedAt()).isEqualTo(1_500_000_000_002L); - assertThat(report.getStartedAt()).isEqualTo(1_500_000_000_003L); - assertThat(report.getFinishedAt()).isEqualTo(1_500_000_000_004L); - assertThat(report.getStatus()).isEqualTo(WORKING); - } - - @Test - public void getById_returns_null_when_id_not_found() { - db.prepareDbUnit(getClass(), "select.xml"); - - AnalysisReportDto report = underTest.selectById(session, 4L); - - assertThat(report).isNull(); - } - - @Test - public void delete_one_analysis_report() { - db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - - underTest.delete(session, 1); - session.commit(); - - db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports"); - } - - @Test - public void findAll_one_analysis_report() { - db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - - List<AnalysisReportDto> reports = underTest.selectAll(session); - - assertThat(reports).hasSize(1); - } - - @Test - public void findAll_empty_table() { - db.prepareDbUnit(getClass(), "empty.xml"); - - List<AnalysisReportDto> reports = underTest.selectAll(session); - - assertThat(reports).isEmpty(); - } - - @Test - public void findAll_three_analysis_reports() { - db.prepareDbUnit(getClass(), "three_analysis_reports.xml"); - - List<AnalysisReportDto> reports = underTest.selectAll(session); - - assertThat(reports).hasSize(3); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivitiesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivitiesTest.java new file mode 100644 index 00000000000..0a474ef4d87 --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/version/v52/RemoveAnalysisReportsFromActivitiesTest.java @@ -0,0 +1,47 @@ +/* + * 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 org.sonar.db.version.v52; + +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; +import org.sonar.db.activity.ActivityDto; +import org.sonar.db.version.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RemoveAnalysisReportsFromActivitiesTest { + @Rule + public DbTester db = DbTester.create(System2.INSTANCE); + + MigrationStep underTest = new RemoveAnalysisReportsFromActivities(db.database()); + + @Test + public void test() throws Exception { + db.getDbClient().activityDao().insert(new ActivityDto().setType("ANALYSIS_REPORT").setKey("1")); + db.getDbClient().activityDao().insert(new ActivityDto().setType("ANALYSIS_REPORT").setKey("2")); + db.getDbClient().activityDao().insert(new ActivityDto().setType("PROFILE_CHANGE").setKey("3")); + + underTest.execute(); + + assertThat(db.countRowsOfTable("ACTIVITIES")).isEqualTo(1); + } +} diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/any-analysis-reports.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/any-analysis-reports.xml deleted file mode 100644 index dba17d047a4..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/any-analysis-reports.xml +++ /dev/null @@ -1,26 +0,0 @@ -<dataset> - <analysis_reports - id="1" - uuid="REPORT_1" - project_key="123456789-987654321" - report_status="WORKING" - created_at="1411509600000" - updated_at="1411509600000" - /> - <analysis_reports - id="2" - uuid="REPORT_2" - project_key="123456789-987654321" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411596000000" - /> - <analysis_reports - id="3" - uuid="REPORT_3" - project_key="123456789-987654321" - report_status="PENDING" - created_at="1411682400000" - updated_at="1411682400000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/book_available_report_analysis_while_having_one_working_on_another_project.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/book_available_report_analysis_while_having_one_working_on_another_project.xml deleted file mode 100644 index ae28befd603..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/book_available_report_analysis_while_having_one_working_on_another_project.xml +++ /dev/null @@ -1,18 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="123456789-987654321" - uuid="REPORT_1" - report_status="PENDING" - created_at="1411509600000" - updated_at="1411596000000" - /> - <analysis_reports - id="2" - project_key="987654321-123456789" - uuid="REPORT_2" - report_status="WORKING" - created_at="1411423200000" - updated_at="1411682400000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/empty.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/empty.xml deleted file mode 100644 index 871dedcb5e9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/empty.xml +++ /dev/null @@ -1,3 +0,0 @@ -<dataset> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/insert-result.xml deleted file mode 100644 index d25e3641ce9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/insert-result.xml +++ /dev/null @@ -1,24 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="ProjectKey1" - project_name="Project 1" - uuid="UUID_1" - report_status="PENDING" - started_at="[null]" - finished_at="[null]" - created_at="1500000000000" - updated_at="1500000000000" - /> - <analysis_reports - id="2" - project_key="ProjectKey2" - project_name="Project 2" - uuid="UUID_2" - report_status="PENDING" - started_at="[null]" - finished_at="[null]" - created_at="1500000000000" - updated_at="1500000000000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/one_analysis_report.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/one_analysis_report.xml deleted file mode 100644 index c38ac125e00..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/one_analysis_report.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="123456789-987654321" - uuid="REPORT_1" - report_status="WORKING" - created_at="1500000000001" - updated_at="1500000000002" - started_at="1500000000003" - finished_at="1500000000004" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_null_if_no_pending_reports.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_null_if_no_pending_reports.xml deleted file mode 100644 index 82f93e9fec5..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_null_if_no_pending_reports.xml +++ /dev/null @@ -1,27 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="111111111-987654321" - uuid="UUID_1" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411682400000" - /> - <analysis_reports - id="2" - project_key="123456789-987654321" - uuid="UUID_2" - report_status="WORKING" - created_at="1411509600000" - updated_at="1411682400000" - /> - <!-- not select as the previous report which is working is on the same project --> - <analysis_reports - id="3" - project_key="123456789-987654321" - uuid="UUID_3" - report_status="PENDING" - created_at="1411596000000" - updated_at="1411682400000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_oldest_pending.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_oldest_pending.xml deleted file mode 100644 index 972fde88fd7..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/pop_oldest_pending.xml +++ /dev/null @@ -1,37 +0,0 @@ -<dataset> - <!-- WORKING --> - <analysis_reports - id="1" - project_key="P1" - uuid="UUID_1" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411682400000" - /> - - <!-- PENDING on P1, which is already being WORKING--> - <analysis_reports - id="2" - project_key="P1" - uuid="UUID_2" - report_status="PENDING" - created_at="1411509600000" - updated_at="1411682400000" - /> - <analysis_reports - id="3" - project_key="P2" - uuid="UUID_3" - report_status="PENDING" - created_at="1411596000000" - updated_at="1411682400000" - /> - <analysis_reports - id="4" - project_key="P2" - uuid="UUID_4" - report_status="PENDING" - created_at="1420066800000" - updated_at="1420066800000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/select.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/select.xml deleted file mode 100644 index de9d5b9f330..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/select.xml +++ /dev/null @@ -1,29 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="123456789-987654321" - project_name="Project 1" - uuid="UUID_1" - report_status="WORKING" - created_at="1411509600000" - updated_at="1411596000000" - /> - <analysis_reports - id="2" - project_key="987654321-123456789" - project_name="Project 2" - uuid="UUID_2" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411596000000" - /> - <analysis_reports - id="3" - project_key="987654321-123456789" - project_name="Project 2" - uuid="UUID_3" - report_status="PENDING" - created_at="1411682400000" - updated_at="1411682400000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/three_analysis_reports.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/three_analysis_reports.xml deleted file mode 100644 index c1e3284f108..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/three_analysis_reports.xml +++ /dev/null @@ -1,26 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="123456789-987654321" - uuid="UUID_1" - report_status="WORKING" - created_at="1411509600000" - updated_at="1411596000000" - /> - <analysis_reports - id="2" - project_key="987654321-123456789" - uuid="UUID_2" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411596000000" - /> - <analysis_reports - id="3" - project_key="987654321-123456789" - uuid="UUID_3" - report_status="PENDING" - created_at="1411682400000" - updated_at="1411682400000" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/truncate-result.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/truncate-result.xml deleted file mode 100644 index e573e0c5b06..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/truncate-result.xml +++ /dev/null @@ -1,3 +0,0 @@ -<dataset> - <analysis_reports/> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending-result.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending-result.xml deleted file mode 100644 index 16fb8dc0895..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending-result.xml +++ /dev/null @@ -1,36 +0,0 @@ -<dataset> - <!-- all rows are PENDING, updated_at is now, started_at is null --> - <analysis_reports - id="1" - project_key="P1" - project_name="Project1" - uuid="UUID_1" - report_status="PENDING" - created_at="1411509600000" - updated_at="1500000000000" - started_at="[null]" - finished_at="[null]" - /> - <analysis_reports - id="2" - project_key="P2" - project_name="Project2" - uuid="UUID_2" - report_status="PENDING" - created_at="1411596000000" - updated_at="1500000000000" - started_at="[null]" - finished_at="[null]" - /> - <analysis_reports - id="3" - project_key="P1" - project_name="Project1" - uuid="UUID_3" - report_status="PENDING" - created_at="1411682400000" - updated_at="1500000000000" - started_at="[null]" - finished_at="[null]" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending.xml b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending.xml deleted file mode 100644 index a630cb4ec4b..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/update-all-to-status-pending.xml +++ /dev/null @@ -1,35 +0,0 @@ -<dataset> - <analysis_reports - id="1" - project_key="P1" - project_name="Project1" - uuid="UUID_1" - report_status="WORKING" - created_at="1411509600000" - updated_at="1411509600000" - started_at="1411509600000" - finished_at="[null]" - /> - <analysis_reports - id="2" - project_key="P2" - project_name="Project2" - uuid="UUID_2" - report_status="WORKING" - created_at="1411596000000" - updated_at="1411596000000" - started_at="1411509600000" - finished_at="[null]" - /> - <analysis_reports - id="3" - project_key="P1" - project_name="Project1" - uuid="UUID_3" - report_status="PENDING" - created_at="1411682400000" - updated_at="1411682400000" - started_at="[null]" - finished_at="[null]" - /> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/zip.zip b/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/zip.zip Binary files differdeleted file mode 100644 index a540bc5b5ca..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/compute/AnalysisReportDaoTest/zip.zip +++ /dev/null |