@gatling.io/mqtt 3.14.400
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +19 -0
- package/jest.config.js +5 -0
- package/package.json +42 -0
- package/target/connect.d.ts +7 -0
- package/target/connect.js +7 -0
- package/target/index.d.ts +87 -0
- package/target/index.js +50 -0
- package/target/lastWill.d.ts +51 -0
- package/target/lastWill.js +17 -0
- package/target/message.d.ts +31 -0
- package/target/message.js +25 -0
- package/target/protocol.d.ts +195 -0
- package/target/protocol.js +67 -0
- package/target/publish.d.ts +121 -0
- package/target/publish.js +64 -0
- package/target/subscribe.d.ts +74 -0
- package/target/subscribe.js +34 -0
- package/target/wait.d.ts +12 -0
- package/target/wait.js +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Gatling JS - MQTT module
|
|
2
|
+
|
|
3
|
+
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
|
|
4
|
+
|
|
5
|
+
This package contains the Gatling JS DSL for [the MQTT protocol](https://docs.gatling.io/reference/script/mqtt/protocol/).
|
|
6
|
+
|
|
7
|
+
To get started with Gatling JS, see our [introduction to JavaScript scripting](https://docs.gatling.io/tutorials/scripting-intro-js);
|
|
8
|
+
or simply have a look at our demo projects:
|
|
9
|
+
|
|
10
|
+
- https://github.com/gatling/gatling-js-demo
|
|
11
|
+
- https://github.com/gatling/gatling-mqtt-demo
|
|
12
|
+
|
|
13
|
+
## Questions, help?
|
|
14
|
+
|
|
15
|
+
Read the [documentation](https://docs.gatling.io).
|
|
16
|
+
|
|
17
|
+
Join the [Gatling Community Forum](https://community.gatling.io).
|
|
18
|
+
|
|
19
|
+
Found a real bug? Raise an [issue](https://github.com/gatling/gatling/issues).
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gatling.io/mqtt",
|
|
3
|
+
"version": "3.14.400",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"homepage": "https://gatling.io",
|
|
6
|
+
"repository": "github:gatling/gatling-js",
|
|
7
|
+
"bugs": "https://github.com/gatling/gatling/issues",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"gatling",
|
|
10
|
+
"typescript",
|
|
11
|
+
"test",
|
|
12
|
+
"testing",
|
|
13
|
+
"loadtest",
|
|
14
|
+
"loadtesting",
|
|
15
|
+
"load test",
|
|
16
|
+
"load testing",
|
|
17
|
+
"performance test",
|
|
18
|
+
"performance testing"
|
|
19
|
+
],
|
|
20
|
+
"main": "target/index.js",
|
|
21
|
+
"types": "target/index.d.ts",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@gatling.io/core": "3.14.400",
|
|
24
|
+
"@gatling.io/jvm-types": "3.14.400"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "30.0.0",
|
|
28
|
+
"jest": "30.1.3",
|
|
29
|
+
"prettier": "3.6.2",
|
|
30
|
+
"rimraf": "6.0.1",
|
|
31
|
+
"ts-jest": "29.4.1",
|
|
32
|
+
"ts-node": "10.9.2",
|
|
33
|
+
"typescript": "5.9.2"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"clean": "rimraf target",
|
|
37
|
+
"format": "prettier --write '**/*.ts'",
|
|
38
|
+
"format-check": "prettier --check '**/*.ts'",
|
|
39
|
+
"test": "jest",
|
|
40
|
+
"build": "tsc -p ."
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionBuilder } from "@gatling.io/core";
|
|
2
|
+
import JvmConnectActionBuilder = io.gatling.javaapi.mqtt.ConnectActionBuilder;
|
|
3
|
+
/** The builder for connect action */
|
|
4
|
+
export interface ConnectActionBuilder extends ActionBuilder {
|
|
5
|
+
_underlying: JvmConnectActionBuilder;
|
|
6
|
+
}
|
|
7
|
+
export declare const wrapConnectActionBuilder: (_underlying: JvmConnectActionBuilder) => ConnectActionBuilder;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ActionBuilder, Expression, Session } from "@gatling.io/core";
|
|
2
|
+
import { ConnectActionBuilder } from "./connect";
|
|
3
|
+
import { MqttInboundMessage } from "./message";
|
|
4
|
+
import { MqttProtocolBuilder } from "./protocol";
|
|
5
|
+
import { PublishActionBuilder } from "./publish";
|
|
6
|
+
import { SubscribeActionBuilder } from "./subscribe";
|
|
7
|
+
import { WaitForMessagesActionBuilder } from "./wait";
|
|
8
|
+
export * from "./connect";
|
|
9
|
+
export * from "./lastWill";
|
|
10
|
+
export * from "./message";
|
|
11
|
+
export * from "./protocol";
|
|
12
|
+
export * from "./publish";
|
|
13
|
+
export * from "./subscribe";
|
|
14
|
+
export * from "./wait";
|
|
15
|
+
export declare namespace Mqtt {
|
|
16
|
+
interface Apply {
|
|
17
|
+
/**
|
|
18
|
+
* Boostrap a builder for a MQTT action
|
|
19
|
+
*
|
|
20
|
+
* @param name - the action name, expressed as a Gatling Expression Language String
|
|
21
|
+
* @returns the next DSL step
|
|
22
|
+
*/
|
|
23
|
+
(name: string): MqttBuilder;
|
|
24
|
+
/**
|
|
25
|
+
* Boostrap a builder for a MQTT action
|
|
26
|
+
*
|
|
27
|
+
* @param name - the action name, expressed as a function
|
|
28
|
+
* @returns the next DSL step
|
|
29
|
+
*/
|
|
30
|
+
(name: (session: Session) => string): MqttBuilder;
|
|
31
|
+
}
|
|
32
|
+
const apply: (name: Expression<string>) => MqttBuilder;
|
|
33
|
+
interface Prefix {
|
|
34
|
+
/**
|
|
35
|
+
* Boostrap a builder for an action that waits for all awaited inbound messages to arrive
|
|
36
|
+
*
|
|
37
|
+
* @returns the next DSL step
|
|
38
|
+
*/
|
|
39
|
+
waitForMessages(): WaitForMessagesActionBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* Process the currently buffered inbound MQTT messages and empty the buffer
|
|
42
|
+
*
|
|
43
|
+
* @param topic - the name of the topic, expressed as a Gatling Expression Language String
|
|
44
|
+
* @param f - the function to process the buffered messages
|
|
45
|
+
* @returns an ActionBuilder
|
|
46
|
+
*/
|
|
47
|
+
processUnmatchedMessages(topic: string, f: (messages: Array<MqttInboundMessage>, session: Session) => Session): ActionBuilder;
|
|
48
|
+
}
|
|
49
|
+
const prefix: Prefix;
|
|
50
|
+
}
|
|
51
|
+
export interface MqttBuilder {
|
|
52
|
+
/**
|
|
53
|
+
* Create a builder for actions that create a MQTT connection
|
|
54
|
+
*
|
|
55
|
+
* @returns a new ActionBuilder instance
|
|
56
|
+
*/
|
|
57
|
+
connect(): ConnectActionBuilder;
|
|
58
|
+
/**
|
|
59
|
+
* Create a builder for actions that subscribe to a MQTT topic
|
|
60
|
+
*
|
|
61
|
+
* @param topic - the name of the topic, expressed as a Gatling Expression Language String
|
|
62
|
+
* @returns a new ActionBuilder instance
|
|
63
|
+
*/
|
|
64
|
+
subscribe(topic: string): SubscribeActionBuilder;
|
|
65
|
+
/**
|
|
66
|
+
* Create a builder for actions that subscribe to a MQTT topic
|
|
67
|
+
*
|
|
68
|
+
* @param topic - the name of the topic, expressed as a function
|
|
69
|
+
* @returns a new ActionBuilder instance
|
|
70
|
+
*/
|
|
71
|
+
subscribe(topic: (session: Session) => string): SubscribeActionBuilder;
|
|
72
|
+
/**
|
|
73
|
+
* Create a builder for actions that publish to a MQTT topic
|
|
74
|
+
*
|
|
75
|
+
* @param topic - the name of the topic, expressed as a Gatling Expression Language String
|
|
76
|
+
* @returns a new ActionBuilder instance
|
|
77
|
+
*/
|
|
78
|
+
publish(topic: string): PublishActionBuilder.Base;
|
|
79
|
+
/**
|
|
80
|
+
* Create a builder for actions that publish to a MQTT topic
|
|
81
|
+
*
|
|
82
|
+
* @param topic - the name of the topic, expressed as a function
|
|
83
|
+
* @returns a new ActionBuilder instance
|
|
84
|
+
*/
|
|
85
|
+
publish(topic: (session: Session) => string): PublishActionBuilder.Base;
|
|
86
|
+
}
|
|
87
|
+
export declare const mqtt: Mqtt.Apply & Mqtt.Prefix & MqttProtocolBuilder;
|
package/target/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.mqtt = exports.Mqtt = void 0;
|
|
18
|
+
const core_1 = require("@gatling.io/core");
|
|
19
|
+
const connect_1 = require("./connect");
|
|
20
|
+
const message_1 = require("./message");
|
|
21
|
+
const protocol_1 = require("./protocol");
|
|
22
|
+
const publish_1 = require("./publish");
|
|
23
|
+
const subscribe_1 = require("./subscribe");
|
|
24
|
+
const wait_1 = require("./wait");
|
|
25
|
+
__exportStar(require("./connect"), exports);
|
|
26
|
+
__exportStar(require("./lastWill"), exports);
|
|
27
|
+
__exportStar(require("./message"), exports);
|
|
28
|
+
__exportStar(require("./protocol"), exports);
|
|
29
|
+
__exportStar(require("./publish"), exports);
|
|
30
|
+
__exportStar(require("./subscribe"), exports);
|
|
31
|
+
__exportStar(require("./wait"), exports);
|
|
32
|
+
const jvm_types_1 = require("@gatling.io/jvm-types");
|
|
33
|
+
var Mqtt;
|
|
34
|
+
(function (Mqtt) {
|
|
35
|
+
Mqtt.apply = (name) => {
|
|
36
|
+
const jvmMqttBuilder = typeof name === "function" ? jvm_types_1.MqttDsl.mqtt((0, core_1.underlyingSessionTo)(name)) : jvm_types_1.MqttDsl.mqtt(name);
|
|
37
|
+
return wrapMqttBuilder(jvmMqttBuilder);
|
|
38
|
+
};
|
|
39
|
+
const jvmMqtt = jvm_types_1.MqttDsl.mqtt;
|
|
40
|
+
Mqtt.prefix = {
|
|
41
|
+
waitForMessages: () => (0, wait_1.wrapWaitForMessagesActionBuilder)(jvmMqtt.waitForMessages()),
|
|
42
|
+
processUnmatchedMessages: (topic, f) => (0, core_1.wrapActionBuilder)(jvmMqtt.processUnmatchedMessages(topic, (0, core_1.underlyingJvmXToXWithSessionToSession)(f, message_1.wrapMqttInboundMessages)))
|
|
43
|
+
};
|
|
44
|
+
})(Mqtt || (exports.Mqtt = Mqtt = {}));
|
|
45
|
+
const wrapMqttBuilder = (jvmMqtt) => ({
|
|
46
|
+
connect: () => (0, connect_1.wrapConnectActionBuilder)(jvmMqtt.connect()),
|
|
47
|
+
subscribe: (topic) => (0, subscribe_1.wrapSubscribeActionBuilder)(typeof topic === "function" ? jvmMqtt.subscribe((0, core_1.underlyingSessionTo)(topic)) : jvmMqtt.subscribe(topic)),
|
|
48
|
+
publish: (topic) => publish_1.PublishActionBuilder.wrapBase(typeof topic === "function" ? jvmMqtt.publish((0, core_1.underlyingSessionTo)(topic)) : jvmMqtt.publish(topic))
|
|
49
|
+
});
|
|
50
|
+
exports.mqtt = Object.assign(Mqtt.apply, Mqtt.prefix, protocol_1.mqttProtocolBuilder);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Body, Session, Wrapper } from "@gatling.io/core";
|
|
2
|
+
import JvmLastWillBuilder = io.gatling.javaapi.mqtt.LastWillBuilder;
|
|
3
|
+
export interface LastWillBuilder extends Wrapper<JvmLastWillBuilder> {
|
|
4
|
+
/**
|
|
5
|
+
* Use an at-most-once QoS
|
|
6
|
+
*
|
|
7
|
+
* @returns a new LastWillBuilder instance
|
|
8
|
+
*/
|
|
9
|
+
qosAtMostOnce(): LastWillBuilder;
|
|
10
|
+
/**
|
|
11
|
+
* Use an at-least-once QoS
|
|
12
|
+
*
|
|
13
|
+
* @returns a new LastWillBuilder instance
|
|
14
|
+
*/
|
|
15
|
+
qosAtLeastOnce(): LastWillBuilder;
|
|
16
|
+
/**
|
|
17
|
+
* Use an exactly-once QoS
|
|
18
|
+
*
|
|
19
|
+
* @returns a new LastWillBuilder instance
|
|
20
|
+
*/
|
|
21
|
+
qosExactlyOnce(): LastWillBuilder;
|
|
22
|
+
/**
|
|
23
|
+
* Instruct the server to retain the last will message
|
|
24
|
+
*
|
|
25
|
+
* @returns a new LastWillBuilder instance
|
|
26
|
+
*/
|
|
27
|
+
retain(newRetain: boolean): LastWillBuilder;
|
|
28
|
+
}
|
|
29
|
+
export declare const wrapLastWillBuilder: (_underlying: JvmLastWillBuilder) => LastWillBuilder;
|
|
30
|
+
export declare namespace LastWill {
|
|
31
|
+
interface Apply {
|
|
32
|
+
/**
|
|
33
|
+
* Bootstrap a builder for last will messages
|
|
34
|
+
*
|
|
35
|
+
* @param topic - the topic to send last will messages to, expressed as a Gatling Expression
|
|
36
|
+
* Language String
|
|
37
|
+
* @param message - the last will message
|
|
38
|
+
* @returns the next DSL step
|
|
39
|
+
*/
|
|
40
|
+
(topic: string, message: Body): LastWillBuilder;
|
|
41
|
+
/**
|
|
42
|
+
* Bootstrap a builder for last will messages
|
|
43
|
+
*
|
|
44
|
+
* @param topic - the topic to send last will messages to, expressed as a function
|
|
45
|
+
* @param message - the last will message
|
|
46
|
+
* @returns the next DSL step
|
|
47
|
+
*/
|
|
48
|
+
(topic: (session: Session) => string, message: Body): LastWillBuilder;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export declare const LastWill: LastWill.Apply;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LastWill = exports.wrapLastWillBuilder = void 0;
|
|
4
|
+
const core_1 = require("@gatling.io/core");
|
|
5
|
+
const jvm_types_1 = require("@gatling.io/jvm-types");
|
|
6
|
+
const wrapLastWillBuilder = (_underlying) => ({
|
|
7
|
+
_underlying,
|
|
8
|
+
qosAtMostOnce: () => (0, exports.wrapLastWillBuilder)(_underlying.qosAtMostOnce()),
|
|
9
|
+
qosAtLeastOnce: () => (0, exports.wrapLastWillBuilder)(_underlying.qosAtLeastOnce()),
|
|
10
|
+
qosExactlyOnce: () => (0, exports.wrapLastWillBuilder)(_underlying.qosExactlyOnce()),
|
|
11
|
+
retain: (newRetain) => (0, exports.wrapLastWillBuilder)(_underlying.retain(newRetain))
|
|
12
|
+
});
|
|
13
|
+
exports.wrapLastWillBuilder = wrapLastWillBuilder;
|
|
14
|
+
const LastWill = (topic, message) => typeof topic === "function"
|
|
15
|
+
? (0, exports.wrapLastWillBuilder)(jvm_types_1.MqttDsl.LastWill((0, core_1.underlyingSessionTo)(topic), message._underlying))
|
|
16
|
+
: (0, exports.wrapLastWillBuilder)(jvm_types_1.MqttDsl.LastWill(topic, message._underlying));
|
|
17
|
+
exports.LastWill = LastWill;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import JvmMqttInboundMessage = io.gatling.mqtt.action.MqttInboundMessage;
|
|
2
|
+
export type MqttMessageType = "CONNECT" | "CONNACK" | "PUBLISH" | "PUBACK" | "PUBREC" | "PUBREL" | "PUBCOMP" | "SUBSCRIBE" | "SUBACK" | "UNSUBSCRIBE" | "UNSUBACK" | "PINGREQ" | "PINGRESP" | "DISCONNECT" | "AUTH";
|
|
3
|
+
export type MqttQos = "AT_MOST_ONCE" | "AT_LEAST_ONCE" | "EXACTLY_ONCE" | "FAILURE";
|
|
4
|
+
export interface MqttFixedHeader {
|
|
5
|
+
isDup(): boolean;
|
|
6
|
+
isRetain(): boolean;
|
|
7
|
+
messageType(): MqttMessageType;
|
|
8
|
+
qosLevel(): MqttQos;
|
|
9
|
+
remainingLength(): number;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
12
|
+
export interface MqttProperties {
|
|
13
|
+
}
|
|
14
|
+
export interface MqttPublishVariableHeader {
|
|
15
|
+
topicName(): string;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use {@link #packetId()} instead.
|
|
18
|
+
*/
|
|
19
|
+
messageId(): number;
|
|
20
|
+
packetId(): number;
|
|
21
|
+
properties(): MqttProperties;
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
export interface MqttInboundMessage {
|
|
25
|
+
timestamp(): number;
|
|
26
|
+
fixedHeader(): MqttFixedHeader;
|
|
27
|
+
variableHeader(): MqttPublishVariableHeader;
|
|
28
|
+
payload(): number[];
|
|
29
|
+
payloadUtf8String(): string;
|
|
30
|
+
}
|
|
31
|
+
export declare const wrapMqttInboundMessages: (jvmMessages: JvmMqttInboundMessage[]) => MqttInboundMessage[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapMqttInboundMessages = void 0;
|
|
4
|
+
const wrapFixedHeader = (jvmFixedHeader) => ({
|
|
5
|
+
isDup: () => jvmFixedHeader.isDup(),
|
|
6
|
+
isRetain: () => jvmFixedHeader.isRetain(),
|
|
7
|
+
messageType: () => jvmFixedHeader.messageType().name(),
|
|
8
|
+
qosLevel: () => jvmFixedHeader.qosLevel().name(),
|
|
9
|
+
remainingLength: () => jvmFixedHeader.remainingLength()
|
|
10
|
+
});
|
|
11
|
+
const wrapMqttInboundMessage = (jvmMessage) => ({
|
|
12
|
+
timestamp: () => jvmMessage.timestamp(),
|
|
13
|
+
fixedHeader: () => wrapFixedHeader(jvmMessage.fixedHeader()),
|
|
14
|
+
variableHeader: () => jvmMessage.variableHeader(),
|
|
15
|
+
payload: () => jvmMessage.payload(), // FIXME Uint8Array after introducing textencoder/decoder?
|
|
16
|
+
payloadUtf8String: () => jvmMessage.payloadUtf8String()
|
|
17
|
+
});
|
|
18
|
+
const wrapMqttInboundMessages = (jvmMessages) => {
|
|
19
|
+
const messages = []; // map looses the original array type and turn it into object?
|
|
20
|
+
jvmMessages.forEach((message) => {
|
|
21
|
+
messages.push(wrapMqttInboundMessage(message));
|
|
22
|
+
});
|
|
23
|
+
return messages;
|
|
24
|
+
};
|
|
25
|
+
exports.wrapMqttInboundMessages = wrapMqttInboundMessages;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { CheckBuilder, Duration, ProtocolBuilder, Session } from "@gatling.io/core";
|
|
2
|
+
import { LastWillBuilder } from "./lastWill";
|
|
3
|
+
export interface MqttProtocolBuilder extends ProtocolBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* Use MQTT 3.1
|
|
6
|
+
*
|
|
7
|
+
* @returns a new MqttProtocolBuilder instance
|
|
8
|
+
*/
|
|
9
|
+
mqttVersion_3_1(): MqttProtocolBuilder;
|
|
10
|
+
/**
|
|
11
|
+
* Use MQTT 3.1.1 (default)
|
|
12
|
+
*
|
|
13
|
+
* @returns a new MqttProtocolBuilder instance
|
|
14
|
+
*/
|
|
15
|
+
mqttVersion_3_1_1(): MqttProtocolBuilder;
|
|
16
|
+
/**
|
|
17
|
+
* Use MQTT 5
|
|
18
|
+
*
|
|
19
|
+
* @returns a new MqttProtocolBuilder instance
|
|
20
|
+
*/
|
|
21
|
+
mqttVersion_5(): MqttProtocolBuilder;
|
|
22
|
+
/**
|
|
23
|
+
* Define the MQTT broker address
|
|
24
|
+
*
|
|
25
|
+
* @param hostname - the hostname
|
|
26
|
+
* @param port - the port
|
|
27
|
+
* @returns a new MqttProtocolBuilder instance
|
|
28
|
+
*/
|
|
29
|
+
broker(hostname: string, port: number): MqttProtocolBuilder;
|
|
30
|
+
/**
|
|
31
|
+
* Use TLS
|
|
32
|
+
*
|
|
33
|
+
* @param useTls - true to enable TLS
|
|
34
|
+
* @returns a new MqttProtocolBuilder instance
|
|
35
|
+
*/
|
|
36
|
+
useTls(useTls: boolean): MqttProtocolBuilder;
|
|
37
|
+
/**
|
|
38
|
+
* Define the clientId
|
|
39
|
+
*
|
|
40
|
+
* @param clientId - the clientId, expressed as a Gatling Expression Language String
|
|
41
|
+
* @returns a new MqttProtocolBuilder instance
|
|
42
|
+
*/
|
|
43
|
+
clientId(clientId: string): MqttProtocolBuilder;
|
|
44
|
+
/**
|
|
45
|
+
* Define the clientId
|
|
46
|
+
*
|
|
47
|
+
* @param clientId - the clientId, expressed as a function
|
|
48
|
+
* @returns a new MqttProtocolBuilder instance
|
|
49
|
+
*/
|
|
50
|
+
clientId(clientId: (session: Session) => string): MqttProtocolBuilder;
|
|
51
|
+
/**
|
|
52
|
+
* Clean the MQTT session when closing the MQTT connection
|
|
53
|
+
*
|
|
54
|
+
* @param cleanSession - true to clean the session
|
|
55
|
+
* @returns a new MqttProtocolBuilder instance
|
|
56
|
+
*/
|
|
57
|
+
cleanSession(cleanSession: boolean): MqttProtocolBuilder;
|
|
58
|
+
/**
|
|
59
|
+
* Define the connect timeout
|
|
60
|
+
*
|
|
61
|
+
* @param timeout - the timeout
|
|
62
|
+
* @returns a new MqttProtocolBuilder instance
|
|
63
|
+
*/
|
|
64
|
+
connectTimeout(timeout: Duration): MqttProtocolBuilder;
|
|
65
|
+
/**
|
|
66
|
+
* Define the keepAlive timeout
|
|
67
|
+
*
|
|
68
|
+
* @param timeout - the keepAlive timeout
|
|
69
|
+
* @returns a new MqttProtocolBuilder instance
|
|
70
|
+
*/
|
|
71
|
+
keepAlive(timeout: Duration): MqttProtocolBuilder;
|
|
72
|
+
/**
|
|
73
|
+
* Use an at-most-once QoS
|
|
74
|
+
*
|
|
75
|
+
* @returns a new MqttProtocolBuilder instance
|
|
76
|
+
*/
|
|
77
|
+
qosAtMostOnce(): MqttProtocolBuilder;
|
|
78
|
+
/**
|
|
79
|
+
* Use an at-least-once QoS
|
|
80
|
+
*
|
|
81
|
+
* @returns a new MqttProtocolBuilder instance
|
|
82
|
+
*/
|
|
83
|
+
qosAtLeastOnce(): MqttProtocolBuilder;
|
|
84
|
+
/**
|
|
85
|
+
* Use an exactly-once QoS
|
|
86
|
+
*
|
|
87
|
+
* @returns a new MqttProtocolBuilder instance
|
|
88
|
+
*/
|
|
89
|
+
qosExactlyOnce(): MqttProtocolBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Instruct the server to retain the message
|
|
92
|
+
*
|
|
93
|
+
* @param retain - true to retain
|
|
94
|
+
* @returns a new MqttProtocolBuilder instance
|
|
95
|
+
*/
|
|
96
|
+
retain(retain: boolean): MqttProtocolBuilder;
|
|
97
|
+
/**
|
|
98
|
+
* Define the credentials
|
|
99
|
+
*
|
|
100
|
+
* @param username - the username, expressed as a Gatling Expression Language String
|
|
101
|
+
* @param password - the password, expressed as a Gatling Expression Language String
|
|
102
|
+
* @returns a new MqttProtocolBuilder instance
|
|
103
|
+
*/
|
|
104
|
+
credentials(username: string, password: string): MqttProtocolBuilder;
|
|
105
|
+
/**
|
|
106
|
+
* Define the credentials
|
|
107
|
+
*
|
|
108
|
+
* @param username - the username, expressed as a Gatling Expression Language String
|
|
109
|
+
* @param password - the password, expressed as a function
|
|
110
|
+
* @returns a new MqttProtocolBuilder instance
|
|
111
|
+
*/
|
|
112
|
+
credentials(username: string, password: (session: Session) => string): MqttProtocolBuilder;
|
|
113
|
+
/**
|
|
114
|
+
* Define the credentials
|
|
115
|
+
*
|
|
116
|
+
* @param username - the username, expressed as a function
|
|
117
|
+
* @param password - the password, expressed as a Gatling Expression Language String
|
|
118
|
+
* @returns a new MqttProtocolBuilder instance
|
|
119
|
+
*/
|
|
120
|
+
credentials(username: (session: Session) => string, password: string): MqttProtocolBuilder;
|
|
121
|
+
/**
|
|
122
|
+
* Define the credentials
|
|
123
|
+
*
|
|
124
|
+
* @param username - the username, expressed as a function
|
|
125
|
+
* @param password - the password, expressed as a function
|
|
126
|
+
* @returns a new MqttProtocolBuilder instance
|
|
127
|
+
*/
|
|
128
|
+
credentials(username: (session: Session) => string, password: (session: Session) => string): MqttProtocolBuilder;
|
|
129
|
+
/**
|
|
130
|
+
* Send a LastWill message when closing the connetion
|
|
131
|
+
*
|
|
132
|
+
* @param lw - the last will message
|
|
133
|
+
* @returns a new MqttProtocolBuilder instance
|
|
134
|
+
*/
|
|
135
|
+
lastWill(lw: LastWillBuilder): MqttProtocolBuilder;
|
|
136
|
+
/**
|
|
137
|
+
* Define the maximum number of reconnections
|
|
138
|
+
*
|
|
139
|
+
* @param reconnectAttemptsMax - the maximum number of reconnections
|
|
140
|
+
* @returns a new MqttProtocolBuilder instance
|
|
141
|
+
*/
|
|
142
|
+
reconnectAttemptsMax(reconnectAttemptsMax: number): MqttProtocolBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Define the reconnect delay exponential backoff multiplier
|
|
145
|
+
*
|
|
146
|
+
* @param multiplier - the multiplier
|
|
147
|
+
* @returns a new MqttProtocolBuilder instance
|
|
148
|
+
*/
|
|
149
|
+
reconnectBackoffMultiplier(multiplier: number): MqttProtocolBuilder;
|
|
150
|
+
/**
|
|
151
|
+
* Define the delay before reconnecting a crashed connection
|
|
152
|
+
*
|
|
153
|
+
* @param delay - the delay
|
|
154
|
+
* @returns a new MqttProtocolBuilder instance
|
|
155
|
+
*/
|
|
156
|
+
reconnectDelay(delay: Duration): MqttProtocolBuilder;
|
|
157
|
+
/**
|
|
158
|
+
* Define the resend delay exponential backoff multiplier
|
|
159
|
+
*
|
|
160
|
+
* @param multiplier - the multiplier
|
|
161
|
+
* @returns a new MqttProtocolBuilder instance
|
|
162
|
+
*/
|
|
163
|
+
resendBackoffMultiplier(multiplier: number): MqttProtocolBuilder;
|
|
164
|
+
/**
|
|
165
|
+
* Define the delay before resending a message
|
|
166
|
+
*
|
|
167
|
+
* @param delay - the delay
|
|
168
|
+
* @returns a new MqttProtocolBuilder instance
|
|
169
|
+
*/
|
|
170
|
+
resendDelay(delay: Duration): MqttProtocolBuilder;
|
|
171
|
+
/**
|
|
172
|
+
* Define a check to extract the correlationId when applying check that have to match outbound
|
|
173
|
+
* and inbound messages
|
|
174
|
+
*
|
|
175
|
+
* @param correlator - the check to extract the correlationId
|
|
176
|
+
* @returns a new MqttProtocolBuilder instance
|
|
177
|
+
*/
|
|
178
|
+
correlateBy(correlator: CheckBuilder): MqttProtocolBuilder;
|
|
179
|
+
/**
|
|
180
|
+
* Define the interval to check for checks timeout
|
|
181
|
+
*
|
|
182
|
+
* @param interval - the interval
|
|
183
|
+
* @returns a new MqttProtocolBuilder instance
|
|
184
|
+
*/
|
|
185
|
+
timeoutCheckInterval(interval: Duration): MqttProtocolBuilder;
|
|
186
|
+
/**
|
|
187
|
+
* Set the max size of the buffer for unmatched/unchecked inbound WebSocket messages. 0 by
|
|
188
|
+
* default, meaning such messages are not buffered.
|
|
189
|
+
*
|
|
190
|
+
* @param max - the max size
|
|
191
|
+
* @returns a new MqttProtocolBuilder instance
|
|
192
|
+
*/
|
|
193
|
+
unmatchedInboundMessageBufferSize(max: number): MqttProtocolBuilder;
|
|
194
|
+
}
|
|
195
|
+
export declare const mqttProtocolBuilder: MqttProtocolBuilder;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mqttProtocolBuilder = void 0;
|
|
4
|
+
const core_1 = require("@gatling.io/core");
|
|
5
|
+
const wrapMqttProtocolBuilder = (_underlying) => ({
|
|
6
|
+
_underlying,
|
|
7
|
+
mqttVersion_3_1: () => wrapMqttProtocolBuilder(_underlying.mqttVersion_3_1()),
|
|
8
|
+
mqttVersion_3_1_1: () => wrapMqttProtocolBuilder(_underlying.mqttVersion_3_1_1()),
|
|
9
|
+
mqttVersion_5: () => wrapMqttProtocolBuilder(_underlying.mqttVersion_5()),
|
|
10
|
+
broker: (hostname, port) => wrapMqttProtocolBuilder(_underlying.broker(hostname, port)),
|
|
11
|
+
useTls: (useTls) => wrapMqttProtocolBuilder(_underlying.useTls(useTls)),
|
|
12
|
+
// FIXME perUserKeyManagerFactory(f: (number) => KeyManagerFactory): MqttProtocolBuilder;
|
|
13
|
+
clientId: (clientId) => wrapMqttProtocolBuilder(typeof clientId === "function"
|
|
14
|
+
? _underlying.clientId((0, core_1.underlyingSessionTo)(clientId))
|
|
15
|
+
: _underlying.clientId(clientId)),
|
|
16
|
+
cleanSession: (cleanSession) => wrapMqttProtocolBuilder(_underlying.cleanSession(cleanSession)),
|
|
17
|
+
connectTimeout: (timeout) => {
|
|
18
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
19
|
+
return wrapMqttProtocolBuilder(_underlying.connectTimeout((0, core_1.toJvmDuration)(timeout)));
|
|
20
|
+
}
|
|
21
|
+
throw Error(`connectTimeout() called with invalid argument ${timeout}`);
|
|
22
|
+
},
|
|
23
|
+
keepAlive: (timeout) => {
|
|
24
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
25
|
+
return wrapMqttProtocolBuilder(_underlying.connectTimeout((0, core_1.toJvmDuration)(timeout)));
|
|
26
|
+
}
|
|
27
|
+
throw Error(`keepAlive() called with invalid argument ${timeout}`);
|
|
28
|
+
},
|
|
29
|
+
qosAtMostOnce: () => wrapMqttProtocolBuilder(_underlying.qosAtMostOnce()),
|
|
30
|
+
qosAtLeastOnce: () => wrapMqttProtocolBuilder(_underlying.qosAtLeastOnce()),
|
|
31
|
+
qosExactlyOnce: () => wrapMqttProtocolBuilder(_underlying.qosExactlyOnce()),
|
|
32
|
+
retain: (retain) => wrapMqttProtocolBuilder(_underlying.retain(retain)),
|
|
33
|
+
credentials: (username, password) => wrapMqttProtocolBuilder(typeof username === "function"
|
|
34
|
+
? typeof password === "function"
|
|
35
|
+
? _underlying.credentials((0, core_1.underlyingSessionTo)(username), (0, core_1.underlyingSessionTo)(password))
|
|
36
|
+
: _underlying.credentials((0, core_1.underlyingSessionTo)(username), password)
|
|
37
|
+
: typeof password === "function"
|
|
38
|
+
? _underlying.credentials(username, (0, core_1.underlyingSessionTo)(password))
|
|
39
|
+
: _underlying.credentials(username, password)),
|
|
40
|
+
lastWill: (lw) => wrapMqttProtocolBuilder(_underlying.lastWill(lw._underlying)),
|
|
41
|
+
reconnectAttemptsMax: (reconnectAttemptsMax) => wrapMqttProtocolBuilder(_underlying.reconnectAttemptsMax(reconnectAttemptsMax)),
|
|
42
|
+
reconnectBackoffMultiplier: (multiplier) => wrapMqttProtocolBuilder(_underlying.reconnectBackoffMultiplier(multiplier)),
|
|
43
|
+
reconnectDelay: (delay) => {
|
|
44
|
+
if ((0, core_1.isDuration)(delay)) {
|
|
45
|
+
return wrapMqttProtocolBuilder(_underlying.reconnectDelay((0, core_1.toJvmDuration)(delay)));
|
|
46
|
+
}
|
|
47
|
+
throw Error(`reconnectDelay() called with invalid argument ${delay}`);
|
|
48
|
+
},
|
|
49
|
+
resendBackoffMultiplier: (multiplier) => wrapMqttProtocolBuilder(_underlying.resendBackoffMultiplier(multiplier)),
|
|
50
|
+
resendDelay: (delay) => {
|
|
51
|
+
if ((0, core_1.isDuration)(delay)) {
|
|
52
|
+
return wrapMqttProtocolBuilder(_underlying.resendDelay((0, core_1.toJvmDuration)(delay)));
|
|
53
|
+
}
|
|
54
|
+
throw Error(`resendDelay() called with invalid argument ${delay}`);
|
|
55
|
+
},
|
|
56
|
+
correlateBy: (correlator) => wrapMqttProtocolBuilder(_underlying.correlateBy(correlator._underlying)),
|
|
57
|
+
timeoutCheckInterval: (interval) => {
|
|
58
|
+
if ((0, core_1.isDuration)(interval)) {
|
|
59
|
+
return wrapMqttProtocolBuilder(_underlying.timeoutCheckInterval((0, core_1.toJvmDuration)(interval)));
|
|
60
|
+
}
|
|
61
|
+
throw Error(`timeoutCheckInterval() called with invalid argument ${interval}`);
|
|
62
|
+
},
|
|
63
|
+
unmatchedInboundMessageBufferSize: (max) => wrapMqttProtocolBuilder(_underlying.unmatchedInboundMessageBufferSize(max))
|
|
64
|
+
});
|
|
65
|
+
exports.mqttProtocolBuilder = wrapMqttProtocolBuilder(
|
|
66
|
+
// MqttDsl.mqtt doesn't get properly generated by java2ts because of conflicts with methods of the same name
|
|
67
|
+
Java.type("io.gatling.javaapi.mqtt.MqttDsl").mqtt);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ActionBuilder, Body, CheckBuilder, Duration, Session } from "@gatling.io/core";
|
|
2
|
+
export declare namespace PublishActionBuilder {
|
|
3
|
+
import JvmBase = io.gatling.javaapi.mqtt.PublishActionBuilder$Base;
|
|
4
|
+
import JvmCheckable = io.gatling.javaapi.mqtt.PublishActionBuilder$Checkable;
|
|
5
|
+
interface Base {
|
|
6
|
+
/**
|
|
7
|
+
* Provide the message to send
|
|
8
|
+
*
|
|
9
|
+
* @param body - a body
|
|
10
|
+
* @returns a new ActionBuilder instance
|
|
11
|
+
*/
|
|
12
|
+
message(body: Body): PublishActionBuilder;
|
|
13
|
+
}
|
|
14
|
+
interface Checkable extends ActionBuilder {
|
|
15
|
+
/**
|
|
16
|
+
* Use an at-most-once QoS
|
|
17
|
+
*
|
|
18
|
+
* @returns a new ActionBuilder instance
|
|
19
|
+
*/
|
|
20
|
+
qosAtMostOnce(): PublishActionBuilder;
|
|
21
|
+
/**
|
|
22
|
+
* Use an at-least-once QoS
|
|
23
|
+
*
|
|
24
|
+
* @returns a new ActionBuilder instance
|
|
25
|
+
*/
|
|
26
|
+
qosAtLeastOnce(): PublishActionBuilder;
|
|
27
|
+
/**
|
|
28
|
+
* Use an exactly-once QoS
|
|
29
|
+
*
|
|
30
|
+
* @returns a new ActionBuilder instance
|
|
31
|
+
*/
|
|
32
|
+
qosExactlyOnce(): PublishActionBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Apply some checks
|
|
35
|
+
*
|
|
36
|
+
* @param checks - the checks
|
|
37
|
+
* @returns the next DSL step
|
|
38
|
+
*/
|
|
39
|
+
check(...checks: Array<CheckBuilder>): PublishActionBuilder.Checkable;
|
|
40
|
+
}
|
|
41
|
+
const wrapBase: (_underlying: JvmBase) => PublishActionBuilder.Base;
|
|
42
|
+
const wrapCheckable: (_underlying: JvmCheckable) => PublishActionBuilder.Checkable;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* DSL for actions that publish MQTT messages
|
|
46
|
+
*
|
|
47
|
+
* <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
|
|
48
|
+
*/
|
|
49
|
+
export interface PublishActionBuilder extends ActionBuilder {
|
|
50
|
+
/**
|
|
51
|
+
* Use an at-most-once QoS
|
|
52
|
+
*
|
|
53
|
+
* @returns a new ActionBuilder instance
|
|
54
|
+
*/
|
|
55
|
+
qosAtMostOnce(): PublishActionBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* Use an at-least-once QoS
|
|
58
|
+
*
|
|
59
|
+
* @returns a new ActionBuilder instance
|
|
60
|
+
*/
|
|
61
|
+
qosAtLeastOnce(): PublishActionBuilder;
|
|
62
|
+
/**
|
|
63
|
+
* Use an exactly-once QoS
|
|
64
|
+
*
|
|
65
|
+
* @returns a new ActionBuilder instance
|
|
66
|
+
*/
|
|
67
|
+
qosExactlyOnce(): PublishActionBuilder;
|
|
68
|
+
/**
|
|
69
|
+
* Wait for the checks to complete
|
|
70
|
+
*
|
|
71
|
+
* @param timeout - the check timeout
|
|
72
|
+
* @returns the next DSL step
|
|
73
|
+
*/
|
|
74
|
+
await(timeout: Duration): PublishActionBuilder.Checkable;
|
|
75
|
+
/**
|
|
76
|
+
* Wait for the checks to complete
|
|
77
|
+
*
|
|
78
|
+
* @param timeout - the check timeout
|
|
79
|
+
* @param expectedTopic - the topic where the response message is expected to be published,
|
|
80
|
+
* expressed as a Gatling Expression Language String
|
|
81
|
+
* @returns the next DSL step
|
|
82
|
+
*/
|
|
83
|
+
await(timeout: Duration, expectedTopic: string): PublishActionBuilder.Checkable;
|
|
84
|
+
/**
|
|
85
|
+
* Wait for the checks to complete
|
|
86
|
+
*
|
|
87
|
+
* @param timeout - the check timeout
|
|
88
|
+
* @param expectedTopic - the topic where the response message is expected to be published,
|
|
89
|
+
* expressed as a function
|
|
90
|
+
* @returns the next DSL step
|
|
91
|
+
*/
|
|
92
|
+
await(timeout: Duration, expectedTopic: (session: Session) => string): PublishActionBuilder.Checkable;
|
|
93
|
+
/**
|
|
94
|
+
* Perform checks in the background, meaning state will have to be reconciled with {@link
|
|
95
|
+
* MqttDsl#waitForMessages()}
|
|
96
|
+
*
|
|
97
|
+
* @param timeout - the check timeout
|
|
98
|
+
* @returns the next DSL step
|
|
99
|
+
*/
|
|
100
|
+
expect(timeout: Duration): PublishActionBuilder.Checkable;
|
|
101
|
+
/**
|
|
102
|
+
* Perform checks in the background, meaning state will have to be reconciled with {@link
|
|
103
|
+
* MqttDsl#waitForMessages()}
|
|
104
|
+
*
|
|
105
|
+
* @param timeout - the check timeout
|
|
106
|
+
* @param expectedTopic - the topic where the response message is expected to be published,
|
|
107
|
+
* expressed as a Gatling Expression Language String
|
|
108
|
+
* @returns the next DSL step
|
|
109
|
+
*/
|
|
110
|
+
expect(timeout: Duration, expectedTopic: string): PublishActionBuilder.Checkable;
|
|
111
|
+
/**
|
|
112
|
+
* Perform checks in the background, meaning state will have to be reconciled with {@link
|
|
113
|
+
* MqttDsl#waitForMessages()}
|
|
114
|
+
*
|
|
115
|
+
* @param timeout - the check timeout
|
|
116
|
+
* @param expectedTopic - the topic where the response message is expected to be published,
|
|
117
|
+
* expressed as a function
|
|
118
|
+
* @returns the next DSL step
|
|
119
|
+
*/
|
|
120
|
+
expect(timeout: Duration, expectedTopic: (session: Session) => string): PublishActionBuilder.Checkable;
|
|
121
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublishActionBuilder = void 0;
|
|
4
|
+
const core_1 = require("@gatling.io/core");
|
|
5
|
+
var PublishActionBuilder;
|
|
6
|
+
(function (PublishActionBuilder) {
|
|
7
|
+
PublishActionBuilder.wrapBase = (_underlying) => ({
|
|
8
|
+
message: (body) => wrapPublishActionBuilder(_underlying.message(body._underlying))
|
|
9
|
+
});
|
|
10
|
+
PublishActionBuilder.wrapCheckable = (_underlying) => ({
|
|
11
|
+
_underlying,
|
|
12
|
+
qosAtMostOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
|
|
13
|
+
qosAtLeastOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
|
|
14
|
+
qosExactlyOnce: () => wrapPublishActionBuilder(_underlying.qosExactlyOnce()),
|
|
15
|
+
check: (...checks) => PublishActionBuilder.wrapCheckable(_underlying.check(checks.map((cb) => cb._underlying)))
|
|
16
|
+
});
|
|
17
|
+
})(PublishActionBuilder || (exports.PublishActionBuilder = PublishActionBuilder = {}));
|
|
18
|
+
const wrapPublishActionBuilder = (_underlying) => ({
|
|
19
|
+
_underlying,
|
|
20
|
+
qosAtMostOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
|
|
21
|
+
qosAtLeastOnce: () => wrapPublishActionBuilder(_underlying.qosAtLeastOnce()),
|
|
22
|
+
qosExactlyOnce: () => wrapPublishActionBuilder(_underlying.qosExactlyOnce()),
|
|
23
|
+
// Checkable
|
|
24
|
+
await: (timeout, expectedTopic) => {
|
|
25
|
+
if (expectedTopic !== undefined) {
|
|
26
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
27
|
+
const jvmTimeout = (0, core_1.toJvmDuration)(timeout);
|
|
28
|
+
if (typeof expectedTopic === "function") {
|
|
29
|
+
return PublishActionBuilder.wrapCheckable(_underlying.await(jvmTimeout, (0, core_1.underlyingSessionTo)(expectedTopic)));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return PublishActionBuilder.wrapCheckable(_underlying.await(jvmTimeout, expectedTopic));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
throw Error(`await() called with invalid arguments ${timeout}, ${expectedTopic}`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
39
|
+
return PublishActionBuilder.wrapCheckable(_underlying.await((0, core_1.toJvmDuration)(timeout)));
|
|
40
|
+
}
|
|
41
|
+
throw Error(`await() called with invalid argument ${timeout}`);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
expect: (timeout, expectedTopic) => {
|
|
45
|
+
if (expectedTopic !== undefined) {
|
|
46
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
47
|
+
const jvmTimeout = (0, core_1.toJvmDuration)(timeout);
|
|
48
|
+
if (typeof expectedTopic === "function") {
|
|
49
|
+
return PublishActionBuilder.wrapCheckable(_underlying.expect(jvmTimeout, (0, core_1.underlyingSessionTo)(expectedTopic)));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return PublishActionBuilder.wrapCheckable(_underlying.expect(jvmTimeout, expectedTopic));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
throw Error(`expect() called with invalid arguments ${timeout}, ${expectedTopic}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
59
|
+
return PublishActionBuilder.wrapCheckable(_underlying.expect((0, core_1.toJvmDuration)(timeout)));
|
|
60
|
+
}
|
|
61
|
+
throw Error(`expect() called with invalid argument ${timeout}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ActionBuilder, CheckBuilder, Duration } from "@gatling.io/core";
|
|
2
|
+
import JvmSubscribeActionBuilder = io.gatling.javaapi.mqtt.SubscribeActionBuilder;
|
|
3
|
+
export declare namespace SubscribeActionBuilder {
|
|
4
|
+
import JvmCheckable = io.gatling.javaapi.mqtt.SubscribeActionBuilder$Checkable;
|
|
5
|
+
interface Checkable extends ActionBuilder {
|
|
6
|
+
/**
|
|
7
|
+
* Use an at-most-once QoS
|
|
8
|
+
*
|
|
9
|
+
* @returns a new ActionBuilder instance
|
|
10
|
+
*/
|
|
11
|
+
qosAtMostOnce(): SubscribeActionBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Use an at-least-once QoS
|
|
14
|
+
*
|
|
15
|
+
* @returns a new ActionBuilder instance
|
|
16
|
+
*/
|
|
17
|
+
qosAtLeastOnce(): SubscribeActionBuilder;
|
|
18
|
+
/**
|
|
19
|
+
* Use an exactly-once QoS
|
|
20
|
+
*
|
|
21
|
+
* @returns a new ActionBuilder instance
|
|
22
|
+
*/
|
|
23
|
+
qosExactlyOnce(): SubscribeActionBuilder;
|
|
24
|
+
/**
|
|
25
|
+
* Apply some checks
|
|
26
|
+
*
|
|
27
|
+
* @param checks - the checks
|
|
28
|
+
* @returns a new ActionBuilder instance
|
|
29
|
+
*/
|
|
30
|
+
check(...checks: Array<CheckBuilder>): SubscribeActionBuilder.Checkable;
|
|
31
|
+
}
|
|
32
|
+
const wrapCheckable: (_underlying: JvmCheckable) => Checkable;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* DSL for actions that subscribe to MQTT topics
|
|
36
|
+
*
|
|
37
|
+
* <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
|
|
38
|
+
*/
|
|
39
|
+
export interface SubscribeActionBuilder extends ActionBuilder {
|
|
40
|
+
/**
|
|
41
|
+
* Use an at-most-once QoS
|
|
42
|
+
*
|
|
43
|
+
* @returns a new ActionBuilder instance
|
|
44
|
+
*/
|
|
45
|
+
qosAtMostOnce(): SubscribeActionBuilder;
|
|
46
|
+
/**
|
|
47
|
+
* Use an at-least-once QoS
|
|
48
|
+
*
|
|
49
|
+
* @returns a new ActionBuilder instance
|
|
50
|
+
*/
|
|
51
|
+
qosAtLeastOnce(): SubscribeActionBuilder;
|
|
52
|
+
/**
|
|
53
|
+
* Use an exactly-once QoS
|
|
54
|
+
*
|
|
55
|
+
* @returns a new ActionBuilder instance
|
|
56
|
+
*/
|
|
57
|
+
qosExactlyOnce(): SubscribeActionBuilder;
|
|
58
|
+
/**
|
|
59
|
+
* Wait for the checks to complete
|
|
60
|
+
*
|
|
61
|
+
* @param timeout - the check timeout
|
|
62
|
+
* @returns a new ActionBuilder instance
|
|
63
|
+
*/
|
|
64
|
+
await(timeout: Duration): SubscribeActionBuilder.Checkable;
|
|
65
|
+
/**
|
|
66
|
+
* Perform checks in the background, meaning state will have to be reconciled with {@link
|
|
67
|
+
* MqttDsl#waitForMessages()}
|
|
68
|
+
*
|
|
69
|
+
* @param timeout - the check timeout
|
|
70
|
+
* @returns the next DSL step
|
|
71
|
+
*/
|
|
72
|
+
expect(timeout: Duration): SubscribeActionBuilder.Checkable;
|
|
73
|
+
}
|
|
74
|
+
export declare const wrapSubscribeActionBuilder: (_underlying: JvmSubscribeActionBuilder) => SubscribeActionBuilder;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapSubscribeActionBuilder = exports.SubscribeActionBuilder = void 0;
|
|
4
|
+
const core_1 = require("@gatling.io/core");
|
|
5
|
+
var SubscribeActionBuilder;
|
|
6
|
+
(function (SubscribeActionBuilder) {
|
|
7
|
+
SubscribeActionBuilder.wrapCheckable = (_underlying) => ({
|
|
8
|
+
_underlying,
|
|
9
|
+
qosAtMostOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosAtMostOnce()),
|
|
10
|
+
qosAtLeastOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosAtLeastOnce()),
|
|
11
|
+
qosExactlyOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosExactlyOnce()),
|
|
12
|
+
check: (...checks) => SubscribeActionBuilder.wrapCheckable(_underlying.check(checks.map((cb) => cb._underlying)))
|
|
13
|
+
});
|
|
14
|
+
})(SubscribeActionBuilder || (exports.SubscribeActionBuilder = SubscribeActionBuilder = {}));
|
|
15
|
+
const wrapSubscribeActionBuilder = (_underlying) => ({
|
|
16
|
+
_underlying,
|
|
17
|
+
qosAtMostOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosAtMostOnce()),
|
|
18
|
+
qosAtLeastOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosAtLeastOnce()),
|
|
19
|
+
qosExactlyOnce: () => (0, exports.wrapSubscribeActionBuilder)(_underlying.qosExactlyOnce()),
|
|
20
|
+
// Checkable
|
|
21
|
+
await: (timeout) => {
|
|
22
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
23
|
+
return SubscribeActionBuilder.wrapCheckable(_underlying.await((0, core_1.toJvmDuration)(timeout)));
|
|
24
|
+
}
|
|
25
|
+
throw Error(`await() called with invalid argument ${timeout}`);
|
|
26
|
+
},
|
|
27
|
+
expect: (timeout) => {
|
|
28
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
29
|
+
return SubscribeActionBuilder.wrapCheckable(_underlying.expect((0, core_1.toJvmDuration)(timeout)));
|
|
30
|
+
}
|
|
31
|
+
throw Error(`expect() called with invalid argument ${timeout}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.wrapSubscribeActionBuilder = wrapSubscribeActionBuilder;
|
package/target/wait.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActionBuilder, Duration } from "@gatling.io/core";
|
|
2
|
+
import JvmWaitForMessagesActionBuilder = io.gatling.javaapi.mqtt.WaitForMessagesActionBuilder;
|
|
3
|
+
export interface WaitForMessagesActionBuilder extends ActionBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* Define the timeout for waiting for pending expects
|
|
6
|
+
*
|
|
7
|
+
* @param timeout - the timeout
|
|
8
|
+
* @returns a new WaitForMessagesActionBuilder instance
|
|
9
|
+
*/
|
|
10
|
+
timeout(timeout: Duration): WaitForMessagesActionBuilder;
|
|
11
|
+
}
|
|
12
|
+
export declare const wrapWaitForMessagesActionBuilder: (_underlying: JvmWaitForMessagesActionBuilder) => WaitForMessagesActionBuilder;
|
package/target/wait.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapWaitForMessagesActionBuilder = void 0;
|
|
4
|
+
const core_1 = require("@gatling.io/core");
|
|
5
|
+
const wrapWaitForMessagesActionBuilder = (_underlying) => ({
|
|
6
|
+
_underlying,
|
|
7
|
+
timeout: (timeout) => {
|
|
8
|
+
if ((0, core_1.isDuration)(timeout)) {
|
|
9
|
+
return (0, exports.wrapWaitForMessagesActionBuilder)(_underlying.timeout((0, core_1.toJvmDuration)(timeout)));
|
|
10
|
+
}
|
|
11
|
+
throw Error(`timeout() called with invalid argument ${timeout}`);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.wrapWaitForMessagesActionBuilder = wrapWaitForMessagesActionBuilder;
|