Skip to content

Commit

Permalink
Merge pull request #18 from dhslrl321/fix-http-connection
Browse files Browse the repository at this point in the history
[#16] Fix http connection
  • Loading branch information
dhslrl321 authored Oct 10, 2022
2 parents 5dcc70c + 4ac83be commit 3e8485e
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ clean: ## gradle clean
test: clean ## gradle test

build: clean ## gradle build

run-server: java -jar zola-messaging-server/build/libs/zola-messaging-server-1.0.0.jar
3 changes: 3 additions & 0 deletions integration-tests/stress-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

- RPC call
- 1,000,000 개의 메시지를 enqueue 하는데 걸리는 시간
- 차수
1. 158947 (ms), 158 (s), 초당 6,329 개
2. 158792 (ms), 158 (s), 초당 6,329 개
- 1,000,000 개의 메시지를 dequeue 하는데 걸리는 시간
1 change: 1 addition & 0 deletions integration-tests/stress-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ dependencies {
}

test {
// exclude 'com/github/dhslrl321/zsmq/**'
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;

public class RpcCallEnqueueTest {
Expand Down Expand Up @@ -41,16 +42,17 @@ void tearDown() {
System.out.println(TOOK_MS_MESSAGE + diff + " (ms)");
}


@Test
@DisplayName("rpc call 1,000,000 messages")
@Disabled
void name() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE-", "dummy message, " + i));
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
void name2() {
@Order(0)
void cannot_be_triggered_by_automatic_build() {
fail("not support");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.github.dhslrl321.zsmq;

import static org.junit.jupiter.api.Assertions.fail;

import com.github.dhslrl321.zsmq.client.ZolaClientConfig;
import com.github.dhslrl321.zsmq.client.ZolaQueueMessageTemplate;
import com.github.dhslrl321.zsmq.http.ZolaHttpClient;
import java.util.stream.IntStream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;

public class RpcCallLoadEnqueueTest {

private static final int SIZE = 1_000_000;
public static final String TOOK_MS_MESSAGE = "test took (ms) : ";

ZolaQueueMessageTemplate sut;


long before;
long after;

@BeforeEach
void setUp() {
sut = new ZolaQueueMessageTemplate(
new ZolaClientConfig("http://localhost:8291"), new ZolaHttpClient());

before = System.currentTimeMillis();
}

@AfterEach
void tearDown() {
after = System.currentTimeMillis();
long diff = (after - before);
System.out.println(TOOK_MS_MESSAGE + diff + " (ms)");
}


@Test
@DisplayName("vUser(1) sending")
void vUser1() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(2) sending")
void vUser2() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(3) sending")
void vUser3() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(4) sending")
void vUser4() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(5) sending")
void vUser5() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(6) sending")
void vUser6() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(7) sending")
void vUser7() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(8) sending")
void vUser8() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("vUser(9) sending")
void vUser9() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@DisplayName("rvUser(0) sending")
void vUser10() {
IntStream.range(0, SIZE)
.forEach((i) -> sut.convertAndSend("TESTING-QUEUE", "dummy message, " + i));
}

@Test
@Order(0)
@Disabled
void cannot_be_triggered_by_automatic_build() {
fail("not support");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public boolean requestPush(String baseUrl, ZolaMessage message) {
.post(RequestBody.create(ZolaJsonSerializer.getInstance().serialize(message), JSON))
.build();
Call call = http.newCall(request);
try {
Response execute = call.execute();
validateResponse(execute.code(), message.getQueueNameValue());
try (Response response = call.execute()){
validateResponse(response.code(), message.getQueueNameValue());
return true;
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -43,8 +42,7 @@ public Optional<ZolaMessage> requestPeek(String baseUrl, String queueName) {
.get()
.build();
Call call = http.newCall(request);
try {
Response response = call.execute();
try (Response response = call.execute()){
validateResponse(response.code(), queueName);
if (NO_CONTENT == response.code()) {
return Optional.empty();
Expand All @@ -64,8 +62,7 @@ public boolean acknowledgement(String baseUrl, String queueName) {
.delete()
.build();
Call call = http.newCall(request);
try {
Response response = call.execute();
try (Response response = call.execute()){
validateResponse(response.code(), queueName);
return true;
} catch (Exception e) {
Expand Down

0 comments on commit 3e8485e

Please sign in to comment.