@ably-labs/locust 0.0.4 → 0.0.6

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/README.md CHANGED
@@ -14,7 +14,7 @@ See [example/users.ts](/example/users.ts) for an example of defining Locust user
14
14
 
15
15
  The example can be run by copying `example/.env.sample` to `example/.env`, setting `ABLY_API_KEY` to your Ably API key, and running [Docker Compose](https://docs.docker.com/compose/):
16
16
 
17
- ```
17
+ ```bash
18
18
  cd example
19
19
 
20
20
  cp .env.sample .env
@@ -36,7 +36,7 @@ Locust has the concept of a User which runs a set of requests during a load test
36
36
 
37
37
  `ably-locust` is an implementation of a Locust worker process in JavaScript. It can be installed by running:
38
38
 
39
- ```
39
+ ```bash
40
40
  npm install @ably-labs/locust
41
41
  ```
42
42
 
@@ -48,7 +48,7 @@ One of the messages a worker receives is a `spawn` message which declares how ma
48
48
 
49
49
  For example, assuming there is a Locust master running at `locust.example.com:5557` which is using the following `locustfile.py`:
50
50
 
51
- ```
51
+ ```python
52
52
  from locust import User
53
53
 
54
54
  class ExampleUser(User):
@@ -57,7 +57,7 @@ class ExampleUser(User):
57
57
 
58
58
  Then here's an example program where each user reports a successful request every second:
59
59
 
60
- ```
60
+ ```javascript
61
61
  const { Worker } = require('@ably-labs/locust');
62
62
 
63
63
  const worker = new Worker({
@@ -88,7 +88,7 @@ worker.run();
88
88
 
89
89
  Start an instance of Locust and run the tests:
90
90
 
91
- ```
91
+ ```bash
92
92
  cd tests
93
93
 
94
94
  docker compose up --build
package/lib/Worker.js CHANGED
@@ -144,7 +144,7 @@ var Worker = /** @class */ (function () {
144
144
  data = _c.value[0];
145
145
  try {
146
146
  msg = Message_1.Message.decode(data);
147
- this.log.info("Received '" + msg.type + "' message");
147
+ this.log.debug("Received '" + msg.type + "' message");
148
148
  this.handle(msg);
149
149
  }
150
150
  catch (err) {
@@ -237,6 +237,7 @@ var Worker = /** @class */ (function () {
237
237
  this.lastReceivedSpawnTimestamp = data.timestamp;
238
238
  this.state = "spawning" /* Spawning */;
239
239
  this.send("spawning" /* Spawning */, null);
240
+ this.log.info("Handling spawn message: expected = " + JSON.stringify(data.user_classes_count) + ", actual = " + JSON.stringify(this.spawnState().user_classes_count));
240
241
  for (var _i = 0, _a = Object.keys(data.user_classes_count); _i < _a.length; _i++) {
241
242
  var userClass = _a[_i];
242
243
  // check we have a registered function for the given class
@@ -317,6 +318,7 @@ var Worker = /** @class */ (function () {
317
318
  * Start the given number of users.
318
319
  */
319
320
  Worker.prototype.startUsers = function (userClass, userFn, count) {
321
+ this.log.debug("Starting " + count + " " + userClass + " users");
320
322
  for (var i = 0; i < count; i++) {
321
323
  try {
322
324
  var user = userFn();
@@ -340,6 +342,7 @@ var Worker = /** @class */ (function () {
340
342
  * Stop the given number of users.
341
343
  */
342
344
  Worker.prototype.stopUsers = function (userClass, count) {
345
+ this.log.debug("Stopping " + count + " " + userClass + " users");
343
346
  for (var i = 0; i < count; i++) {
344
347
  var user = this.users[userClass].pop();
345
348
  if (user !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ably-labs/locust",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A JavaScript load generator for Locust.io.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -36,8 +36,8 @@
36
36
  "typescript": "^4.4.4"
37
37
  },
38
38
  "dependencies": {
39
+ "@ably/zeromq": "^6.0.0-beta.ably.3",
39
40
  "msgpack5": "^5.3.2",
40
- "winston": "^3.3.3",
41
- "zeromq": "^6.0.0-beta.6"
41
+ "winston": "^3.3.3"
42
42
  }
43
43
  }