xref: /aosp_15_r20/external/sdk-platform-java/gapic-generator-java/src/test/proto/testing.proto (revision 882aa7c72c3cd3b66e72a261bdd69b93f7de7670)
1// Copyright 2018 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17import "google/api/annotations.proto";
18import "google/api/routing.proto";
19import "google/api/client.proto";
20import "google/api/resource.proto";
21import "google/protobuf/empty.proto";
22
23package google.showcase.v1beta1;
24
25option go_package = "github.com/googleapis/gapic-showcase/server/genproto";
26option java_package = "com.google.showcase.v1beta1";
27option java_multiple_files = true;
28
29// A service to facilitate running discrete sets of tests
30// against Showcase.
31service Testing {
32  // This service is meant to only run locally on the port 7469 (keypad digits
33  // for "show").
34  option (google.api.default_host) = "localhost:7469";
35  option (google.api.oauth_scopes) =
36      "https://www.googleapis.com/auth/cloud-platform";
37
38  // Creates a new testing session.
39  rpc CreateSession(CreateSessionRequest) returns (Session) {
40    option (google.api.http) = {
41      post: "/v1beta1/sessions"
42      body: "session"
43    };
44    option (google.api.method_signature) = "session,blueprint";
45  }
46
47  // Gets a testing session.
48  rpc GetSession(GetSessionRequest) returns (Session) {
49    option (google.api.http) = {
50      get: "/v1beta1/{name=sessions/*}"
51    };
52  }
53
54  // Lists the current test sessions.
55  rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {
56    option (google.api.http) = {
57      get: "/v1beta1/sessions"
58    };
59  }
60
61  // Delete a test session.
62  rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) {
63    option (google.api.http) = {
64      delete: "/v1beta1/{name=sessions/*}"
65    };
66  }
67
68  // Report on the status of a session.
69  // This generates a report detailing which tests have been completed,
70  // and an overall rollup.
71  rpc ReportSession(ReportSessionRequest) returns (ReportSessionResponse) {
72    option (google.api.http) = {
73      post: "/v1beta1/{name=sessions/*}:report"
74    };
75  }
76
77  // Gets a testing session.
78  rpc GetTest(GetTestRequest) returns (Test) {
79    option (google.api.http) = {
80      get: "/v1beta1/{name=tests/*}"
81    };
82    option (google.api.routing) = {
83      routing_parameters {
84        field: "name"
85        path_template: "/v1beta1/{rename=tests/*}"
86        }
87      routing_parameters {
88        field: "routing.name"
89        path_template: "/v1beta1/{routing_id=tests/*}"
90        }
91    };
92    option (google.api.method_signature) = "name";
93  }
94
95  // List the tests of a sessesion.
96  rpc ListTests(ListTestsRequest) returns (ListTestsResponse) {
97    option (google.api.http) = {
98      get: "/v1beta1/{parent=sessions/*}/tests"
99    };
100  }
101
102  // Explicitly decline to implement a test.
103  //
104  // This removes the test from subsequent `ListTests` calls, and
105  // attempting to do the test will error.
106  //
107  // This method will error if attempting to delete a required test.
108  rpc DeleteTest(DeleteTestRequest) returns (google.protobuf.Empty) {
109    option (google.api.http) = {
110      delete: "/v1beta1/{name=sessions/*/tests/*}"
111    };
112  }
113
114  // Register a response to a test.
115  //
116  // In cases where a test involves registering a final answer at the
117  // end of the test, this method provides the means to do so.
118  rpc VerifyTest(VerifyTestRequest) returns (VerifyTestResponse) {
119    option (google.api.http) = {
120      post: "/v1beta1/{name=sessions/*/tests/*}:check"
121      body: "*"
122      additional_bindings {
123        post: "/v1beta1/{foo=sessions/*/tests/*}:check"
124        body: "*"
125      }
126      additional_bindings {
127        post: "/v1beta1/{answer=sessions/*/tests/*}:check"
128        body: "*"
129      }
130      additional_bindings {
131        post: "/v1beta1/{test_to_verify.name=sessions/*/tests/*}:check"
132        body: "*"
133      }
134      // Test enums in HTTP fields.
135      additional_bindings { post: "/v1beta1/{type}:check" body: "*" }
136    };
137  }
138}
139
140// A session is a suite of tests, generally being made in the context
141// of testing code generation.
142//
143// A session defines tests it may expect, based on which version of the
144// code generation spec is in use.
145message Session {
146  option (google.api.resource) = {
147    type: "showcase.googleapis.com/Session"
148    pattern: "sessions/{session}"
149  };
150
151  // The name of the session. The ID must conform to ^[a-z]+$
152  // If this is not provided, Showcase chooses one at random.
153  string name = 1;
154
155  // The specification versions understood by Showcase.
156  enum Version {
157    // Unspecified version. If passed on creation, the session will default
158    // to using the latest stable release.
159    VERSION_UNSPECIFIED = 0;
160
161    // The latest v1. Currently, this is v1.0.
162    V1_LATEST = 1;
163
164    // v1.0. (Until the spec is "GA", this will be a moving target.)
165    V1_0 = 2;
166  }
167
168  // Required. The version this session is using.
169  Version version = 2;
170
171  map<int32, string> session_ids_to_descriptor = 3;
172}
173
174// The request for the CreateSession method.
175message CreateSessionRequest {
176  // The session to be created.
177  // Sessions are immutable once they are created (although they can
178  // be deleted).
179  Session session = 1;
180
181  // A blueprint is an explicit definition of methods and requests that are
182  // needed to be made to test this specific test case. Ideally this would be
183  // represented by something more robust like CEL, but as of writing this, I am
184  // unsure if CEL is ready.
185  message Blueprint {
186    option (google.api.resource) = {
187      type: "showcase.googleapis.com/Blueprint"
188      pattern: "sessions/{session}/tests/{test}/blueprints/{blueprint}"
189    };
190
191    // The name of this blueprint.
192    string name = 1;
193
194    // A description of this blueprint.
195    string description = 2;
196
197    // A message representing a method invocation.
198    message Invocation {
199      // The fully qualified name of the showcase method to be invoked.
200      string method = 1;
201
202      // The request to be made if a specific request is necessary.
203      bytes serialized_request = 2;
204    }
205
206    // The initial request to trigger this test.
207    Invocation request = 3;
208  }
209
210  // The blueprints that will satisfy this test. There may be multiple
211  // blueprints that can signal to the server that this test case is being
212  // exercised. Although multiple blueprints are specified, only a single
213  // blueprint needs to be run to signal that the test case was exercised.
214  Blueprint blueprint = 2;
215}
216
217// The request for the GetSession method.
218message GetSessionRequest {
219  // The session to be retrieved.
220  string name = 1 [(google.api.resource_reference).type =
221                       "showcase.googleapis.com/Session"];
222}
223
224// The request for the ListSessions method.
225message ListSessionsRequest {
226  // The maximum number of sessions to return per page.
227  int32 page_size = 1;
228
229  // The page token, for retrieving subsequent pages.
230  string page_token = 2;
231}
232
233// Response for the ListSessions method.
234message ListSessionsResponse {
235  // The sessions being returned.
236  repeated Session sessions = 1;
237
238  // The next page token, if any.
239  // An empty value here means the last page has been reached.
240  string next_page_token = 2;
241}
242
243// Request for the DeleteSession method.
244message DeleteSessionRequest {
245  // The session to be deleted.
246  string name = 1 [(google.api.resource_reference).type =
247                       "showcase.googleapis.com/Session"];
248}
249
250// Request message for reporting on a session.
251message ReportSessionRequest {
252  // The session to be reported on.
253  string name = 1 [(google.api.resource_reference).type =
254                       "showcase.googleapis.com/Session"];
255}
256
257// Response message for reporting on a session.
258message ReportSessionResponse {
259  // The topline state of the report.
260  enum Result {
261    RESULT_UNSPECIFIED = 0;
262
263    // The session is complete, and everything passed.
264    PASSED = 1;
265
266    // The session had an explicit failure.
267    FAILED = 2;
268
269    // The session is incomplete. This is a failure response.
270    INCOMPLETE = 3;
271  }
272
273  // The state of the report.
274  Result result = 1;
275
276  // The test runs of this session.
277  repeated TestRun test_runs = 2;
278}
279
280message GetTestRequest {
281  // The session to be retrieved.
282  string name = 1
283      [(google.api.resource_reference).type = "showcase.googleapis.com/Test"];
284  Routing routing = 2;
285}
286
287message Routing {
288  string name = 1;
289}
290
291message Test {
292  option (google.api.resource) = {
293    type: "showcase.googleapis.com/Test"
294    pattern: "sessions/{session}/tests/{shard_id}~{test_id}"
295  };
296
297  // The name of the test.
298  // The tests/* portion of the names are hard-coded, and do not change
299  // from session to session.
300  string name = 1;
301
302  // Whether or not a test is required, recommended, or optional.
303  enum ExpectationLevel {
304    EXPECTATION_LEVEL_UNSPECIFIED = 0;
305
306    // This test is strictly required.
307    REQUIRED = 1;
308
309    // This test is recommended.
310    //
311    // If a generator explicitly ignores a recommended test (see `DeleteTest`),
312    // then the report may still pass, but with a warning.
313    //
314    // If a generator skips a recommended test and does not explicitly
315    // express that intention, the report will fail.
316    RECOMMENDED = 2;
317
318    // This test is optional.
319    //
320    // If a generator explicitly ignores an optional test (see `DeleteTest`),
321    // then the report may still pass, and no warning will be issued.
322    //
323    // If a generator skips an optional test and does not explicitly
324    // express that intention, the report may still pass, but with a
325    // warning.
326    OPTIONAL = 3;
327  }
328
329  // The expectation level for this test.
330  ExpectationLevel expectation_level = 2;
331
332  // A description of the test.
333  string description = 3;
334}
335
336// An issue found in the test.
337message Issue {
338  // The different potential types of issues.
339  enum Type {
340    TYPE_UNSPECIFIED = 0;
341
342    // The test was never instrumented.
343    SKIPPED = 1;
344
345    // The test was started but never confirmed.
346    PENDING = 2;
347
348    // The test was instrumented, but Showcase got an unexpected
349    // value when the generator tried to confirm success.
350    INCORRECT_CONFIRMATION = 3;
351  }
352
353  // The type of the issue.
354  Type type = 1;
355
356  // Severity levels.
357  enum Severity {
358    SEVERITY_UNSPECIFIED = 0;
359
360    // Errors.
361    ERROR = 1;
362
363    // Warnings.
364    WARNING = 2;
365  }
366
367  // The severity of the issue.
368  Severity severity = 2;
369
370  // A description of the issue.
371  string description = 3;
372}
373
374// The request for the ListTests method.
375message ListTestsRequest {
376  // The session.
377  string parent = 1 [(google.api.resource_reference).type =
378                         "showcase.googleapis.com/Session"];
379
380  // The maximum number of tests to return per page.
381  int32 page_size = 2;
382
383  // The page token, for retrieving subsequent pages.
384  string page_token = 3;
385}
386
387// The response for the ListTests method.
388message ListTestsResponse {
389  // The tests being returned.
390  repeated Test tests = 1;
391
392  // The next page token, if any.
393  // An empty value here means the last page has been reached.
394  string next_page_token = 2;
395}
396
397// A TestRun is the result of running a Test.
398message TestRun {
399  // The name of the test.
400  // The tests/* portion of the names are hard-coded, and do not change
401  // from session to session.
402  string test = 1
403      [(google.api.resource_reference).type = "showcase.googleapis.com/Test"];
404
405  // An issue found with the test run. If empty, this test run was successful.
406  Issue issue = 2;
407}
408
409// Request message for deleting a test.
410message DeleteTestRequest {
411  // The test to be deleted.
412  string name = 1
413      [(google.api.resource_reference).type = "showcase.googleapis.com/Test"];
414}
415
416message VerifyTestRequest {
417  // The test to have an answer registered to it.
418  string name = 1
419      [(google.api.resource_reference).type = "showcase.googleapis.com/Test"];
420
421  // The answer from the test.
422  bytes answer = 2;
423
424  // The answers from the test if multiple are to be checked
425  repeated bytes answers = 3;
426
427  // Test fields for HTTP annotations.
428  string foo = 4;
429
430  Test test_to_verify = 5;
431
432  // For testing enums in HTTP fields.
433  Issue.Type type = 6;
434}
435
436message VerifyTestResponse {
437  // An issue if check answer was unsuccessful. This will be empty if the check
438  // answer succeeded.
439  Issue issue = 1;
440}
441