From 1ed241e7bafbe9627c2db9367a68e926ce435bd3 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 25 Aug 2022 17:54:26 +0100 Subject: [PATCH 1/7] add property to json schema --- jsonschema/TestCaseStarted.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonschema/TestCaseStarted.json b/jsonschema/TestCaseStarted.json index 672ce32d..5800aaa4 100644 --- a/jsonschema/TestCaseStarted.json +++ b/jsonschema/TestCaseStarted.json @@ -20,6 +20,10 @@ "testCaseId": { "type": "string" }, + "workerId": { + "description": "An identifier for the worker process running this test case, if test cases are being run in parallel. The identifier will be unique per worker, but no particular format is defined - it could be an index, uuid, machine name etc - and as such should be assumed that it's not human readable.", + "type": "string" + }, "timestamp": { "$ref": "./Timestamp.json" } From b6b9448d9c1420e99a75669744021024cba1f161 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 25 Aug 2022 18:55:53 +0000 Subject: [PATCH 2/7] regenerate code --- go/messages.go | 1 + .../messages/types/TestCaseStarted.java | 10 +++++++++ javascript/src/messages.ts | 2 ++ messages.md | 1 + perl/lib/Cucumber/Messages.pm | 12 +++++++++++ php/src-generated/TestCaseStarted.php | 21 +++++++++++++++++++ ruby/lib/cucumber/messages.deserializers.rb | 1 + ruby/lib/cucumber/messages.dtos.rb | 7 +++++++ 8 files changed, 55 insertions(+) diff --git a/go/messages.go b/go/messages.go index b87e7f8c..7578da47 100644 --- a/go/messages.go +++ b/go/messages.go @@ -321,6 +321,7 @@ type TestCaseStarted struct { Attempt int64 `json:"attempt"` Id string `json:"id"` TestCaseId string `json:"testCaseId"` + WorkerId string `json:"workerId,omitempty"` Timestamp *Timestamp `json:"timestamp"` } diff --git a/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java b/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java index 0de9df75..2532ab21 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java @@ -13,17 +13,20 @@ public final class TestCaseStarted { private final Long attempt; private final String id; private final String testCaseId; + private final String workerId; private final Timestamp timestamp; public TestCaseStarted( Long attempt, String id, String testCaseId, + String workerId, Timestamp timestamp ) { this.attempt = requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); this.id = requireNonNull(id, "TestCaseStarted.id cannot be null"); this.testCaseId = requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + this.workerId = workerId; this.timestamp = requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } @@ -39,6 +42,10 @@ public String getTestCaseId() { return testCaseId; } + public Optional getWorkerId() { + return Optional.ofNullable(workerId); + } + public Timestamp getTimestamp() { return timestamp; } @@ -52,6 +59,7 @@ public boolean equals(Object o) { attempt.equals(that.attempt) && id.equals(that.id) && testCaseId.equals(that.testCaseId) && + Objects.equals(workerId, that.workerId) && timestamp.equals(that.timestamp); } @@ -61,6 +69,7 @@ public int hashCode() { attempt, id, testCaseId, + workerId, timestamp ); } @@ -71,6 +80,7 @@ public String toString() { "attempt=" + attempt + ", id=" + id + ", testCaseId=" + testCaseId + + ", workerId=" + workerId + ", timestamp=" + timestamp + '}'; } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 8e6903ec..63c31772 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -583,6 +583,8 @@ export class TestCaseStarted { testCaseId: string = '' + workerId?: string + @Type(() => Timestamp) timestamp: Timestamp = new Timestamp() } diff --git a/messages.md b/messages.md index 43890766..0248b3ee 100644 --- a/messages.md +++ b/messages.md @@ -419,6 +419,7 @@ will only have one of its fields set, which indicates the payload of the message | `attempt` | integer | yes | | | `id` | string | yes | | | `testCaseId` | string | yes | | +| `workerId` | string | no | | | `timestamp` | [Timestamp](#timestamp) | yes | | ## TestRunFinished diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 7d733ea7..9ec1cc29 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -4070,6 +4070,7 @@ my %types = ( attempt => 'number', id => 'string', test_case_id => 'string', + worker_id => 'string', timestamp => 'Cucumber::Messages::Timestamp', ); @@ -4123,6 +4124,17 @@ has test_case_id => ); +=head4 worker_id + +An identifier for the worker process running this test case, if test cases are being run in parallel. The identifier will be unique per worker, but no particular format is defined - it could be an index, uuid, machine name etc - and as such should be assumed that it's not human readable. + +=cut + +has worker_id => + (is => 'ro', + ); + + =head4 timestamp diff --git a/php/src-generated/TestCaseStarted.php b/php/src-generated/TestCaseStarted.php index 2a518012..42164161 100644 --- a/php/src-generated/TestCaseStarted.php +++ b/php/src-generated/TestCaseStarted.php @@ -38,6 +38,15 @@ public function __construct( */ public readonly string $id = '', public readonly string $testCaseId = '', + + /** + * An identifier for the worker process running this test case, if test + * cases are being run in parallel. The identifier will be unique per + * worker, but no particular format is defined - it could be an index, + * uuid, machine name etc - and as such should be assumed that it's not + * human readable. + */ + public readonly ?string $workerId = null, public readonly Timestamp $timestamp = new Timestamp(), ) { } @@ -52,12 +61,14 @@ public static function fromArray(array $arr): self self::ensureAttempt($arr); self::ensureId($arr); self::ensureTestCaseId($arr); + self::ensureWorkerId($arr); self::ensureTimestamp($arr); return new self( (int) $arr['attempt'], (string) $arr['id'], (string) $arr['testCaseId'], + isset($arr['workerId']) ? (string) $arr['workerId'] : null, Timestamp::fromArray($arr['timestamp']), ); } @@ -101,6 +112,16 @@ private static function ensureTestCaseId(array $arr): void } } + /** + * @psalm-assert array{workerId?: string|int|bool} $arr + */ + private static function ensureWorkerId(array $arr): void + { + if (array_key_exists('workerId', $arr) && is_array($arr['workerId'])) { + throw new SchemaViolationException('Property \'workerId\' was array'); + } + } + /** * @psalm-assert array{timestamp: array} $arr */ diff --git a/ruby/lib/cucumber/messages.deserializers.rb b/ruby/lib/cucumber/messages.deserializers.rb index 8e072ad0..17fa2d52 100644 --- a/ruby/lib/cucumber/messages.deserializers.rb +++ b/ruby/lib/cucumber/messages.deserializers.rb @@ -1031,6 +1031,7 @@ def self.from_h(hash) attempt: hash[:attempt], id: hash[:id], test_case_id: hash[:testCaseId], + worker_id: hash[:workerId], timestamp: Timestamp.from_h(hash[:timestamp]), ) end diff --git a/ruby/lib/cucumber/messages.dtos.rb b/ruby/lib/cucumber/messages.dtos.rb index a77230f7..478cd029 100644 --- a/ruby/lib/cucumber/messages.dtos.rb +++ b/ruby/lib/cucumber/messages.dtos.rb @@ -1694,17 +1694,24 @@ class TestCaseStarted < ::Cucumber::Messages::Message attr_reader :test_case_id + ## + # An identifier for the worker process running this test case, if test cases are being run in parallel. The identifier will be unique per worker, but no particular format is defined - it could be an index, uuid, machine name etc - and as such should be assumed that it's not human readable. + + attr_reader :worker_id + attr_reader :timestamp def initialize( attempt: 0, id: '', test_case_id: '', + worker_id: nil, timestamp: Timestamp.new ) @attempt = attempt @id = id @test_case_id = test_case_id + @worker_id = worker_id @timestamp = timestamp end end From 970b9d15ee85221f224f77a5e33c75388da7e3eb Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 25 Aug 2022 19:57:59 +0100 Subject: [PATCH 3/7] fix php code --- php/src-generated/TestCaseStarted.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/php/src-generated/TestCaseStarted.php b/php/src-generated/TestCaseStarted.php index 42164161..069abce1 100644 --- a/php/src-generated/TestCaseStarted.php +++ b/php/src-generated/TestCaseStarted.php @@ -40,11 +40,7 @@ public function __construct( public readonly string $testCaseId = '', /** - * An identifier for the worker process running this test case, if test - * cases are being run in parallel. The identifier will be unique per - * worker, but no particular format is defined - it could be an index, - * uuid, machine name etc - and as such should be assumed that it's not - * human readable. + * An identifier for the worker process running this test case, if test cases are being run in parallel. The identifier will be unique per worker, but no particular format is defined - it could be an index, uuid, machine name etc - and as such should be assumed that it's not human readable. */ public readonly ?string $workerId = null, public readonly Timestamp $timestamp = new Timestamp(), From e2145ab91d146b5147c70cebe68edce6b69517b1 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 25 Aug 2022 20:03:09 +0100 Subject: [PATCH 4/7] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b0277e6..35a46293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) + ### Changed ### Deprecated From 2ccdd5930948919f51e43842cd21ff47300d5a83 Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 13 Sep 2022 15:01:40 +0100 Subject: [PATCH 5/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63fe2732..cacbc64a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added -- Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) +- BREAKING CHANGE: Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) ### Changed From 5613d7a6bc181047831098905a50aaee61a31580 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 22 Sep 2022 09:00:58 +0100 Subject: [PATCH 6/7] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cacbc64a..b30e5a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added -- BREAKING CHANGE: Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) - ### Changed +- BREAKING CHANGE: Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) + ### Deprecated ### Removed From b98610f10bf7a245badfb4204d7f103e50d2b81e Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 22 Sep 2022 09:01:51 +0100 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef3bbe6..f1d78918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,21 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - -## [19.1.3] - 2022-09-20 -### Added - ### Changed - - BREAKING CHANGE: Add `workerId` field to TestCaseStarted message ([#34](https://github.com/cucumber/messages/pull/34)) -### Deprecated - +## [19.1.3] - 2022-09-20 ### Fixed - Add `name` field to `package.cjs.json` ([#36](https://github.com/cucumber/messages/pull/36)) -### Removed - ## [19.1.2] - 2022-06-22 ### Fixed - [Javascript] Schema was still missing in 19.1.1 due to how npm manages the files attribute in package.json