From 197bae5c7f83ce4289fc4cd1b989cdbb23b9f785 Mon Sep 17 00:00:00 2001 From: Yaseen Alkhafaji Date: Wed, 14 Jul 2021 15:27:04 +0000 Subject: [PATCH] Add protolock dependency and tests to envoy Signed-off-by: Yaseen Alkhafaji --- bazel/external/api_protolock.BUILD | 47 ++++++ bazel/external/api_protolock_parser.BUILD | 29 ++++ bazel/repositories.bzl | 18 +++ bazel/repository_locations.bzl | 22 +++ tools/api_protolock/BUILD | 47 ++++++ tools/api_protolock/protolock_test.py | 149 ++++++++++++++++++ tools/testdata/api_protolock/BUILD | 36 +++++ .../allowed/test_add_comment_current | 10 ++ .../allowed/test_add_comment_next | 11 ++ .../allowed/test_add_enum_value_current | 14 ++ .../allowed/test_add_enum_value_next | 15 ++ .../allowed/test_add_field_current | 6 + .../api_protolock/allowed/test_add_field_next | 7 + .../allowed/test_add_option_current | 10 ++ .../allowed/test_add_option_next | 11 ++ .../test_force_breaking_change_current | 6 + .../allowed/test_force_breaking_change_next | 6 + .../test_remove_and_reserve_field_current | 7 + .../test_remove_and_reserve_field_next | 9 ++ .../test_change_field_from_oneof_current | 10 ++ .../test_change_field_from_oneof_next | 10 ++ .../breaking/test_change_field_id_current | 6 + .../breaking/test_change_field_id_next | 6 + .../breaking/test_change_field_name_current | 6 + .../breaking/test_change_field_name_next | 6 + .../test_change_field_plurality_current | 6 + .../breaking/test_change_field_plurality_next | 6 + .../test_change_field_to_oneof_current | 10 ++ .../breaking/test_change_field_to_oneof_next | 10 ++ .../breaking/test_change_field_type_current | 6 + .../breaking/test_change_field_type_next | 6 + .../breaking/test_change_package_name_current | 6 + .../breaking/test_change_package_name_next | 6 + .../breaking/test_change_pgv_field_current | 6 + .../breaking/test_change_pgv_field_next | 6 + .../breaking/test_change_pgv_message_current | 8 + .../breaking/test_change_pgv_message_next | 8 + .../breaking/test_change_pgv_oneof_current | 10 ++ .../breaking/test_change_pgv_oneof_next | 10 ++ 39 files changed, 608 insertions(+) create mode 100644 bazel/external/api_protolock.BUILD create mode 100644 bazel/external/api_protolock_parser.BUILD create mode 100644 tools/api_protolock/BUILD create mode 100644 tools/api_protolock/protolock_test.py create mode 100644 tools/testdata/api_protolock/BUILD create mode 100644 tools/testdata/api_protolock/allowed/test_add_comment_current create mode 100644 tools/testdata/api_protolock/allowed/test_add_comment_next create mode 100644 tools/testdata/api_protolock/allowed/test_add_enum_value_current create mode 100644 tools/testdata/api_protolock/allowed/test_add_enum_value_next create mode 100644 tools/testdata/api_protolock/allowed/test_add_field_current create mode 100644 tools/testdata/api_protolock/allowed/test_add_field_next create mode 100644 tools/testdata/api_protolock/allowed/test_add_option_current create mode 100644 tools/testdata/api_protolock/allowed/test_add_option_next create mode 100644 tools/testdata/api_protolock/allowed/test_force_breaking_change_current create mode 100644 tools/testdata/api_protolock/allowed/test_force_breaking_change_next create mode 100644 tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_current create mode 100644 tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_from_oneof_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_from_oneof_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_id_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_id_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_name_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_name_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_plurality_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_plurality_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_to_oneof_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_to_oneof_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_type_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_field_type_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_package_name_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_package_name_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_field_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_field_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_message_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_message_next create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_oneof_current create mode 100644 tools/testdata/api_protolock/breaking/test_change_pgv_oneof_next diff --git a/bazel/external/api_protolock.BUILD b/bazel/external/api_protolock.BUILD new file mode 100644 index 0000000000000..3be88d14ca87d --- /dev/null +++ b/bazel/external/api_protolock.BUILD @@ -0,0 +1,47 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +licenses(["notice"]) # Apache 2 + +go_binary( + name = "protolock", + srcs = [ + "cmd/protolock/main.go", + "cmd/protolock/plugins.go", + ], + visibility = ["//visibility:public"], + deps = [ + ":protolock_extend", + ":protolock_root", + ], +) + +go_library( + name = "protolock_extend", + srcs = [ + "extend/plugin.go", + ], + importpath = "github.com/nilslice/protolock/extend", + deps = [ + ":protolock_root", + ], +) + +go_library( + name = "protolock_root", + srcs = [ + "commit.go", + "config.go", + "hints.go", + "init.go", + "parse.go", + "protopath.go", + "report.go", + "rules.go", + "status.go", + "uptodate.go", + ], + importpath = "github.com/nilslice/protolock", + deps = [ + "@com_github_emicklei_proto//:proto_parsing_lib", + ], +) diff --git a/bazel/external/api_protolock_parser.BUILD b/bazel/external/api_protolock_parser.BUILD new file mode 100644 index 0000000000000..16bf195a79eb3 --- /dev/null +++ b/bazel/external/api_protolock_parser.BUILD @@ -0,0 +1,29 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "proto_parsing_lib", + srcs = [ + "comment.go", + "enum.go", + "extensions.go", + "field.go", + "group.go", + "import.go", + "message.go", + "oneof.go", + "option.go", + "package.go", + "parent_accessor.go", + "parser.go", + "proto.go", + "range.go", + "reserved.go", + "service.go", + "syntax.go", + "token.go", + "visitor.go", + "walk.go", + ], + importpath = "github.com/emicklei/proto", + visibility = ["//visibility:public"], +) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 9967b86504382..32bc2a0f7b943 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -142,6 +142,8 @@ def envoy_dependencies(skip_targets = []): _com_github_luajit_luajit() _com_github_moonjit_moonjit() _com_github_nghttp2_nghttp2() + _com_github_nilslice_protolock() + _com_github_emicklei_proto() _com_github_skyapm_cpp2sky() _com_github_nodejs_http_parser() _com_github_alibaba_hessian2_codec() @@ -505,6 +507,22 @@ def _com_github_ncopa_suexec(): actual = "@com_github_ncopa_suexec//:su-exec", ) +def _com_github_nilslice_protolock(): + external_http_archive( + name = "com_github_nilslice_protolock", + build_file = "@envoy//bazel/external:api_protolock.BUILD", + ) + native.bind( + name = "protolock", + actual = "@com_github_nilslice_protolock//:protolock", + ) + +def _com_github_emicklei_proto(): + external_http_archive( + name = "com_github_emicklei_proto", + build_file = "@envoy//bazel/external:api_protolock_parser.BUILD", + ) + def _com_google_googletest(): external_http_archive("com_google_googletest") native.bind( diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 3e7f6cfa44dac..b56f97fc660c6 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -287,6 +287,28 @@ REPOSITORY_LOCATIONS_SPEC = dict( release_date = "2020-11-23", cpe = "cpe:2.3:a:nghttp2:nghttp2:*", ), + com_github_nilslice_protolock = dict( + project_name = "protolock", + project_desc = "Track your .proto files and prevent changes to messages and services which impact API compatibility.", + project_url = "https://github.com/nilslice/protolock/", + version = "0.15.2", + sha256 = "26d0b491471866c4959a75a1418a577eab432782b9923fdf022535bb7c322374", + urls = ["https://github.com/nilslice/protolock/archive/refs/tags/v{version}.tar.gz"], + release_date = "2021-02-18", + use_category = ["api"], + strip_prefix = "protolock-{version}", + ), + com_github_emicklei_proto = dict( + project_name = "proto", + project_desc = "parser for Google ProtocolBuffers definition", + project_url = "https://github.com/emicklei/proto/", + version = "1.7.0", + sha256 = "e93272fea9e4f993b9d160440bf980d015970147907090834492771bb1c4510c", + urls = ["https://github.com/emicklei/proto/archive/refs/tags/v{version}.tar.gz"], + release_date = "2019-10-05", + use_category = ["api"], + strip_prefix = "proto-{version}", + ), io_opentracing_cpp = dict( project_name = "OpenTracing", project_desc = "Vendor-neutral APIs and instrumentation for distributed tracing", diff --git a/tools/api_protolock/BUILD b/tools/api_protolock/BUILD new file mode 100644 index 0000000000000..a2b19e4a9d5c1 --- /dev/null +++ b/tools/api_protolock/BUILD @@ -0,0 +1,47 @@ +load("@rules_python//python:defs.bzl", "py_test") + +licenses(["notice"]) # Apache 2 + +py_test( + name = "protolock_test", + srcs = ["protolock_test.py"], + data = [ + "//tools/testdata/api_protolock:allowed/test_add_comment_current", + "//tools/testdata/api_protolock:allowed/test_add_comment_next", + "//tools/testdata/api_protolock:allowed/test_add_enum_value_current", + "//tools/testdata/api_protolock:allowed/test_add_enum_value_next", + "//tools/testdata/api_protolock:allowed/test_add_field_current", + "//tools/testdata/api_protolock:allowed/test_add_field_next", + "//tools/testdata/api_protolock:allowed/test_add_option_current", + "//tools/testdata/api_protolock:allowed/test_add_option_next", + "//tools/testdata/api_protolock:allowed/test_force_breaking_change_current", + "//tools/testdata/api_protolock:allowed/test_force_breaking_change_next", + "//tools/testdata/api_protolock:allowed/test_remove_and_reserve_field_current", + "//tools/testdata/api_protolock:allowed/test_remove_and_reserve_field_next", + "//tools/testdata/api_protolock:breaking/test_change_field_from_oneof_current", + "//tools/testdata/api_protolock:breaking/test_change_field_from_oneof_next", + "//tools/testdata/api_protolock:breaking/test_change_field_id_current", + "//tools/testdata/api_protolock:breaking/test_change_field_id_next", + "//tools/testdata/api_protolock:breaking/test_change_field_name_current", + "//tools/testdata/api_protolock:breaking/test_change_field_name_next", + "//tools/testdata/api_protolock:breaking/test_change_field_plurality_current", + "//tools/testdata/api_protolock:breaking/test_change_field_plurality_next", + "//tools/testdata/api_protolock:breaking/test_change_field_to_oneof_current", + "//tools/testdata/api_protolock:breaking/test_change_field_to_oneof_next", + "//tools/testdata/api_protolock:breaking/test_change_field_type_current", + "//tools/testdata/api_protolock:breaking/test_change_field_type_next", + "//tools/testdata/api_protolock:breaking/test_change_package_name_current", + "//tools/testdata/api_protolock:breaking/test_change_package_name_next", + "//tools/testdata/api_protolock:breaking/test_change_pgv_field_current", + "//tools/testdata/api_protolock:breaking/test_change_pgv_field_next", + "//tools/testdata/api_protolock:breaking/test_change_pgv_message_current", + "//tools/testdata/api_protolock:breaking/test_change_pgv_message_next", + "//tools/testdata/api_protolock:breaking/test_change_pgv_oneof_current", + "//tools/testdata/api_protolock:breaking/test_change_pgv_oneof_next", + "@com_github_nilslice_protolock//:protolock", + ], + python_version = "PY3", + srcs_version = "PY3", + visibility = ["//visibility:public"], + deps = ["@rules_python//python/runfiles"], +) diff --git a/tools/api_protolock/protolock_test.py b/tools/api_protolock/protolock_test.py new file mode 100644 index 0000000000000..0c8c0cc6a2ad1 --- /dev/null +++ b/tools/api_protolock/protolock_test.py @@ -0,0 +1,149 @@ +import os +import unittest +import tempfile +from shutil import copyfile +import io +import subprocess +from rules_python.python.runfiles import runfiles + +DEFAULT_PROTOLOCK_ARGS = ["--plugins="] + + +class ProtolockTests(unittest.TestCase): + + def setUp(self): + # create a temporary directory to house the proto.lock file and current proto file + self.temp_dir = tempfile.TemporaryDirectory() + self.protolock_path = runfiles.Create().Rlocation( + "com_github_nilslice_protolock/protolock_/protolock") + + def tearDown(self): + self.temp_dir.cleanup() + + def run_protolock_test(self, testtype, testname, additional_args=None, expect_no_changes=False): + # there's probably a better/safer way to navigate + # but it seems like check_spelling_pedantic_test.py takes this approach as well + tests_path = os.path.join( + os.path.dirname(os.path.realpath(__file__)), "..", "testdata", "api_protolock", + testtype) + protolock_args = DEFAULT_PROTOLOCK_ARGS + [ + f"--protoroot={self.temp_dir.name}", f"--lockdir={self.temp_dir.name}" + ] + if additional_args is not None: + protolock_args.extend(additional_args) + + # check that test files exist + current = os.path.join(tests_path, f"{testname}_current") + changed = os.path.join(tests_path, f"{testname}_next") + self.assertTrue(os.path.isfile(current)) + self.assertTrue(os.path.isfile(changed)) + + # 1) copy start file into temp dir + # 2) protolock init + # 3) copy changed file into temp dir + # 4) protolock commit + # 5) check for differences (if changes are breaking, there should be none) + + target = os.path.join(self.temp_dir.name, f"{testname}.proto") + copyfile(current, target) + + # TODO: change this to use tools/run_command.py? + initial_result = subprocess.run([self.protolock_path, "init", *protolock_args], + capture_output=True) + + self.assertEqual(len(initial_result.stdout), 0) + self.assertEqual(len(initial_result.stderr), 0) + + lock_location = os.path.join(self.temp_dir.name, "proto.lock") + with open(lock_location) as f: + initial_lock = f.readlines() + + copyfile(changed, target) + + final_result = subprocess.run([self.protolock_path, "commit", *protolock_args], + capture_output=True) + with open(lock_location) as f: + post_lock = f.readlines() + + if testtype == "breaking": + self.assertGreater(len(final_result.stdout), 0) + self.assertRegex(str(final_result.stdout), r"CONFLICT") + + self.assertListEqual(initial_lock, post_lock) + elif testtype == "allowed": + self.assertEqual(len(final_result.stdout), 0) + self.assertEqual(len(final_result.stderr), 0) + + if not expect_no_changes: + self.assertGreater(len(post_lock), 0) + self.assertNotEqual(initial_lock, post_lock) + else: + raise ValueError(f"Unknown test type: {testtype}") + + +class TestBreakingChanges(ProtolockTests): + + def test_change_field_id(self): + self.run_protolock_test("breaking", self.test_change_field_id.__name__) + + def test_change_field_type(self): + self.run_protolock_test("breaking", self.test_change_field_type.__name__) + + def test_change_field_plurality(self): + self.run_protolock_test("breaking", self.test_change_field_plurality.__name__) + + def test_change_field_name(self): + self.run_protolock_test("breaking", self.test_change_field_name.__name__) + + @unittest.skip("package name detection not yet added to Protolock (simply requires plugin)") + def test_change_package_name(self): + self.run_protolock_test("breaking", self.test_change_package_name.__name__) + + @unittest.skip( + "oneof support not yet added to Protolock (requires Protolock changes AND plugin)") + def test_change_field_from_oneof(self): + self.run_protolock_test("breaking", self.test_change_field_from_oneof.__name__) + + @unittest.skip( + "oneof support not yet added to Protolock (requires Protolock changes AND plugin)") + def test_change_field_to_oneof(self): + self.run_protolock_test("breaking", self.test_change_field_to_oneof.__name__) + + @unittest.skip("PGV field support not yet added to Protolock (simply requires plugin)") + def test_change_pgv_field(self): + self.run_protolock_test("breaking", self.test_change_pgv_field.__name__) + + @unittest.skip("PGV message option support not yet added to Protolock (simply requires plugin)") + def test_change_pgv_message(self): + self.run_protolock_test("breaking", self.test_change_pgv_message.__name__) + + @unittest.skip( + "PGV oneof option support not yet added to Protolock (requires Protolock changes AND plugin)" + ) + def test_change_pgv_oneof(self): + self.run_protolock_test("breaking", self.test_change_pgv_oneof.__name__) + + +class TestAllowedChanges(ProtolockTests): + + def test_add_comment(self): + self.run_protolock_test("allowed", self.test_add_comment.__name__, expect_no_changes=True) + + def test_add_field(self): + self.run_protolock_test("allowed", self.test_add_field.__name__) + + def test_add_option(self): + self.run_protolock_test("allowed", self.test_add_option.__name__) + + def test_add_enum_value(self): + self.run_protolock_test("allowed", self.test_add_enum_value.__name__) + + def test_remove_and_reserve_field(self): + self.run_protolock_test("allowed", self.test_remove_and_reserve_field.__name__) + + def test_force_breaking_change(self): + self.run_protolock_test("allowed", self.test_force_breaking_change.__name__, ["--force"]) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/testdata/api_protolock/BUILD b/tools/testdata/api_protolock/BUILD new file mode 100644 index 0000000000000..e9e797dca8c6f --- /dev/null +++ b/tools/testdata/api_protolock/BUILD @@ -0,0 +1,36 @@ +licenses(["notice"]) # Apache 2 + +exports_files([ + "allowed/test_add_comment_current", + "allowed/test_add_enum_value_next", + "allowed/test_add_option_current", + "allowed/test_force_breaking_change_next", + "allowed/test_add_comment_next", + "allowed/test_add_field_current", + "allowed/test_add_option_next", + "allowed/test_remove_and_reserve_field_current", + "allowed/test_add_enum_value_current", + "allowed/test_add_field_next", + "allowed/test_force_breaking_change_current", + "allowed/test_remove_and_reserve_field_next", + "breaking/test_change_field_from_oneof_current", + "breaking/test_change_field_name_next", + "breaking/test_change_field_type_current", + "breaking/test_change_pgv_field_next", + "breaking/test_change_field_from_oneof_next", + "breaking/test_change_field_plurality_current", + "breaking/test_change_field_type_next", + "breaking/test_change_pgv_message_current", + "breaking/test_change_field_id_current", + "breaking/test_change_field_plurality_next", + "breaking/test_change_package_name_current", + "breaking/test_change_pgv_message_next", + "breaking/test_change_field_id_next", + "breaking/test_change_field_to_oneof_current", + "breaking/test_change_package_name_next", + "breaking/test_change_pgv_oneof_current", + "breaking/test_change_field_name_current", + "breaking/test_change_field_to_oneof_next", + "breaking/test_change_pgv_field_current", + "breaking/test_change_pgv_oneof_next", +]) diff --git a/tools/testdata/api_protolock/allowed/test_add_comment_current b/tools/testdata/api_protolock/allowed/test_add_comment_current new file mode 100644 index 0000000000000..f5bc0fc9f796a --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_comment_current @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package envoy.protolock.testdata; + +option java_package = "io.envoyproxy.envoy.protolock"; +option java_outer_classname = "EnvoyProtolock"; +option java_multiple_files = true; + +message CommonExtensionConfig { +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_comment_next b/tools/testdata/api_protolock/allowed/test_add_comment_next new file mode 100644 index 0000000000000..f630af0f1e441 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_comment_next @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package envoy.protolock.testdata; + +option java_package = "io.envoyproxy.envoy.protolock"; +option java_outer_classname = "EnvoyProtolock"; +option java_multiple_files = true; + +// Common configuration for all tap extensions. +message CommonExtensionConfig { +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_enum_value_current b/tools/testdata/api_protolock/allowed/test_add_enum_value_current new file mode 100644 index 0000000000000..a778ce6362f6d --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_enum_value_current @@ -0,0 +1,14 @@ +message SearchRequest { + string query = 1; + int32 page_number = 2; + int32 result_per_page = 3; + enum Corpus { + UNIVERSAL = 0; + WEB = 1; + IMAGES = 2; + LOCAL = 3; + NEWS = 4; + PRODUCTS = 5; + } + Corpus corpus = 4; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_enum_value_next b/tools/testdata/api_protolock/allowed/test_add_enum_value_next new file mode 100644 index 0000000000000..6943df162d859 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_enum_value_next @@ -0,0 +1,15 @@ +message SearchRequest { + string query = 1; + int32 page_number = 2; + int32 result_per_page = 3; + enum Corpus { + UNIVERSAL = 0; + WEB = 1; + IMAGES = 2; + LOCAL = 3; + NEWS = 4; + PRODUCTS = 5; + VIDEO = 6; + } + Corpus corpus = 4; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_field_current b/tools/testdata/api_protolock/allowed/test_add_field_current new file mode 100644 index 0000000000000..3bd6850b8ff4d --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_field_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 3; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_field_next b/tools/testdata/api_protolock/allowed/test_add_field_next new file mode 100644 index 0000000000000..b516016939a4b --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_field_next @@ -0,0 +1,7 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 3; + float four = 4; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_option_current b/tools/testdata/api_protolock/allowed/test_add_option_current new file mode 100644 index 0000000000000..adbd401ac0220 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_option_current @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package envoy.protolock.testdata; + +option java_package = "io.envoyproxy.envoy.protolock"; +option java_outer_classname = "EnvoyProtolock"; + +// Common configuration for all tap extensions. +message CommonExtensionConfig { +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_add_option_next b/tools/testdata/api_protolock/allowed/test_add_option_next new file mode 100644 index 0000000000000..f630af0f1e441 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_add_option_next @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package envoy.protolock.testdata; + +option java_package = "io.envoyproxy.envoy.protolock"; +option java_outer_classname = "EnvoyProtolock"; +option java_multiple_files = true; + +// Common configuration for all tap extensions. +message CommonExtensionConfig { +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_force_breaking_change_current b/tools/testdata/api_protolock/allowed/test_force_breaking_change_current new file mode 100644 index 0000000000000..3bd6850b8ff4d --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_force_breaking_change_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 3; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_force_breaking_change_next b/tools/testdata/api_protolock/allowed/test_force_breaking_change_next new file mode 100644 index 0000000000000..9f308f0e39299 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_force_breaking_change_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + float three = 3; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_current b/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_current new file mode 100644 index 0000000000000..b516016939a4b --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_current @@ -0,0 +1,7 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 3; + float four = 4; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_next b/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_next new file mode 100644 index 0000000000000..4181ec669ba93 --- /dev/null +++ b/tools/testdata/api_protolock/allowed/test_remove_and_reserve_field_next @@ -0,0 +1,9 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + reserved 4; + reserved "four"; + + string three = 3; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_current b/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_current new file mode 100644 index 0000000000000..7e91e4a8fdbcd --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_current @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + string name = 4; + SubMessage sub_message = 9; + float special = 10; + } +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_next b/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_next new file mode 100644 index 0000000000000..8c2793b75bb84 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_from_oneof_next @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + string name = 4; + SubMessage sub_message = 9; + } + float special = 10; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_id_current b/tools/testdata/api_protolock/breaking/test_change_field_id_current new file mode 100644 index 0000000000000..3bd6850b8ff4d --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_id_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 3; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_id_next b/tools/testdata/api_protolock/breaking/test_change_field_id_next new file mode 100644 index 0000000000000..92a664a0e4b3c --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_id_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string three = 42; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_name_current b/tools/testdata/api_protolock/breaking/test_change_field_name_current new file mode 100644 index 0000000000000..f925bf7f0045f --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_name_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string seventeen = 17; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_name_next b/tools/testdata/api_protolock/breaking/test_change_field_name_next new file mode 100644 index 0000000000000..c3107afc6677b --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_name_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string twenty = 17; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_plurality_current b/tools/testdata/api_protolock/breaking/test_change_field_plurality_current new file mode 100644 index 0000000000000..e6385b1f0ea84 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_plurality_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string from = 1; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_plurality_next b/tools/testdata/api_protolock/breaking/test_change_field_plurality_next new file mode 100644 index 0000000000000..290569886bc4c --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_plurality_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + repeated string from = 1; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_current b/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_current new file mode 100644 index 0000000000000..8aba457bc9878 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_current @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + string name = 4; + SubMessage sub_message = 9; + } + float loner = 10; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_next b/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_next new file mode 100644 index 0000000000000..745c5d7e81aad --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_to_oneof_next @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + string name = 4; + SubMessage sub_message = 9; + float loner = 10; + } +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_type_current b/tools/testdata/api_protolock/breaking/test_change_field_type_current new file mode 100644 index 0000000000000..35b79ea76c18b --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_type_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + float pi = 314; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_field_type_next b/tools/testdata/api_protolock/breaking/test_change_field_type_next new file mode 100644 index 0000000000000..a4105da6ec255 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_field_type_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string pi = 314; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_package_name_current b/tools/testdata/api_protolock/breaking/test_change_package_name_current new file mode 100644 index 0000000000000..b1b91b269d18c --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_package_name_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string passcode = 69; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_package_name_next b/tools/testdata/api_protolock/breaking/test_change_package_name_next new file mode 100644 index 0000000000000..4a9e7c4f76d7d --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_package_name_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package evaluatingprotos; + +message SampleMessage { + string passcode = 69; +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_field_current b/tools/testdata/api_protolock/breaking/test_change_pgv_field_current new file mode 100644 index 0000000000000..aec2f7a189d01 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_field_current @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string useremail = 1 [(validate.rules).string.email = true]; +} diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_field_next b/tools/testdata/api_protolock/breaking/test_change_pgv_field_next new file mode 100644 index 0000000000000..dacd443855d35 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_field_next @@ -0,0 +1,6 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + string useremail = 1 [(validate.rules).string.email = false]; +} diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_message_current b/tools/testdata/api_protolock/breaking/test_change_pgv_message_current new file mode 100644 index 0000000000000..108806c89e8ee --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_message_current @@ -0,0 +1,8 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + option (validate.disabled) = true; + + SampleMessage q = 543; +} diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_message_next b/tools/testdata/api_protolock/breaking/test_change_pgv_message_next new file mode 100644 index 0000000000000..f1d97b93b0578 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_message_next @@ -0,0 +1,8 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + option (validate.disabled) = false; + + SampleMessage q = 543; +} diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_current b/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_current new file mode 100644 index 0000000000000..7876e12cd33a5 --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_current @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + option (validate.required) = true; + string name = 4; + SubMessage sub_message = 9;; + } +} \ No newline at end of file diff --git a/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_next b/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_next new file mode 100644 index 0000000000000..d71f33df4961a --- /dev/null +++ b/tools/testdata/api_protolock/breaking/test_change_pgv_oneof_next @@ -0,0 +1,10 @@ +syntax = "proto3"; +package testingprotos; + +message SampleMessage { + oneof test_oneof { + option (validate.required) = false; + string name = 4; + SubMessage sub_message = 9;; + } +} \ No newline at end of file