"UPDATED_AT" BIGINT NOT NULL,
"EXECUTION_TIME_MS" BIGINT NULL,
"ERROR_MESSAGE" VARCHAR(1000),
- "ERROR_STACKTRACE" CLOB(2147483647)
+ "ERROR_STACKTRACE" CLOB(2147483647),
+ "ERROR_TYPE" VARCHAR(20)
);
CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID");
* @see CeActivityDao#selectByUuid(DbSession, String)
*/
private String errorStacktrace;
+
+ /**
+ * Optional free-text type of error. It may be set only when {@link #errorMessage} is not null.
+ */
+ @Nullable
+ private String errorType;
+
/**
* Flag indicating whether the analysis of the current activity has a scanner context or not.
* <p>
return this;
}
+ @CheckForNull
+ public String getErrorType() {
+ return errorType;
+ }
+
+ public CeActivityDto setErrorType(@Nullable String s) {
+ this.errorType = ensureNotTooBig(s, 20);
+ return this;
+ }
+
@CheckForNull
private static String ensureNotTooBig(@Nullable String str, int maxSize) {
if (str == null) {
ca.is_last_key as isLastKey,
ca.execution_time_ms as executionTimeMs,
ca.error_message as errorMessage,
+ ca.error_type as errorType,
<include refid="hasScannerContextColumn"/>
</sql>
updated_at,
execution_time_ms,
error_message,
- error_stacktrace
+ error_stacktrace,
+ error_type
)
values (
#{uuid,jdbcType=VARCHAR},
#{updatedAt,jdbcType=BIGINT},
#{executionTimeMs,jdbcType=BIGINT},
#{errorMessage,jdbcType=VARCHAR},
- #{errorStacktrace,jdbcType=CLOB}
+ #{errorStacktrace,jdbcType=CLOB},
+ #{errorType,jdbcType=VARCHAR}
)
</insert>
assertThat(dto.toString()).isNotEmpty();
assertThat(dto.getErrorMessage()).isNull();
assertThat(dto.getErrorStacktrace()).isNull();
+ assertThat(dto.getErrorType()).isNull();
assertThat(dto.isHasScannerContext()).isFalse();
}
CeActivityDto read = saved.get();
assertThat(read.getErrorMessage()).isEqualTo(dto.getErrorMessage());
assertThat(read.getErrorStacktrace()).isEqualTo(dto.getErrorStacktrace());
+ assertThat(read.getErrorType()).isNotNull().isEqualTo(dto.getErrorType());
}
@Test
dto.setAnalysisUuid(uuid + "_2");
if (status == FAILED) {
dto.setErrorMessage("error msg for " + uuid);
+ dto.setErrorType("anErrorType");
}
return dto;
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class AddErrorTypeColumnToCeActivityTable extends DdlChange {
+
+ public AddErrorTypeColumnToCeActivityTable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new AddColumnsBuilder(getDialect(), "ce_activity")
+ .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
+ .setColumnName("error_type")
+ .setLimit(20)
+ .setIsNullable(true)
+ .build())
+ .build());
+ }
+}
+
.add(1806, "Create table project_branches", CreateTableProjectBranches.class)
.add(1807, "Add on project_branches key", AddIndexOnProjectBranchesKey.class)
.add(1808, "Add branch column to projects table", AddBranchColumnToProjectsTable.class)
- .add(1809, "Populate project_branches with existing main branches", PopulateMainProjectBranches.class);
+ .add(1809, "Populate project_branches with existing main branches", PopulateMainProjectBranches.class)
+ .add(1810, "Add ce_activity.error_type", AddErrorTypeColumnToCeActivityTable.class)
+ ;
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+
+public class AddErrorTypeColumnToCeActivityTableTest {
+
+ @Rule
+ public final CoreDbTester dbTester = CoreDbTester.createForSchema(AddErrorTypeColumnToCeActivityTableTest.class, "ce_activity_6_5.sql");
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private AddErrorTypeColumnToCeActivityTable underTest = new AddErrorTypeColumnToCeActivityTable(dbTester.database());
+
+ @Test
+ public void column_is_added_to_table() throws SQLException {
+ underTest.execute();
+
+ dbTester.assertColumnDefinition("ce_activity", "error_type", java.sql.Types.VARCHAR, 20, true);
+ }
+
+ @Test
+ public void migration_is_not_reentrant() throws SQLException {
+ underTest.execute();
+
+ expectedException.expect(IllegalStateException.class);
+
+ underTest.execute();
+ }
+
+}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 9);
+ verifyMigrationCount(underTest, 10);
}
}
--- /dev/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,
+ "ANALYSIS_UUID" VARCHAR(50) NULL,
+ "STATUS" VARCHAR(15) NOT NULL,
+ "IS_LAST" BOOLEAN NOT NULL,
+ "IS_LAST_KEY" VARCHAR(55) NOT NULL,
+ "SUBMITTER_LOGIN" VARCHAR(255) NULL,
+ "WORKER_UUID" VARCHAR(40) NULL,
+ "EXECUTION_COUNT" INTEGER NOT NULL,
+ "SUBMITTED_AT" BIGINT NOT NULL,
+ "STARTED_AT" BIGINT NULL,
+ "EXECUTED_AT" BIGINT NULL,
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL,
+ "EXECUTION_TIME_MS" BIGINT NULL,
+ "ERROR_MESSAGE" VARCHAR(1000),
+ "ERROR_STACKTRACE" CLOB(2147483647)
+);