diff --git a/docs-core/pom.xml b/docs-core/pom.xml index 956decc5..f26794e2 100644 --- a/docs-core/pom.xml +++ b/docs-core/pom.xml @@ -5,7 +5,7 @@ com.sismics.docs docs-parent - 1.9 + 1.10-SNAPSHOT .. diff --git a/docs-stress/pom.xml b/docs-stress/pom.xml deleted file mode 100644 index 75e12807..00000000 --- a/docs-stress/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - com.sismics.docs - docs-parent - 1.9 - .. - - - 4.0.0 - docs-stress - jar - Docs Stress - - - - - org.glassfish.jersey.core - jersey-client - - - - org.glassfish.jersey.media - jersey-media-multipart - - - - - com.sismics.docs - docs-web-common - - - - com.sismics.docs - docs-web-common - test-jar - - - - - com.google.guava - guava - - - - log4j - log4j - - - - org.slf4j - slf4j-log4j12 - - - - org.slf4j - slf4j-api - - - - org.slf4j - jcl-over-slf4j - - - - junit - junit - - - - - - - - src/main/resources - - - - diff --git a/docs-stress/src/main/java/com/sismics/docs/stress/Main.java b/docs-stress/src/main/java/com/sismics/docs/stress/Main.java deleted file mode 100644 index 3a7f78fd..00000000 --- a/docs-stress/src/main/java/com/sismics/docs/stress/Main.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.sismics.docs.stress; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import com.google.common.io.Resources; -import com.sismics.docs.rest.util.ClientUtil; -import com.sismics.util.filter.TokenBasedSecurityFilter; -import org.glassfish.jersey.client.ClientResponse; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.json.JsonObject; -import javax.ws.rs.client.*; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response.Status; -import java.io.InputStream; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; - -/** - * Stress app for Teedy. - * - * @author bgamard - */ -public class Main { - /** - * Logger. - */ - private static final Logger log = LoggerFactory.getLogger(Main.class); - - private static final String API_URL = "http://localhost:9999/docs-web/api/"; - private static final int USER_COUNT = 50; - private static final int DOCUMENT_PER_USER_COUNT = 2000; - private static final int TAG_PER_USER_COUNT = 20; - private static final int FILE_PER_DOCUMENT_COUNT = 10; - - private static Client client = ClientBuilder.newClient(); - - private static Set userSet = Sets.newHashSet(); - - /** - * Entry point. - * - * @param args Args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - log.info("Starting stress test..."); - - WebTarget resource = client.target(API_URL); - ClientUtil clientUtil = new ClientUtil(resource); - - // Create users - for (int i = 0; i < USER_COUNT; i++) { - String username = generateString(); - clientUtil.createUser(username); - userSet.add(new User(username, (clientUtil.login(username)))); - log.info("Created user " + (i + 1) + "/" + USER_COUNT); - } - - // Create tags for each user - int tagCreatedCount = 1; - for (User user : userSet) { - Invocation.Builder tagResource = resource.path("/tag").request() - .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken); - - for (int j = 0; j < TAG_PER_USER_COUNT; j++) { - Form form = new Form(); - String name = generateString(); - form.param("name", name); - form.param("color", "#ff0000"); - JsonObject json = tagResource.put(Entity.form(form), JsonObject.class); - user.tagList.add(json.getString("id")); - log.info("Created tag " + (tagCreatedCount++) + "/" + TAG_PER_USER_COUNT * USER_COUNT); - } - } - - // Create documents for each user - int documentCreatedCount = 1; - for (User user : userSet) { - for (int i = 0; i < DOCUMENT_PER_USER_COUNT; i++) { - long createDate = new Date().getTime(); - Form form = new Form() - .param("title", generateString()) - .param("description", generateString()) - .param("tags", user.tagList.get(ThreadLocalRandom.current().nextInt(user.tagList.size()))) // Random tag - .param("language", "eng") - .param("create_date", Long.toString(createDate)); - JsonObject json = resource.path("/document").request() - .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken) - .put(Entity.form(form), JsonObject.class); - String documentId = json.getString("id"); - log.info("Created document " + (documentCreatedCount++) + "/" + DOCUMENT_PER_USER_COUNT * USER_COUNT + " for user: " + user.username); - - // Add files for each document - for (int j = 0; j < FILE_PER_DOCUMENT_COUNT; j++) { - try (InputStream is = Resources.getResource("empty.png").openStream()) { - StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("file", is, "empty.png"); - @SuppressWarnings("resource") - ClientResponse response = resource - .register(MultiPartFeature.class) - .path("/file").request() - .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken) - .put(Entity.entity(new FormDataMultiPart().field("id", documentId).bodyPart(streamDataBodyPart), - MediaType.MULTIPART_FORM_DATA_TYPE), ClientResponse.class); - Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus())); - } - } - } - } - } - - private static String generateString() { - return UUID.randomUUID().toString().replace("-", ""); - } - - private static class User { - String username; - List tagList = Lists.newArrayList(); - String authToken; - - User(String username, String authToken) { - this.username = username; - this.authToken = authToken; - } - } -} diff --git a/docs-stress/src/main/resources/empty.png b/docs-stress/src/main/resources/empty.png deleted file mode 100644 index cee81591..00000000 Binary files a/docs-stress/src/main/resources/empty.png and /dev/null differ diff --git a/docs-stress/src/main/resources/log4j.properties b/docs-stress/src/main/resources/log4j.properties deleted file mode 100644 index d7ea887b..00000000 --- a/docs-stress/src/main/resources/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootCategory=WARN, CONSOLE -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{DATE} %p %l %m %n - -log4j.logger.com.sismics=DEBUG diff --git a/docs-web-common/pom.xml b/docs-web-common/pom.xml index 903e2673..d6684215 100644 --- a/docs-web-common/pom.xml +++ b/docs-web-common/pom.xml @@ -5,7 +5,7 @@ com.sismics.docs docs-parent - 1.9 + 1.10-SNAPSHOT .. diff --git a/docs-web/pom.xml b/docs-web/pom.xml index dde15638..78699765 100644 --- a/docs-web/pom.xml +++ b/docs-web/pom.xml @@ -5,7 +5,7 @@ com.sismics.docs docs-parent - 1.9 + 1.10-SNAPSHOT .. diff --git a/pom.xml b/pom.xml index fa9a5290..c3d0bd6c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.sismics.docs docs-parent pom - 1.9 + 1.10-SNAPSHOT Docs Parent