aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Marion <steve.marion@sonarsource.com>2024-07-31 11:02:18 +0200
committersonartech <sonartech@sonarsource.com>2024-08-12 20:02:45 +0000
commitb9f79022490910dc8b3ba4ea21b2b001479c7a47 (patch)
tree40ced3d82821da3de525c82ff1c31da764381145
parent294a5e6b07d412b1bd14b0a300e1fefdc94a939b (diff)
downloadsonarqube-b9f79022490910dc8b3ba4ea21b2b001479c7a47.tar.gz
sonarqube-b9f79022490910dc8b3ba4ea21b2b001479c7a47.zip
SONAR-22649 remove usage of id generator that are incompatible with a large volume of data generated asynchronously.
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java7
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java8
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java4
4 files changed, 13 insertions, 8 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
index 342d6b64e61..89221a2434d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
@@ -58,7 +58,7 @@ public class IssueTesting {
checkArgument(file.branchUuid().equals(projectUuid), "The file doesn't belong to the project");
return new IssueDto()
- .setKee("uuid_" + randomAlphabetic(5))
+ .setKee(UuidFactoryFast.getInstance().create())
.setRule(rule)
.setType(RuleType.values()[nextInt(RuleType.values().length)])
.setProjectUuid(projectUuid)
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java
index ac11529d44f..e5d99902d9c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java
@@ -71,7 +71,7 @@ public class AlmSettingDaoWithPersisterTest {
.extracting("devOpsPlatformSettingUuid", "key")
.containsExactly(almSettingDto.getUuid(), almSettingDto.getKey());
assertThat(newValue)
- .hasToString("{\"devOpsPlatformSettingUuid\": \"1\", \"key\": \"key\", \"devOpsPlatformName\": \"id1\", \"url\": \"url\", \"appId\": \"id1\", \"clientId\": \"cid1\" }");
+ .hasToString("{\"devOpsPlatformSettingUuid\": \""+almSettingDto.getUuid()+"\", \"key\": \""+almSettingDto.getKey()+"\", \"devOpsPlatformName\": \"id1\", \"url\": \"url\", \"appId\": \"id1\", \"clientId\": \"cid1\" }");
almSettingDto.setPrivateKey("updated private key");
almSettingDto.setAppId("updated app id");
@@ -90,8 +90,9 @@ public class AlmSettingDaoWithPersisterTest {
assertThat(newValue)
.extracting("devOpsPlatformSettingUuid", "key", "appId", "devOpsPlatformName", "url", "clientId")
.containsExactly(almSettingDto.getUuid(), almSettingDto.getKey(), almSettingDto.getAppId(), almSettingDto.getAppId(), almSettingDto.getUrl(), almSettingDto.getClientId());
- assertThat(newValue).hasToString("{\"devOpsPlatformSettingUuid\": \"1\", \"key\": \"updated key\", \"devOpsPlatformName\": \"updated app id\", "
- + "\"url\": \"updated url\", \"appId\": \"updated app id\", \"clientId\": \"cid1\" }");
+ assertThat(newValue).hasToString("{\"devOpsPlatformSettingUuid\": \""+almSettingDto.getUuid()+"\", \"key\": \""+almSettingDto.getKey()
+ +"\", \"devOpsPlatformName\": \""+almSettingDto.getAppId()+"\", "
+ + "\"url\": \""+almSettingDto.getUrl()+"\", \"appId\": \""+almSettingDto.getAppId()+"\", \"clientId\": \""+almSettingDto.getClientId()+"\" }");
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java
index 17206cf1808..07bd20d7fe1 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java
@@ -19,6 +19,8 @@
*/
package org.sonar.db.notification;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
@@ -100,8 +102,10 @@ public class NotificationQueueDaoTest {
db.commit();
assertThat(dao.selectOldest(3))
- .extracting(NotificationQueueDto::getUuid)
- .containsExactlyElementsOf(Arrays.asList("1", "2", "3"));
+ .extracting(NotificationQueueDto::getData)
+ .map(bytes -> new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject())
+ .extracting("type")
+ .containsExactlyElementsOf(List.of("foo_0", "foo_1", "foo_2"));
}
private List<String> selectAllUuid() {
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
index 3108082c4cf..c9e8783b46e 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java
@@ -29,8 +29,8 @@ import java.util.Map;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
-import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.core.util.UuidFactory;
+import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.alm.integration.pat.AlmPatsDbTester;
import org.sonar.db.almsettings.AlmSettingsDbTester;
import org.sonar.db.audit.AuditDbTester;
@@ -62,7 +62,7 @@ import org.sonar.db.webhook.WebhookDeliveryDbTester;
*/
public class DbTester extends AbstractDbTester<TestDbImpl> {
- private final UuidFactory uuidFactory = new SequenceUuidFactory();
+ private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();
private final System2 system2;
private final AuditPersister auditPersister;
private DbClient client;