Goby3 3.7.0
2026.11.12
Loading...
Searching...
No Matches
pubsub_test.proto
Go to the documentation of this file.
1// Copyright 2026:
2// GobySoft, LLC (2013-)
3// Community contributors (see AUTHORS file)
4// File authors:
5// Toby Schneider <toby@gobysoft.org>
6//
7//
8// This file is part of the Goby Underwater Autonomy Project Libraries
9// ("The Goby Libraries").
10//
11// The Goby Libraries are free software: you can redistribute them and/or modify
12// them under the terms of the GNU Lesser General Public License as published by
13// the Free Software Foundation, either version 2.1 of the License, or
14// (at your option) any later version.
15//
16// The Goby Libraries are distributed in the hope that they will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public License
22// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24syntax = "proto2";
25import "dccl/option_extensions.proto";
26import "goby/protobuf/option_extensions.proto";
27import "goby/middleware/protobuf/intervehicle_transporter_config.proto";
28
29package goby.middleware.protobuf;
30
31// Declarative publish/subscribe test run by 'goby zeromq test' and 'goby udpm test'.
32// Endpoints (connections to a layer) are declared by the transport-specific
33// tool configuration and referenced here by name.
34
35enum PubSubTestRunMode
36{
37 SEQUENTIAL = 1;
38 PARALLEL = 2;
39}
40
41message PubSubTestCondition
42{
43 enum Op
44 {
45 EQ = 1;
46 NE = 2;
47 LT = 3;
48 LE = 4;
49 GT = 5;
50 GE = 6;
51 REGEX = 7;
52 EXISTS = 8;
53 ABSENT = 9;
54 }
55
56 required string field = 1 [(goby.field).description =
57 "Dotted path into the message, with [n] for repeated fields, "
58 "e.g. 'pos.lat' or 'waypoint[0].id'"];
59 required Op op = 2;
60 optional string value = 3
61 [(goby.field).description =
62 "Value to compare against. Numeric comparison when both sides parse as numbers, "
63 "otherwise string comparison (enums compare by name). Regex for REGEX."];
64}
65
66message PubSubTestPublish
67{
68 option (dccl.msg).unit_system = "si";
69
70 optional string endpoint = 1
71 [(goby.field).description = "Endpoint name. Defaults to the first declared endpoint"];
72 required string group = 2
73 [(goby.field).description =
74 "Group name. On intervehicle endpoints, the numeric group "
75 "(e.g. \"7\"; \"0\" is broadcast)"];
76 required string type = 3 [(goby.field).description =
77 "Scheme and type as for 'goby zeromq publish', e.g. "
78 "'PROTOBUF/NavigationReport', 'DCCL/NavigationReport', "
79 "'JSON/NavigationReport', 'JSON' or 'protobuf.NavigationReport'"];
80 required string value = 4 [(goby.field).description =
81 "TextFormat (PROTOBUF/DCCL) or JSON (JSON) message contents"];
82 optional uint32 repeat = 5 [default = 1];
83 optional double interval = 6 [default = 0, (dccl.field).units.base_dimensions = "T"];
84 optional double delay = 7 [
85 default = 0,
86 (dccl.field).units.base_dimensions = "T",
87 (goby.field).description = "Wait this long after arming the run's expectations "
88 "before publishing"
89 ];
90
91 // intervehicle endpoints only
92 optional string group_field = 20 [
93 (goby.field).description =
94 "Intervehicle endpoints: top-level integer field of the message that carries the "
95 "numeric group. Required unless the group is 0 (broadcast)"
96 ];
97 optional goby.middleware.intervehicle.protobuf.TransporterConfig
98 intervehicle = 21 [
99 (goby.field).description =
100 "Intervehicle endpoints: the publication's settings (buffer, broadcast, "
101 "clear_pending). With buffer { ack_required: true }, acks and expiries are reported "
102 "on this endpoint in the publication's group as "
103 "PROTOBUF/goby.middleware.intervehicle.protobuf.AckData and ExpireData"
104 ];
105}
106
107message PubSubTestExpect
108{
109 option (dccl.msg).unit_system = "si";
110
111 optional string endpoint = 1
112 [(goby.field).description = "Endpoint name. Defaults to the first declared endpoint"];
113 optional string group = 2 [
114 default = ".*",
115 (goby.field).description =
116 "Group regex. On intervehicle endpoints, the numeric group to subscribe to (e.g. \"7\")"
117 ];
118 optional string type = 3 [
119 default = ".*",
120 (goby.field).description =
121 "Type regex, optionally prefixed by scheme and '/', e.g. 'DCCL/.*', "
122 "'JSON/NavigationReport', 'protobuf.NavigationReport'"
123 ];
124 optional string scheme = 4
125 [(goby.field).description =
126 "Restrict to this marshalling scheme (name or number) when 'type' has no prefix"];
127
128 optional uint32 count = 10
129 [(goby.field).description =
130 "Exactly this many matching messages. The run lasts its full timeout "
131 "so that extra messages are detected. Use 0 to assert that nothing arrives."];
132 optional uint32 min_count = 11 [
133 default = 1,
134 (goby.field).description = "At least this many matching messages (ignored if 'count' is set). "
135 "The run completes as soon as every expectation reaches its minimum"
136 ];
137 optional uint32 max_count = 12
138 [(goby.field).description = "More than this many matching messages fails the expectation "
139 "(ignored if 'count' is set)"];
140 optional double timeout = 13
141 [(dccl.field).units.base_dimensions = "T",
142 (goby.field).description = "Defaults to the run timeout, then the test default_timeout"];
143
144 optional string match = 20
145 [(goby.field).description =
146 "Partial message (TextFormat for PROTOBUF/DCCL, JSON for JSON): every field set here "
147 "must equal the received value. Messages that do not match are counted as rejected "
148 "rather than received."];
149 repeated PubSubTestCondition condition = 21;
150
151 // intervehicle endpoints only
152 optional string group_field = 30 [
153 (goby.field).description =
154 "Intervehicle endpoints: top-level integer field of the message that carries the "
155 "numeric group. Required unless the group is 0 (broadcast)"
156 ];
157 optional goby.middleware.intervehicle.protobuf.TransporterConfig
158 intervehicle = 31 [
159 (goby.field).description =
160 "Intervehicle endpoints: the subscription's settings (publisher_id, buffer, "
161 "broadcast). Subscriptions are made once require_app has passed, before the first "
162 "run, so publishes need a delay that lets them cross the link"
163 ];
164}
165
166message PubSubTestStep
167{
168 option (dccl.msg).unit_system = "si";
169
170 optional string name = 1;
171 repeated PubSubTestPublish publish = 10;
172 repeated PubSubTestExpect expect = 11;
173 optional double timeout = 20
174 [(dccl.field).units.base_dimensions = "T",
175 (goby.field).description = "Default timeout for this step's expectations"];
176 optional double wait = 21 [
177 (dccl.field).units.base_dimensions = "T",
178 (goby.field).description =
179 "Hold this step open for at least this long (seconds). With no publish or expect "
180 "entries it is a plain pause."
181 ];
182}
183
184message PubSubTestRun
185{
186 option (dccl.msg).unit_system = "si";
187
188 optional string name = 1;
189 optional PubSubTestRunMode mode = 2
190 [default = SEQUENTIAL, (goby.field).description = "How this run's steps are executed"];
191 repeated PubSubTestStep step = 3
192 [(goby.field).description =
193 "Child steps. A run with no steps is itself a step using its own publish/expect"];
194
195 repeated PubSubTestPublish publish = 10;
196 repeated PubSubTestExpect expect = 11;
197
198 optional double timeout = 20
199 [(dccl.field).units.base_dimensions = "T",
200 (goby.field).description = "Default timeout for this run's expectations"];
201 optional double wait = 21 [
202 (dccl.field).units.base_dimensions = "T",
203 (goby.field).description =
204 "Hold this run open for at least this long (seconds); only for a run without "
205 "steps. With no publish or expect entries it is a plain pause."
206 ];
207
208 optional uint32 repeat = 22 [
209 default = 1,
210 (goby.field).description =
211 "Run this many times in sequence (for each for_each entry, if any). ${ITERATION} "
212 "is the pass number, from 1"
213 ];
214 repeated PubSubTestParameters for_each = 23
215 [(goby.field).description =
216 "One pass per entry, with ${NAME} in this run's text replaced by the entry's value "
217 "for NAME"];
218}
219
220message PubSubTestParameters
221{
222 // a list of key/value pairs rather than a map, which the DCCL plugin can't generate;
223 // YAML test files can still write it as a map
224 message Var
225 {
226 required string key = 1;
227 required string value = 2;
228 }
229 repeated Var var = 1;
230}
231
232message PubSubTestRequireApp
233{
234 option (dccl.msg).unit_system = "si";
235
236 optional string endpoint = 1
237 [(goby.field).description = "Endpoint name. Defaults to the first declared endpoint"];
238 repeated string name = 2 [(goby.field).description = "Application names that must respond"];
239 optional double timeout = 3 [default = 30, (dccl.field).units.base_dimensions = "T"];
240 optional bool require_ok = 4
241 [default = false,
242 (goby.field).description = "Also require each application to report HEALTH__OK"];
243 optional double request_interval = 5 [
244 default = 1,
245 (dccl.field).units.base_dimensions = "T",
246 (goby.field).description =
247 "How often to publish HealthRequest. Requests stop once a goby_coroner report is seen, "
248 "after which the coroner's report is used instead."
249 ];
250}
251
252message PubSubTest
253{
254 option (dccl.msg).unit_system = "si";
255
256 optional string name = 1;
257 optional double default_timeout = 2 [default = 5, (dccl.field).units.base_dimensions = "T"];
258 optional double connect_timeout = 3 [
259 default = 10,
260 (dccl.field).units.base_dimensions = "T",
261 (goby.field).description = "Time allowed for all endpoints to connect"
262 ];
263
264 repeated PubSubTestRequireApp require_app = 10;
265
266 optional PubSubTestRunMode mode = 20
267 [default = SEQUENTIAL, (goby.field).description = "How the runs are executed"];
268 repeated PubSubTestRun run = 21;
269}
270
271// Result of a test run, emitted as JSON by --output_format json
272
273enum PubSubTestResult
274{
275 PASS = 1;
276 FAIL = 2;
277 ERROR = 3;
278}
279
280message PubSubTestExpectReport
281{
282 option (dccl.msg).unit_system = "si";
283
284 optional string endpoint = 1;
285 optional string group = 2;
286 optional string type = 3;
287 required PubSubTestResult result = 4;
288 optional uint32 received = 5 [(goby.field).description = "Matching messages"];
289 optional uint32 rejected = 6
290 [(goby.field).description = "Messages on the group/type that failed match or conditions"];
291 optional uint32 min_count = 7;
292 optional uint32 max_count = 8;
293 optional double elapsed = 9 [(dccl.field).units.base_dimensions = "T"];
294 optional string reason = 10;
295 optional string last_rejected = 11
296 [(goby.field).description = "Why the most recent rejected message was rejected"];
297}
298
299message PubSubTestPublishReport
300{
301 optional string endpoint = 1;
302 optional string group = 2;
303 optional string type = 3;
304 optional uint32 count = 4;
305}
306
307message PubSubTestStepReport
308{
309 option (dccl.msg).unit_system = "si";
310
311 optional string name = 1;
312 required PubSubTestResult result = 2;
313 optional double elapsed = 3 [(dccl.field).units.base_dimensions = "T"];
314 repeated PubSubTestPublishReport publish = 4;
315 repeated PubSubTestExpectReport expect = 5;
316 optional double wait = 6 [(dccl.field).units.base_dimensions = "T"];
317}
318
319message PubSubTestRunReport
320{
321 option (dccl.msg).unit_system = "si";
322
323 optional string name = 1;
324 optional PubSubTestRunMode mode = 2;
325 required PubSubTestResult result = 3;
326 optional double elapsed = 4 [(dccl.field).units.base_dimensions = "T"];
327 repeated PubSubTestStepReport step = 5;
328 repeated PubSubTestPublishReport publish = 6;
329 repeated PubSubTestExpectReport expect = 7;
330 optional double wait = 8 [(dccl.field).units.base_dimensions = "T"];
331}
332
333message PubSubTestRequireAppReport
334{
335 option (dccl.msg).unit_system = "si";
336
337 optional string endpoint = 1;
338 required PubSubTestResult result = 2;
339 repeated string name = 3;
340 repeated string missing = 4;
341 repeated string unhealthy = 5;
342 optional double elapsed = 6 [(dccl.field).units.base_dimensions = "T"];
343 optional bool from_coroner = 7
344 [(goby.field).description = "True if a goby_coroner report was used"];
345}
346
347// A problem found while loading or validating a test file
348message PubSubTestIssue
349{
350 optional string location = 1
351 [(goby.field).description =
352 "Where the problem is: a file name, a field path such as "
353 "'test.run[2].expect[0].match', or both"];
354 required string message = 2;
355}
356
357message PubSubTestValidation
358{
359 optional string file = 1;
360 required bool valid = 2;
361 repeated PubSubTestIssue issue = 3;
362}
363
364message PubSubTestFixtureReport
365{
366 option (dccl.msg).unit_system = "si";
367
368 required string name = 1;
369 required PubSubTestResult result = 2;
370 optional double ready_time = 3 [
371 (dccl.field).units.base_dimensions = "T",
372 (goby.field).description = "Seconds from start until the fixture was ready"
373 ];
374 optional string reason = 4;
375 optional string log_file = 5;
376 optional int32 exit_status = 6
377 [(goby.field).description = "Exit status if the fixture exited by itself"];
378 optional int32 exit_signal = 7
379 [(goby.field).description = "Signal number if the fixture was ended by a signal"];
380 repeated string output_tail = 8
381 [(goby.field).description = "Last lines of output, included when the test did not pass"];
382}
383
384message PubSubTestReport
385{
386 option (dccl.msg).unit_system = "si";
387
388 optional string name = 1;
389 required PubSubTestResult result = 2;
390 optional double elapsed = 3 [(dccl.field).units.base_dimensions = "T"];
391 optional string error = 4 [(goby.field).description = "Set when result is ERROR"];
392
393 repeated PubSubTestRequireAppReport require_app = 10;
394 repeated PubSubTestRunReport run = 11;
395 repeated PubSubTestFixtureReport fixture = 12;
396 repeated PubSubTestReport pass = 14
397 [(goby.field).description = "Each pass of the test when run with --repeat"];
398 repeated PubSubTestIssue issue = 13
399 [(goby.field).description = "Validation problems that prevented the test from running"];
400}