Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-11-10 12:10:43 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-11-14 11:07:31 +0300
commitd247ec65163185553af587120ca9f013f06540b8 (patch)
treee511e915f9b2493429353ebb8d70b333bdbefc54 /proto/testproto
parente8fb35a99a9ece6ed3ea2fd52817e18258d4d3ac (diff)
tools/protoc-gen-gitaly-lint: Move test Protobuf definitions
While we were able to get rid of all custom Protobuf definitions used for tests, this is definitely not possible for our tests that verify the behaviour of `protoc-gen-gitaly-lint`. Its whole purpose is to lint invalid Protobuf definitions, and we of course ain't got any in our normal gRPC services. We can still make the generation of this test-specific Protobuf code easier by moving the definitions into a new `proto/testproto` directory so that they live in the same filesystem hierarchy as the other Protobuf definitions. This both allows us to unify the call to protoc and will allow us to easily change the directory where the code is generated in in a subsequent commit.
Diffstat (limited to 'proto/testproto')
-rw-r--r--proto/testproto/invalid.proto213
-rw-r--r--proto/testproto/valid.proto148
2 files changed, 361 insertions, 0 deletions
diff --git a/proto/testproto/invalid.proto b/proto/testproto/invalid.proto
new file mode 100644
index 000000000..d9b993c89
--- /dev/null
+++ b/proto/testproto/invalid.proto
@@ -0,0 +1,213 @@
+syntax = "proto3";
+
+package testproto;
+
+import "lint.proto";
+import "shared.proto";
+
+option go_package = "gitlab.com/gitlab-org/gitaly/v15/proto/testproto";
+
+message InvalidMethodRequest {
+}
+
+message InvalidMethodRequestWithRepo {
+ gitaly.Repository destination = 1 [(gitaly.target_repository)=true];
+}
+
+message InvalidTargetType {
+ int32 wrong_type = 1 [(gitaly.target_repository)=true];
+}
+
+message InvalidMethodResponse{
+}
+
+message InvalidNestedRequest{
+ InvalidTargetType inner_message = 1;
+}
+
+message RequestWithStorage {
+ string storage_name = 1 [(gitaly.storage)=true];
+ gitaly.Repository destination = 2;
+}
+
+message RequestWithStorageAndRepo {
+ string storage_name = 1 [(gitaly.storage)=true];
+ gitaly.Repository destination = 2 [(gitaly.target_repository)=true];
+}
+
+message RequestWithNestedStorageAndRepo{
+ RequestWithStorageAndRepo inner_message = 1;
+}
+
+message RequestWithMultipleNestedStorage{
+ RequestWithStorage inner_message = 1;
+ string storage_name = 2 [(gitaly.storage)=true];
+}
+
+message RequestWithInnerNestedStorage {
+ message Header {
+ string storage_name = 1 [(gitaly.storage) = true];
+ }
+
+ Header header = 1;
+}
+
+message RequestWithWrongTypeRepository {
+ message Header {
+ InvalidMethodResponse repository = 1 [(gitaly.repository) = true];
+ }
+
+ Header header = 1 [(gitaly.target_repository) = true];
+}
+
+message RequestWithNestedRepoNotFlagged {
+ message Header {
+ gitaly.Repository repository = 1;
+ }
+
+ Header header = 1 [(gitaly.target_repository) = true];
+}
+
+service InterceptedWithOperationType {
+ option (gitaly.intercepted) = true;
+
+ // intercepted services can't have operation type annotations.
+ rpc InvalidMethod(InvalidMethodRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: ACCESSOR
+ };
+ }
+}
+
+service InvalidService {
+ // should fail if op_type extension is missing
+ rpc InvalidMethod0(InvalidMethodRequest) returns (InvalidMethodResponse) {}
+
+ // should fail if op type is unknown
+ rpc InvalidMethod1(InvalidMethodRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = UNKNOWN;
+ }
+ // should fail if target repo is not provided for accessor
+ rpc InvalidMethod2(InvalidMethodRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: ACCESSOR
+ };
+ }
+ // should fail if missing either target repo or non-repo-scope for mutator
+ rpc InvalidMethod4(InvalidMethodRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MUTATOR;
+ }
+
+ // should fail if repository is not of type Repository
+ rpc InvalidMethod5(RequestWithWrongTypeRepository) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MUTATOR;
+ }
+
+ // should fail if nested repository isn't flagged
+ rpc InvalidMethod6(RequestWithNestedRepoNotFlagged) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MUTATOR;
+ }
+ // should fail if target field type is not of type Repository
+ rpc InvalidMethod7(InvalidTargetType) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+
+ // should fail if nested target field type is not of type Repository
+ rpc InvalidMethod8(InvalidNestedRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+ // should fail if target repo is specified for storage scoped RPC
+ rpc InvalidMethod9(InvalidMethodRequestWithRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: STORAGE
+ };
+ }
+
+ // should fail if storage is specified for implicit repository scoped RPC
+ rpc InvalidMethod10(RequestWithStorageAndRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: ACCESSOR
+ };
+ }
+
+ // should fail if storage is specified for repository scoped RPC
+ rpc InvalidMethod11(RequestWithNestedStorageAndRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: REPOSITORY
+ };
+ }
+
+ // should fail if storage isn't specified for storage scoped RPC
+ rpc InvalidMethod13(InvalidTargetType) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: STORAGE
+ };
+ }
+
+ // should fail if multiple storage is specified for storage scoped RPC
+ rpc InvalidMethod14(RequestWithMultipleNestedStorage) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: STORAGE
+ };
+ }
+
+ // Intercepted methods must not have operation type annotations.
+ rpc InvalidMethod15(RequestWithStorageAndRepo) returns (InvalidMethodResponse) {
+ option (gitaly.intercepted_method) = true;
+ option (gitaly.op_type) = {};
+ };
+
+ rpc MaintenanceWithMissingRepository(InvalidMethodRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MAINTENANCE;
+ }
+
+ rpc MaintenanceWithUnflaggedRepository(RequestWithNestedRepoNotFlagged) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MAINTENANCE;
+ }
+
+ rpc MaintenanceWithWrongNestedRepositoryType(RequestWithWrongTypeRepository) returns (InvalidMethodResponse) {
+ option (gitaly.op_type).op = MAINTENANCE;
+ }
+
+ rpc MaintenanceWithInvalidTargetType(InvalidTargetType) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+ rpc MaintenanceWithInvalidNestedRequest(InvalidNestedRequest) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+ rpc MaintenanceWithStorageAndRepository(RequestWithStorageAndRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ scope_level: REPOSITORY
+ };
+ }
+
+ rpc MaintenanceWithNestedStorageAndRepository(RequestWithNestedStorageAndRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ scope_level: REPOSITORY
+ };
+ }
+
+ rpc MaintenanceWithStorageScope(InvalidMethodRequestWithRepo) returns (InvalidMethodResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ scope_level: STORAGE
+ };
+ }
+
+}
diff --git a/proto/testproto/valid.proto b/proto/testproto/valid.proto
new file mode 100644
index 000000000..0a023d100
--- /dev/null
+++ b/proto/testproto/valid.proto
@@ -0,0 +1,148 @@
+syntax = "proto3";
+
+package testproto;
+
+import "lint.proto";
+import "shared.proto";
+
+option go_package = "gitlab.com/gitlab-org/gitaly/v15/proto/testproto";
+
+message ValidRequest {
+ gitaly.Repository destination = 1 [(gitaly.target_repository)=true];
+}
+
+message ValidRequestWithoutRepo {
+}
+
+message ValidStorageRequest {
+ string storage_name = 1 [(gitaly.storage)=true];
+}
+
+message ValidResponse{
+}
+
+message ValidNestedRequest{
+ ValidRequest inner_message = 1;
+}
+
+message ValidStorageNestedRequest{
+ ValidStorageRequest inner_message = 1;
+}
+
+message ValidNestedSharedRequest {
+ gitaly.ObjectPool nested_target_repo = 1 [(gitaly.target_repository)=true];
+}
+
+message ValidInnerNestedRequest {
+ message Header {
+ gitaly.Repository destination = 1 [(gitaly.target_repository)=true];
+ }
+
+ Header header = 1;
+}
+
+message ValidStorageInnerNestedRequest {
+ message Header {
+ string storage_name = 1 [(gitaly.storage) = true];
+ }
+
+ Header header = 1;
+}
+
+service InterceptedService {
+ // intercepted services do not need method operation and scope
+ // annotations.
+ option (gitaly.intercepted) = true;
+
+ rpc TestMethod(ValidRequest) returns (ValidResponse);
+}
+
+service ValidService {
+ rpc TestMethod(ValidRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: ACCESSOR
+ };
+ }
+
+ rpc TestMethod2(ValidRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+
+ rpc TestMethod3(ValidRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: REPOSITORY // repo can be explicitly included
+ };
+ }
+
+ rpc TestMethod5(ValidNestedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+
+ rpc TestMethod6(ValidNestedSharedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+
+ rpc TestMethod7(ValidInnerNestedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ };
+ }
+
+ rpc TestMethod8(ValidStorageRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: STORAGE
+ };
+ }
+
+ rpc TestMethod9(ValidStorageNestedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MUTATOR
+ scope_level: STORAGE
+ };
+ }
+
+ // Intercepted methods do not need operation type annotations.
+ rpc TestMethod10(ValidStorageRequest) returns (ValidResponse) {
+ option (gitaly.intercepted_method) = true;
+ }
+
+ rpc TestMaintenance(ValidRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+ rpc TestMaintenanceWithExplicitScope(ValidRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ scope_level: REPOSITORY // repo can be explicitly included
+ };
+ }
+
+ rpc TestMaintenanceWithNestedRequest(ValidNestedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+ rpc TestMaintenanceWithNestedSharedRequest(ValidNestedSharedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+ rpc TestMutatorWithInnerNestedRequest(ValidInnerNestedRequest) returns (ValidResponse) {
+ option (gitaly.op_type) = {
+ op: MAINTENANCE
+ };
+ }
+
+}