Skip to content

Commit

Permalink
refactor(:core:test): fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zero88 committed Aug 5, 2024
1 parent de69af8 commit cd0ed6e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
8 changes: 5 additions & 3 deletions core/src/main/java/cloud/playio/qwe/QWEBootConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.vertx.core.metrics.MetricsOptions;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.core.tracing.TracingOptions;

import cloud.playio.qwe.cluster.ClusterType;
import cloud.playio.qwe.launcher.BootCommand;
import cloud.playio.qwe.utils.NetworkUtils;
Expand Down Expand Up @@ -58,7 +59,7 @@ public final class QWEBootConfig extends VertxOptions implements IConfig {
@Accessors(chain = true)
private JsonObject keyStoreConfig;

public QWEBootConfig() {this.delegate = defVertxOpts();}
public QWEBootConfig() { this.delegate = defVertxOpts(); }

@JsonCreator
public QWEBootConfig(Map<String, Object> map) {
Expand Down Expand Up @@ -93,14 +94,15 @@ public QWEBootConfig setClusterConfigFile(String clusterConfigFile) {
private VertxOptions defVertxOpts() {
return new VertxOptions().setHAGroup(DEFAULT_HA_GROUP)
.setEventBusOptions(defEventBusOpts())
.setEventLoopPoolSize(8)
.setFileSystemOptions(defFileSysOpts());
}

@Override
public String configKey() {return QWEConfig.BOOT_CONF_KEY;}
public String configKey() { return QWEConfig.BOOT_CONF_KEY; }

@Override
public Class<? extends IConfig> parent() {return QWEConfig.class;}
public Class<? extends IConfig> parent() { return QWEConfig.class; }

@Override
public JsonObject toJson() {
Expand Down
20 changes: 11 additions & 9 deletions core/src/test/java/cloud/playio/qwe/QWEConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.junit.jupiter.api.Test;

import io.vertx.core.DeploymentOptions;
import io.vertx.core.ThreadingModel;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.JsonObject;

import cloud.playio.qwe.QWEConfig.QWEDeployConfig;
import cloud.playio.qwe.exceptions.ConfigException;

Expand Down Expand Up @@ -71,7 +73,7 @@ public void test_deserialize_child_from_root() {
Assertions.assertEquals(10, cfg.getInstances());
Assertions.assertEquals(60000000000L, cfg.getMaxWorkerExecuteTime());
Assertions.assertEquals(TimeUnit.NANOSECONDS, cfg.getMaxWorkerExecuteTimeUnit());
Assertions.assertFalse(cfg.isWorker());
Assertions.assertEquals(ThreadingModel.EVENT_LOOP, cfg.getThreadingModel());
}

@Test
Expand All @@ -94,10 +96,10 @@ public void test_blank() {
Assertions.assertNotNull(cfg.getAppConfig().dataDir());
Assertions.assertTrue(cfg.getAppConfig().other().isEmpty());
Assertions.assertNotNull(cfg.getDeployConfig());
JsonHelper.assertJson(new JsonObject("{\"worker\":false,\"workerPoolSize\":20," +
"\"maxWorkerExecuteTime\":60000000000,\"ha\":false,\"instances\":1," +
"\"maxWorkerExecuteTimeUnit\":\"NANOSECONDS\"}"),
cfg.getDeployConfig().toJson());
JsonHelper.assertJson(new JsonObject(
"{\"worker\":false,\"workerPoolSize\":20,\"threadingModel\":\"EVENT_LOOP\"," +
"\"maxWorkerExecuteTime\":60000000000,\"ha\":false,\"instances\":1," +
"\"maxWorkerExecuteTimeUnit\":\"NANOSECONDS\"}"), cfg.getDeployConfig().toJson());
Assertions.assertNull(cfg.getBootConfig());
}

Expand All @@ -110,10 +112,10 @@ public void test_blank_with_app_cfg() {
Assertions.assertEquals(1, config.getAppConfig().other().size());
Assertions.assertEquals(1, config.getAppConfig().lookup("hello"));
Assertions.assertNotNull(config.getDeployConfig());
JsonHelper.assertJson(new JsonObject("{\"worker\":false,\"workerPoolSize\":20," +
"\"maxWorkerExecuteTime\":60000000000,\"ha\":false,\"instances\":1," +
"\"maxWorkerExecuteTimeUnit\":\"NANOSECONDS\"}"),
config.getDeployConfig().toJson());
JsonHelper.assertJson(new JsonObject(
"{\"worker\":false,\"workerPoolSize\":20,\"threadingModel\":\"EVENT_LOOP\"," +
"\"maxWorkerExecuteTime\":60000000000,\"ha\":false,\"instances\":1," +
"\"maxWorkerExecuteTimeUnit\":\"NANOSECONDS\"}"), config.getDeployConfig().toJson());
Assertions.assertNull(config.getBootConfig());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class NetworkUtilsTest {

@Test
public void test_get_public_ipv4() {
Assertions.assertNotNull(NetworkUtils.getPublicIpv4());
final String address = NetworkUtils.getPublicIpv4();
System.out.println(address);
Assertions.assertNotNull(address);
}

@Test
Expand All @@ -18,8 +20,8 @@ public void test_get_socket_ipv4_address() {
Assertions.assertNotNull(address);
Assertions.assertEquals("127.0.0.1", address.getHostName());
Assertions.assertEquals("127.0.0.1", address.getHostString());
Assertions.assertEquals("127.0.0.1:9090", address.toString());
Assertions.assertEquals(9090, address.getPort());
Assertions.assertEquals("127.0.0.1/<unresolved>:9090", address.toString());
}

}
7 changes: 3 additions & 4 deletions core/src/test/resources/def-system-cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
"crlValues": [],
"enabledCipherSuites": [],
"enabledSecureTransportProtocols": [
"TLSv1",
"TLSv1.1",
"TLSv1.2"
"TLSv1.2",
"TLSv1.3"
],
"idleTimeout": 0,
"idleTimeoutUnit": "SECONDS",
Expand All @@ -51,7 +50,7 @@
"trustAll": true,
"useAlpn": false
},
"eventLoopPoolSize": 32,
"eventLoopPoolSize": 8,
"fileSystemOptions": {
"classPathResolvingEnabled": true,
"fileCacheDir": "/tmp/qwe-cache",
Expand Down
7 changes: 3 additions & 4 deletions core/src/test/resources/full-system-cfg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"__system__": {
"eventLoopPoolSize": 32,
"eventLoopPoolSize": 8,
"workerPoolSize": 20,
"internalBlockingPoolSize": 20,
"blockedThreadCheckInterval": 1000,
Expand Down Expand Up @@ -36,9 +36,8 @@
"crlValues": [],
"useAlpn": false,
"enabledSecureTransportProtocols": [
"TLSv1",
"TLSv1.1",
"TLSv1.2"
"TLSv1.2",
"TLSv1.3"
],
"tcpFastOpen": false,
"tcpCork": false,
Expand Down

0 comments on commit cd0ed6e

Please sign in to comment.