Commit e25bd4f0dcafee2c40361fc1d61f663d82f15815
Committed by
GitHub
Merge pull request #34 from volodymyr-babak/master
Moved stress test to different repo
Showing
12 changed files
with
12 additions
and
511 deletions
@@ -29,9 +29,9 @@ app-dispatcher { | @@ -29,9 +29,9 @@ app-dispatcher { | ||
29 | executor = "fork-join-executor" | 29 | executor = "fork-join-executor" |
30 | fork-join-executor { | 30 | fork-join-executor { |
31 | # Min number of threads to cap factor-based parallelism number to | 31 | # Min number of threads to cap factor-based parallelism number to |
32 | - parallelism-min = 2 | 32 | + parallelism-min = 1 |
33 | # Max number of threads to cap factor-based parallelism number to | 33 | # Max number of threads to cap factor-based parallelism number to |
34 | - parallelism-max = 12 | 34 | + parallelism-max = 1 |
35 | 35 | ||
36 | # The parallelism factor is used to determine thread pool size using the | 36 | # The parallelism factor is used to determine thread pool size using the |
37 | # following formula: ceil(available processors * factor). Resulting size | 37 | # following formula: ceil(available processors * factor). Resulting size |
@@ -54,7 +54,7 @@ rpc-dispatcher { | @@ -54,7 +54,7 @@ rpc-dispatcher { | ||
54 | # Min number of threads to cap factor-based parallelism number to | 54 | # Min number of threads to cap factor-based parallelism number to |
55 | parallelism-min = 2 | 55 | parallelism-min = 2 |
56 | # Max number of threads to cap factor-based parallelism number to | 56 | # Max number of threads to cap factor-based parallelism number to |
57 | - parallelism-max = 12 | 57 | + parallelism-max = 8 |
58 | 58 | ||
59 | # The parallelism factor is used to determine thread pool size using the | 59 | # The parallelism factor is used to determine thread pool size using the |
60 | # following formula: ceil(available processors * factor). Resulting size | 60 | # following formula: ceil(available processors * factor). Resulting size |
@@ -82,7 +82,7 @@ core-dispatcher { | @@ -82,7 +82,7 @@ core-dispatcher { | ||
82 | # The parallelism factor is used to determine thread pool size using the | 82 | # The parallelism factor is used to determine thread pool size using the |
83 | # following formula: ceil(available processors * factor). Resulting size | 83 | # following formula: ceil(available processors * factor). Resulting size |
84 | # is then bounded by the parallelism-min and parallelism-max values. | 84 | # is then bounded by the parallelism-min and parallelism-max values. |
85 | - parallelism-factor = 1.0 | 85 | + parallelism-factor = 0.25 |
86 | } | 86 | } |
87 | # How long time the dispatcher will wait for new actors until it shuts down | 87 | # How long time the dispatcher will wait for new actors until it shuts down |
88 | shutdown-timeout = 1s | 88 | shutdown-timeout = 1s |
@@ -105,7 +105,7 @@ rule-dispatcher { | @@ -105,7 +105,7 @@ rule-dispatcher { | ||
105 | # The parallelism factor is used to determine thread pool size using the | 105 | # The parallelism factor is used to determine thread pool size using the |
106 | # following formula: ceil(available processors * factor). Resulting size | 106 | # following formula: ceil(available processors * factor). Resulting size |
107 | # is then bounded by the parallelism-min and parallelism-max values. | 107 | # is then bounded by the parallelism-min and parallelism-max values. |
108 | - parallelism-factor = 1.0 | 108 | + parallelism-factor = 0.25 |
109 | } | 109 | } |
110 | # How long time the dispatcher will wait for new actors until it shuts down | 110 | # How long time the dispatcher will wait for new actors until it shuts down |
111 | shutdown-timeout = 1s | 111 | shutdown-timeout = 1s |
@@ -128,7 +128,7 @@ plugin-dispatcher { | @@ -128,7 +128,7 @@ plugin-dispatcher { | ||
128 | # The parallelism factor is used to determine thread pool size using the | 128 | # The parallelism factor is used to determine thread pool size using the |
129 | # following formula: ceil(available processors * factor). Resulting size | 129 | # following formula: ceil(available processors * factor). Resulting size |
130 | # is then bounded by the parallelism-min and parallelism-max values. | 130 | # is then bounded by the parallelism-min and parallelism-max values. |
131 | - parallelism-factor = 1.0 | 131 | + parallelism-factor = 0.25 |
132 | } | 132 | } |
133 | # How long time the dispatcher will wait for new actors until it shuts down | 133 | # How long time the dispatcher will wait for new actors until it shuts down |
134 | shutdown-timeout = 1s | 134 | shutdown-timeout = 1s |
@@ -152,7 +152,7 @@ session-dispatcher { | @@ -152,7 +152,7 @@ session-dispatcher { | ||
152 | # The parallelism factor is used to determine thread pool size using the | 152 | # The parallelism factor is used to determine thread pool size using the |
153 | # following formula: ceil(available processors * factor). Resulting size | 153 | # following formula: ceil(available processors * factor). Resulting size |
154 | # is then bounded by the parallelism-min and parallelism-max values. | 154 | # is then bounded by the parallelism-min and parallelism-max values. |
155 | - parallelism-factor = 1.0 | 155 | + parallelism-factor = 0.25 |
156 | } | 156 | } |
157 | # How long time the dispatcher will wait for new actors until it shuts down | 157 | # How long time the dispatcher will wait for new actors until it shuts down |
158 | shutdown-timeout = 1s | 158 | shutdown-timeout = 1s |
@@ -167,7 +167,7 @@ actors: | @@ -167,7 +167,7 @@ actors: | ||
167 | # Cache parameters | 167 | # Cache parameters |
168 | cache: | 168 | cache: |
169 | # Enable/disable cache functionality. | 169 | # Enable/disable cache functionality. |
170 | - enabled: "${CACHE_ENABLED:true}" | 170 | + enabled: "${CACHE_ENABLED:false}" |
171 | device_credentials: | 171 | device_credentials: |
172 | # Default time to store device credentials in cache, in seconds | 172 | # Default time to store device credentials in cache, in seconds |
173 | time_to_live: "${CACHE_DEVICE_CREDENTIAL_TTL:3600}" | 173 | time_to_live: "${CACHE_DEVICE_CREDENTIAL_TTL:3600}" |
@@ -32,7 +32,7 @@ do | @@ -32,7 +32,7 @@ do | ||
32 | done | 32 | done |
33 | 33 | ||
34 | # Copying env variables into conf files | 34 | # Copying env variables into conf files |
35 | -printenv | while read x; do echo export $x; done >> /usr/share/thingsboard/conf/thingsboard.conf | 35 | +printenv | awk -F "=" '{print "export " $1 "='\''" $2 "'\''"}' >> /usr/share/thingsboard/conf/thingsboard.conf |
36 | 36 | ||
37 | cat /usr/share/thingsboard/conf/thingsboard.conf | 37 | cat /usr/share/thingsboard/conf/thingsboard.conf |
38 | 38 |
@@ -48,39 +48,8 @@ | @@ -48,39 +48,8 @@ | ||
48 | <groupId>org.eclipse.paho</groupId> | 48 | <groupId>org.eclipse.paho</groupId> |
49 | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | 49 | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> |
50 | </dependency> | 50 | </dependency> |
51 | - <dependency> | ||
52 | - <groupId>org.slf4j</groupId> | ||
53 | - <artifactId>slf4j-api</artifactId> | ||
54 | - </dependency> | ||
55 | - <dependency> | ||
56 | - <groupId>org.slf4j</groupId> | ||
57 | - <artifactId>log4j-over-slf4j</artifactId> | ||
58 | - </dependency> | ||
59 | - <dependency> | ||
60 | - <groupId>ch.qos.logback</groupId> | ||
61 | - <artifactId>logback-core</artifactId> | ||
62 | - </dependency> | ||
63 | - <dependency> | ||
64 | - <groupId>ch.qos.logback</groupId> | ||
65 | - <artifactId>logback-classic</artifactId> | ||
66 | - </dependency> | ||
67 | - <dependency> | ||
68 | - <groupId>org.springframework</groupId> | ||
69 | - <artifactId>spring-test</artifactId> | ||
70 | - </dependency> | ||
71 | - <dependency> | ||
72 | - <groupId>junit</groupId> | ||
73 | - <artifactId>junit</artifactId> | ||
74 | - <scope>test</scope> | ||
75 | - </dependency> | ||
76 | - <dependency> | ||
77 | - <groupId>org.mockito</groupId> | ||
78 | - <artifactId>mockito-all</artifactId> | ||
79 | - <scope>test</scope> | ||
80 | - </dependency> | ||
81 | </dependencies> | 51 | </dependencies> |
82 | 52 | ||
83 | - | ||
84 | <build> | 53 | <build> |
85 | <plugins> | 54 | <plugins> |
86 | <plugin> | 55 | <plugin> |
@@ -105,7 +74,7 @@ | @@ -105,7 +74,7 @@ | ||
105 | </filters> | 74 | </filters> |
106 | <transformers> | 75 | <transformers> |
107 | <transformer | 76 | <transformer |
108 | - implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | 77 | + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> |
109 | <manifestEntries> | 78 | <manifestEntries> |
110 | <Main-Class>org.thingsboard.client.tools.MqttStressTestTool</Main-Class> | 79 | <Main-Class>org.thingsboard.client.tools.MqttStressTestTool</Main-Class> |
111 | </manifestEntries> | 80 | </manifestEntries> |
tools/src/main/java/org/thingsboard/client/tools/MqttStressTestClient.java
deleted
100644 → 0
1 | -/** | ||
2 | - * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.thingsboard.client.tools; /** | ||
17 | - * Copyright © 2016 The Thingsboard Authors | ||
18 | - * | ||
19 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
20 | - * you may not use this file except in compliance with the License. | ||
21 | - * You may obtain a copy of the License at | ||
22 | - * | ||
23 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
24 | - * | ||
25 | - * Unless required by applicable law or agreed to in writing, software | ||
26 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
27 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
28 | - * See the License for the specific language governing permissions and | ||
29 | - * limitations under the License. | ||
30 | - */ | ||
31 | -import lombok.Getter; | ||
32 | -import lombok.extern.slf4j.Slf4j; | ||
33 | -import org.eclipse.paho.client.mqttv3.*; | ||
34 | -import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; | ||
35 | - | ||
36 | -/** | ||
37 | - * @author Andrew Shvayka | ||
38 | - */ | ||
39 | -@Slf4j | ||
40 | -public class MqttStressTestClient { | ||
41 | - | ||
42 | - @Getter | ||
43 | - private final String deviceToken; | ||
44 | - @Getter | ||
45 | - private final String clientId; | ||
46 | - private final MqttClientPersistence persistence; | ||
47 | - private final MqttAsyncClient client; | ||
48 | - private final ResultAccumulator results; | ||
49 | - | ||
50 | - public MqttStressTestClient(ResultAccumulator results, String brokerUri, String deviceToken) throws MqttException { | ||
51 | - this.results = results; | ||
52 | - this.clientId = MqttAsyncClient.generateClientId(); | ||
53 | - this.deviceToken = deviceToken; | ||
54 | - this.persistence = new MemoryPersistence(); | ||
55 | - this.client = new MqttAsyncClient(brokerUri, clientId, persistence); | ||
56 | - } | ||
57 | - | ||
58 | - public IMqttToken connect() throws MqttException { | ||
59 | - MqttConnectOptions options = new MqttConnectOptions(); | ||
60 | - options.setUserName(deviceToken); | ||
61 | - return client.connect(options, null, new IMqttActionListener() { | ||
62 | - @Override | ||
63 | - public void onSuccess(IMqttToken iMqttToken) { | ||
64 | - log.info("OnSuccess"); | ||
65 | - } | ||
66 | - | ||
67 | - @Override | ||
68 | - public void onFailure(IMqttToken iMqttToken, Throwable e) { | ||
69 | - log.info("OnFailure", e); | ||
70 | - } | ||
71 | - }); | ||
72 | - } | ||
73 | - | ||
74 | - public void disconnect() throws MqttException { | ||
75 | - client.disconnect(); | ||
76 | - } | ||
77 | - | ||
78 | - | ||
79 | - | ||
80 | - public void warmUp(byte[] data) throws MqttException { | ||
81 | - MqttMessage msg = new MqttMessage(data); | ||
82 | - client.publish("v1/devices/me/telemetry", msg, null, new IMqttActionListener() { | ||
83 | - @Override | ||
84 | - public void onSuccess(IMqttToken asyncActionToken) { | ||
85 | - } | ||
86 | - | ||
87 | - @Override | ||
88 | - public void onFailure(IMqttToken asyncActionToken, Throwable exception) { | ||
89 | - } | ||
90 | - }).waitForCompletion(); | ||
91 | - } | ||
92 | - | ||
93 | - | ||
94 | - public void publishTelemetry(byte[] data) throws MqttException { | ||
95 | - long sendTime = System.currentTimeMillis(); | ||
96 | - MqttMessage msg = new MqttMessage(data); | ||
97 | - client.publish("v1/devices/me/telemetry", msg, null, new IMqttActionListener() { | ||
98 | - @Override | ||
99 | - public void onSuccess(IMqttToken asyncActionToken) { | ||
100 | - long ackTime = System.currentTimeMillis(); | ||
101 | - results.onResult(true, ackTime - sendTime); | ||
102 | - } | ||
103 | - | ||
104 | - @Override | ||
105 | - public void onFailure(IMqttToken asyncActionToken, Throwable exception) { | ||
106 | - long failTime = System.currentTimeMillis(); | ||
107 | - results.onResult(false, failTime - sendTime); | ||
108 | - } | ||
109 | - }); | ||
110 | - } | ||
111 | -} |
tools/src/main/java/org/thingsboard/client/tools/MqttStressTestTool.java
deleted
100644 → 0
1 | -/** | ||
2 | - * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.thingsboard.client.tools; /** | ||
17 | - * Copyright © 2016 The Thingsboard Authors | ||
18 | - * <p> | ||
19 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
20 | - * you may not use this file except in compliance with the License. | ||
21 | - * You may obtain a copy of the License at | ||
22 | - * <p> | ||
23 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
24 | - * <p> | ||
25 | - * Unless required by applicable law or agreed to in writing, software | ||
26 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
27 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
28 | - * See the License for the specific language governing permissions and | ||
29 | - * limitations under the License. | ||
30 | - */ | ||
31 | - | ||
32 | -import lombok.extern.slf4j.Slf4j; | ||
33 | -import org.eclipse.paho.client.mqttv3.IMqttToken; | ||
34 | -import org.thingsboard.server.common.data.Device; | ||
35 | -import org.thingsboard.server.common.data.security.DeviceCredentials; | ||
36 | - | ||
37 | -import java.nio.charset.StandardCharsets; | ||
38 | -import java.util.ArrayList; | ||
39 | -import java.util.List; | ||
40 | -import java.util.UUID; | ||
41 | -import java.util.concurrent.*; | ||
42 | -import java.util.concurrent.atomic.AtomicLong; | ||
43 | - | ||
44 | -/** | ||
45 | - * @author Andrew Shvayka | ||
46 | - */ | ||
47 | -@Slf4j | ||
48 | -public class MqttStressTestTool { | ||
49 | - | ||
50 | - public static void main(String[] args) throws Exception { | ||
51 | - TestParams params = new TestParams(); | ||
52 | - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10); | ||
53 | - | ||
54 | - | ||
55 | - if (params.getDuration() % params.getIterationInterval() != 0) { | ||
56 | - throw new IllegalArgumentException("Test Duration % Iteration Interval != 0"); | ||
57 | - } | ||
58 | - | ||
59 | - if ((params.getIterationInterval() * 1000) % params.getDeviceCount() != 0) { | ||
60 | - throw new IllegalArgumentException("Iteration Interval % Device Count != 0"); | ||
61 | - } | ||
62 | - | ||
63 | - ResultAccumulator results = new ResultAccumulator(); | ||
64 | - | ||
65 | - AtomicLong value = new AtomicLong(Long.MAX_VALUE); | ||
66 | - log.info("value: {} ", value.incrementAndGet()); | ||
67 | - | ||
68 | - RestClient restClient = new RestClient(params.getRestApiUrl()); | ||
69 | - restClient.login(params.getUsername(), params.getPassword()); | ||
70 | - | ||
71 | - List<MqttStressTestClient> clients = new ArrayList<>(); | ||
72 | - List<IMqttToken> connectTokens = new ArrayList<>(); | ||
73 | - for (int i = 0; i < params.getDeviceCount(); i++) { | ||
74 | - Device device = restClient.createDevice("Device " + UUID.randomUUID()); | ||
75 | - DeviceCredentials credentials = restClient.getCredentials(device.getId()); | ||
76 | - String[] mqttUrls = params.getMqttUrls(); | ||
77 | - String mqttURL = mqttUrls[i % mqttUrls.length]; | ||
78 | - MqttStressTestClient client = new MqttStressTestClient(results, mqttURL, credentials.getCredentialsId()); | ||
79 | - connectTokens.add(client.connect()); | ||
80 | - clients.add(client); | ||
81 | - } | ||
82 | - | ||
83 | - for (IMqttToken tokens : connectTokens) { | ||
84 | - tokens.waitForCompletion(); | ||
85 | - } | ||
86 | - | ||
87 | - byte[] data = "{\"longKey\":73}".getBytes(StandardCharsets.UTF_8); | ||
88 | - | ||
89 | - for (MqttStressTestClient client : clients) { | ||
90 | - client.warmUp(data); | ||
91 | - } | ||
92 | - | ||
93 | - Thread.sleep(1000); | ||
94 | - | ||
95 | - long startTime = System.currentTimeMillis(); | ||
96 | - int iterationsCount = (int) (params.getDuration() / params.getIterationInterval()); | ||
97 | - int subIterationMicroSeconds = (int) ((params.getIterationInterval() * 1000) / params.getDeviceCount()); | ||
98 | - | ||
99 | - List<ScheduledFuture<Void>> iterationFutures = new ArrayList<>(); | ||
100 | - for (int i = 0; i < iterationsCount; i++) { | ||
101 | - long delay = i * params.getIterationInterval(); | ||
102 | - iterationFutures.add(scheduler.schedule((Callable<Void>) () -> { | ||
103 | - long sleepMicroSeconds = 0L; | ||
104 | - for (MqttStressTestClient client : clients) { | ||
105 | - client.publishTelemetry(data); | ||
106 | - sleepMicroSeconds += subIterationMicroSeconds; | ||
107 | - if (sleepMicroSeconds > 1000) { | ||
108 | - Thread.sleep(sleepMicroSeconds / 1000); | ||
109 | - sleepMicroSeconds = sleepMicroSeconds % 1000; | ||
110 | - } | ||
111 | - } | ||
112 | - return null; | ||
113 | - }, delay, TimeUnit.MILLISECONDS)); | ||
114 | - } | ||
115 | - | ||
116 | - for (ScheduledFuture<Void> future : iterationFutures) { | ||
117 | - future.get(); | ||
118 | - } | ||
119 | - | ||
120 | - Thread.sleep(1000); | ||
121 | - | ||
122 | - for (MqttStressTestClient client : clients) { | ||
123 | - client.disconnect(); | ||
124 | - } | ||
125 | - log.info("Results: {} took {}ms", results, System.currentTimeMillis() - startTime); | ||
126 | - scheduler.shutdownNow(); | ||
127 | - } | ||
128 | - | ||
129 | -} |
@@ -13,25 +13,10 @@ | @@ -13,25 +13,10 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.client.tools; /** | ||
17 | - * Copyright © 2016 The Thingsboard Authors | ||
18 | - * | ||
19 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
20 | - * you may not use this file except in compliance with the License. | ||
21 | - * You may obtain a copy of the License at | ||
22 | - * | ||
23 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
24 | - * | ||
25 | - * Unless required by applicable law or agreed to in writing, software | ||
26 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
27 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
28 | - * See the License for the specific language governing permissions and | ||
29 | - * limitations under the License. | ||
30 | - */ | 16 | +package org.thingsboard.client.tools; |
17 | + | ||
31 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
32 | import lombok.RequiredArgsConstructor; | 19 | import lombok.RequiredArgsConstructor; |
33 | -import org.springframework.http.HttpEntity; | ||
34 | -import org.springframework.http.HttpHeaders; | ||
35 | import org.springframework.http.HttpRequest; | 20 | import org.springframework.http.HttpRequest; |
36 | import org.springframework.http.ResponseEntity; | 21 | import org.springframework.http.ResponseEntity; |
37 | import org.springframework.http.client.ClientHttpRequestExecution; | 22 | import org.springframework.http.client.ClientHttpRequestExecution; |
tools/src/main/java/org/thingsboard/client/tools/ResultAccumulator.java
deleted
100644 → 0
1 | -/** | ||
2 | - * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.thingsboard.client.tools; /** | ||
17 | - * Copyright © 2016 The Thingsboard Authors | ||
18 | - * | ||
19 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
20 | - * you may not use this file except in compliance with the License. | ||
21 | - * You may obtain a copy of the License at | ||
22 | - * | ||
23 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
24 | - * | ||
25 | - * Unless required by applicable law or agreed to in writing, software | ||
26 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
27 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
28 | - * See the License for the specific language governing permissions and | ||
29 | - * limitations under the License. | ||
30 | - */ | ||
31 | -import lombok.extern.slf4j.Slf4j; | ||
32 | - | ||
33 | -import java.util.concurrent.atomic.AtomicInteger; | ||
34 | -import java.util.concurrent.atomic.AtomicLong; | ||
35 | - | ||
36 | -/** | ||
37 | - * @author Andrew Shvayka | ||
38 | - */ | ||
39 | -@Slf4j | ||
40 | -public class ResultAccumulator { | ||
41 | - | ||
42 | - private AtomicLong minTime = new AtomicLong(Long.MAX_VALUE); | ||
43 | - private AtomicLong maxTime = new AtomicLong(Long.MIN_VALUE); | ||
44 | - private AtomicLong timeSpentCount = new AtomicLong(); | ||
45 | - private AtomicInteger successCount = new AtomicInteger(); | ||
46 | - private AtomicInteger errorCount = new AtomicInteger(); | ||
47 | - | ||
48 | - public void onResult(boolean success, long timeSpent) { | ||
49 | - if (success) { | ||
50 | - successCount.incrementAndGet(); | ||
51 | - } else { | ||
52 | - errorCount.incrementAndGet(); | ||
53 | - } | ||
54 | - timeSpentCount.addAndGet(timeSpent); | ||
55 | - | ||
56 | - while (!setMax(timeSpent)) ; | ||
57 | - while (!setMin(timeSpent)) ; | ||
58 | - } | ||
59 | - | ||
60 | - private boolean setMax(long timeSpent) { | ||
61 | - long curMax = maxTime.get(); | ||
62 | - long newMax = Math.max(curMax, timeSpent); | ||
63 | - return maxTime.compareAndSet(curMax, newMax); | ||
64 | - } | ||
65 | - | ||
66 | - private boolean setMin(long timeSpent) { | ||
67 | - long curMin = minTime.get(); | ||
68 | - long newMin = Math.min(curMin, timeSpent); | ||
69 | - return minTime.compareAndSet(curMin, newMin); | ||
70 | - } | ||
71 | - | ||
72 | - | ||
73 | - public int getSuccessCount() { | ||
74 | - return successCount.get(); | ||
75 | - } | ||
76 | - | ||
77 | - public int getErrorCount() { | ||
78 | - return errorCount.get(); | ||
79 | - } | ||
80 | - | ||
81 | - public long getTimeSpent() { | ||
82 | - return timeSpentCount.get(); | ||
83 | - } | ||
84 | - | ||
85 | - public double getAvgTimeSpent() { | ||
86 | - return ((double) getTimeSpent()) / (getSuccessCount() + getErrorCount()); | ||
87 | - } | ||
88 | - | ||
89 | - @Override | ||
90 | - public String toString() { | ||
91 | - return "Result {" + | ||
92 | - "successCount=" + getSuccessCount() + | ||
93 | - ", errorCount=" + getErrorCount() + | ||
94 | - ", totalTime=" + getTimeSpent() + | ||
95 | - ", avgTime=" + getAvgTimeSpent() + | ||
96 | - ", minTime=" + minTime.get() + | ||
97 | - ", maxTime=" + maxTime.get() + | ||
98 | - '}'; | ||
99 | - } | ||
100 | -} |
tools/src/main/java/org/thingsboard/client/tools/TestParams.java
deleted
100644 → 0
1 | -/** | ||
2 | - * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | -package org.thingsboard.client.tools; | ||
17 | - | ||
18 | -import lombok.extern.slf4j.Slf4j; | ||
19 | - | ||
20 | -import java.io.FileInputStream; | ||
21 | -import java.io.IOException; | ||
22 | -import java.util.Properties; | ||
23 | -import java.util.concurrent.TimeUnit; | ||
24 | - | ||
25 | -@Slf4j | ||
26 | -public class TestParams { | ||
27 | - static final String TEST_PROPERTIES = "test.properties"; | ||
28 | - static final long DEFAULT_TEST_DURATION = TimeUnit.MINUTES.toMillis(1); | ||
29 | - static final long DEFAULT_TEST_INTERVAL = TimeUnit.MILLISECONDS.toMillis(100); | ||
30 | - static final int DEFAULT_DEVICE_COUNT = 100; | ||
31 | - static final String DEFAULT_REST_URL = "http://localhost:8080"; | ||
32 | - static final String DEFAULT_MQTT_URLS = "tcp://localhost:1883"; | ||
33 | - static final String DEFAULT_USERNAME = "tenant@thingsboard.org"; | ||
34 | - static final String DEFAULT_PASSWORD = "tenant"; | ||
35 | - | ||
36 | - private Properties params = new Properties(); | ||
37 | - | ||
38 | - public TestParams() throws IOException { | ||
39 | - try { | ||
40 | - params.load(new FileInputStream(TEST_PROPERTIES)); | ||
41 | - } catch (Exception e) { | ||
42 | - log.warn("Failed to read " + TEST_PROPERTIES); | ||
43 | - } | ||
44 | - } | ||
45 | - | ||
46 | - public long getDuration() { | ||
47 | - return Long.valueOf(params.getProperty("durationMs", Long.toString(DEFAULT_TEST_DURATION))); | ||
48 | - } | ||
49 | - | ||
50 | - public long getIterationInterval() { | ||
51 | - return Long.valueOf(params.getProperty("iterationIntervalMs", Long.toString(DEFAULT_TEST_INTERVAL))); | ||
52 | - } | ||
53 | - | ||
54 | - public int getDeviceCount() { | ||
55 | - return Integer.valueOf(params.getProperty("deviceCount", Integer.toString(DEFAULT_DEVICE_COUNT))); | ||
56 | - } | ||
57 | - | ||
58 | - public String getRestApiUrl() { | ||
59 | - return params.getProperty("restUrl", DEFAULT_REST_URL); | ||
60 | - } | ||
61 | - | ||
62 | - public String[] getMqttUrls() { | ||
63 | - return params.getProperty("mqttUrls", DEFAULT_MQTT_URLS).split(","); | ||
64 | - } | ||
65 | - | ||
66 | - public String getUsername() { | ||
67 | - return params.getProperty("username", DEFAULT_USERNAME); | ||
68 | - } | ||
69 | - | ||
70 | - public String getPassword() { | ||
71 | - return params.getProperty("password", DEFAULT_PASSWORD); | ||
72 | - } | ||
73 | -} |
tools/src/main/resources/logback.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | -<!-- | ||
3 | - | ||
4 | - Copyright © 2016-2017 The Thingsboard Authors | ||
5 | - | ||
6 | - Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | - you may not use this file except in compliance with the License. | ||
8 | - You may obtain a copy of the License at | ||
9 | - | ||
10 | - http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | - | ||
12 | - Unless required by applicable law or agreed to in writing, software | ||
13 | - distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | - See the License for the specific language governing permissions and | ||
16 | - limitations under the License. | ||
17 | - | ||
18 | ---> | ||
19 | -<!DOCTYPE configuration> | ||
20 | -<configuration> | ||
21 | - | ||
22 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
23 | - <encoder> | ||
24 | - <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
25 | - </encoder> | ||
26 | - </appender> | ||
27 | - | ||
28 | - <logger name="org.thingsboard" level="INFO" /> | ||
29 | - | ||
30 | - <root level="INFO"> | ||
31 | - <appender-ref ref="STDOUT"/> | ||
32 | - </root> | ||
33 | - | ||
34 | -</configuration> |
tools/src/main/resources/test.properties
deleted
100644 → 0
@@ -76,7 +76,6 @@ public class MqttTransportService { | @@ -76,7 +76,6 @@ public class MqttTransportService { | ||
76 | 76 | ||
77 | @PostConstruct | 77 | @PostConstruct |
78 | public void init() throws Exception { | 78 | public void init() throws Exception { |
79 | - ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED); | ||
80 | log.info("Starting MQTT transport..."); | 79 | log.info("Starting MQTT transport..."); |
81 | log.info("Lookup MQTT transport adaptor {}", adaptorName); | 80 | log.info("Lookup MQTT transport adaptor {}", adaptorName); |
82 | this.adaptor = (MqttTransportAdaptor) appContext.getBean(adaptorName); | 81 | this.adaptor = (MqttTransportAdaptor) appContext.getBean(adaptorName); |