Create up to 10k max length forum posts for load testing.

This commit is contained in:
akwizgran
2025-05-02 15:04:11 +01:00
parent 070a0181d9
commit a03c65f944
2 changed files with 6 additions and 7 deletions

View File

@@ -174,7 +174,7 @@
android:id="@+id/seekBarForumMessages" android:id="@+id/seekBarForumMessages"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:max="50" android:max="10000"
android:paddingTop="5dp" android:paddingTop="5dp"
android:progress="20" android:progress="20"
app:layout_constraintEnd_toStartOf="@+id/TextViewForumMessagesSb" app:layout_constraintEnd_toStartOf="@+id/TextViewForumMessagesSb"

View File

@@ -470,20 +470,19 @@ public class TestDataCreatorImpl implements TestDataCreator {
private void createRandomForumPosts(Forum forum, List<Contact> contacts, private void createRandomForumPosts(Forum forum, List<Contact> contacts,
int numForumPosts) throws DbException { int numForumPosts) throws DbException {
List<ForumPost> posts = new ArrayList<>(); List<MessageId> postIds = new ArrayList<>();
for (int i = 0; i < numForumPosts; i++) { for (int i = 0; i < numForumPosts; i++) {
Contact contact = contacts.get(random.nextInt(contacts.size())); Contact contact = contacts.get(random.nextInt(contacts.size()));
LocalAuthor author = localAuthors.get(contact); LocalAuthor author = localAuthors.get(contact);
long timestamp = clock.currentTimeMillis() - (long) i * 60 * 1000; long timestamp = clock.currentTimeMillis() - (long) i * 60 * 1000;
String text = getRandomText(); String text = getRandomText();
MessageId parent = null; MessageId parent = null;
if (random.nextBoolean() && posts.size() > 0) { if (random.nextBoolean() && !postIds.isEmpty()) {
ForumPost parentPost = posts.get(random.nextInt(posts.size())); parent = postIds.get(random.nextInt(postIds.size()));
parent = parentPost.getMessage().getId();
} }
ForumPost post = forumManager.createLocalPost(forum.getId(), text, ForumPost post = forumManager.createLocalPost(forum.getId(), text,
timestamp, parent, author); timestamp, parent, author);
posts.add(post); postIds.add(post.getMessage().getId());
db.transaction(false, txn -> db.transaction(false, txn ->
db.receiveMessage(txn, contact.getId(), post.getMessage())); db.receiveMessage(txn, contact.getId(), post.getMessage()));
} }
@@ -573,7 +572,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
} }
private String getRandomText() { private String getRandomText() {
int minLength = 3 + random.nextInt(500); int minLength = 30_000;
int maxWordLength = 15; int maxWordLength = 15;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while (sb.length() < minLength) { while (sb.length() < minLength) {