diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2021-01-22 23:30:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-27 01:38:50 +0000 |
commit | 3b3e3f2bafca78b1acd80102f069fd4a28c2617c (patch) | |
tree | f6cb3f073ae47f57454f3382cddb378ed402106e /buildscripts/idl/tests | |
parent | acf4722f7c235c5f740151b43c0de5875be67b91 (diff) | |
download | mongo-3b3e3f2bafca78b1acd80102f069fd4a28c2617c.tar.gz |
SERVER-53205 Check for a removed field from reply type in IDL compatibility checker script
Diffstat (limited to 'buildscripts/idl/tests')
11 files changed, 463 insertions, 6 deletions
diff --git a/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl b/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl index 2645fef9e2b..8d737948d89 100644 --- a/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl +++ b/buildscripts/idl/tests/compatibility_test_fail/new/compatibility_test_fail_new.idl @@ -31,6 +31,28 @@ global: imports: - "mongo/idl/basic_types.idl" + - "../buildscripts/idl/tests/compatibility_test_fail/new/imports.idl" + +structs: + UnstableNewFieldReply: + description: "This reply contains a field that is stable in the old command but is + unstable in the new command." + fields: + unstableNewField: + type: string + unstable: true + + OptionalNewFieldReply: + description: "This reply contains a field that is required in the old command but is + optional in the new command." + fields: + optionalNewField: + type: string + optional: true + + MissingNewFieldReply: + description: "This reply contains a field that exists in the old command but is + missing in the new command." commands: invalidAPIVersionNew: @@ -70,4 +92,43 @@ commands: cpp_name: duplicateCommandOld strict: true api_version: "1" - reply_type: OkReply
\ No newline at end of file + reply_type: OkReply + + newReplyFieldUnstable: + description: "new command fails because it contains an unstable reply field that is stable + in the corresponding old command" + command_name: newReplyFieldUnstable + namespace: ignored + cpp_name: newReplyFieldUnstable + strict: true + api_version: "1" + reply_type: UnstableNewFieldReply + + newReplyFieldOptional: + description: "new command fails because it contains an optional reply field that is + required in the corresponding old command" + command_name: newReplyFieldOptional + namespace: ignored + cpp_name: newReplyFieldOptional + strict: true + api_version: "1" + reply_type: OptionalNewFieldReply + + newReplyFieldMissing: + description: "new command fails because it is missing a reply field that exists in + the corresponding old command" + command_name: newReplyFieldMissing + namespace: ignored + cpp_name: newReplyFieldMissing + strict: true + api_version: "1" + reply_type: MissingNewFieldReply + + importedReplyCommand: + description: "reply is imported and should fail" + command_name: importedReplyCommand + namespace: ignored + cpp_name: importedReplyCommand + strict: true + api_version: "1" + reply_type: ImportedUnstableNewFieldReply diff --git a/buildscripts/idl/tests/compatibility_test_fail/new/duplicate_command_fail_new.idl b/buildscripts/idl/tests/compatibility_test_fail/new/duplicate_command_fail_new.idl index b507d68fa52..a5be605a39f 100644 --- a/buildscripts/idl/tests/compatibility_test_fail/new/duplicate_command_fail_new.idl +++ b/buildscripts/idl/tests/compatibility_test_fail/new/duplicate_command_fail_new.idl @@ -41,4 +41,4 @@ commands: cpp_name: duplicateCommandNew strict: true api_version: "1" - reply_type: OkReply
\ No newline at end of file + reply_type: OkReply diff --git a/buildscripts/idl/tests/compatibility_test_fail/new/imports.idl b/buildscripts/idl/tests/compatibility_test_fail/new/imports.idl new file mode 100644 index 00000000000..493b8f9757a --- /dev/null +++ b/buildscripts/idl/tests/compatibility_test_fail/new/imports.idl @@ -0,0 +1,39 @@ +# Copyright (C) 2021-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + +structs: + ImportedUnstableNewFieldReply: + description: "This reply contains a field that is stable in the old command but is + unstable in the new command." + fields: + unstableNewField: + type: string + unstable: true
\ No newline at end of file diff --git a/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl b/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl index 5cfbf499254..968cf2fd5f2 100644 --- a/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl +++ b/buildscripts/idl/tests/compatibility_test_fail/old/compatibility_test_fail_old.idl @@ -31,6 +31,29 @@ global: imports: - "mongo/idl/basic_types.idl" + - "../buildscripts/idl/tests/compatibility_test_fail/old/imports.idl" + +structs: + UnstableNewFieldReply: + description: "This reply contains a field that is stable in the old command but is + unstable in the new command." + fields: + unstableNewField: + type: string + + OptionalNewFieldReply: + description: "This reply contains a field that is required in the old command but is + optional in the new command." + fields: + optionalNewField: + type: string + + MissingNewFieldReply: + description: "This reply contains a field that exists in the old command but is + missing in the new command." + fields: + missingNewField: + type: string commands: invalidAPIVersionOld: @@ -60,4 +83,43 @@ commands: cpp_name: removedCommand strict: true api_version: "1" - reply_type: OkReply
\ No newline at end of file + reply_type: OkReply + + newReplyFieldUnstable: + description: "new command fails because it contains an unstable reply field that is stable + in the corresponding old command" + command_name: newReplyFieldUnstable + namespace: ignored + cpp_name: newReplyFieldUnstable + strict: true + api_version: "1" + reply_type: UnstableNewFieldReply + + newReplyFieldOptional: + description: "new command fails because it contains an optional reply field that is + required in the corresponding old command" + command_name: newReplyFieldOptional + namespace: ignored + cpp_name: newReplyFieldOptional + strict: true + api_version: "1" + reply_type: OptionalNewFieldReply + + newReplyFieldMissing: + description: "new command fails because it is missing a reply field that exists in + the corresponding old command" + command_name: newReplyFieldMissing + namespace: ignored + cpp_name: newReplyFieldMissing + strict: true + api_version: "1" + reply_type: MissingNewFieldReply + + importedReplyCommand: + description: "reply is imported and should fail" + command_name: importedReplyCommand + namespace: ignored + cpp_name: importedReplyCommand + strict: true + api_version: "1" + reply_type: ImportedUnstableNewFieldReply diff --git a/buildscripts/idl/tests/compatibility_test_fail/old/duplicate_command_fail_old.idl b/buildscripts/idl/tests/compatibility_test_fail/old/duplicate_command_fail_old.idl index 82772b51df7..44e3c4fed92 100644 --- a/buildscripts/idl/tests/compatibility_test_fail/old/duplicate_command_fail_old.idl +++ b/buildscripts/idl/tests/compatibility_test_fail/old/duplicate_command_fail_old.idl @@ -41,4 +41,4 @@ commands: cpp_name: duplicateCommandOld strict: true api_version: "1" - reply_type: OkReply
\ No newline at end of file + reply_type: OkReply diff --git a/buildscripts/idl/tests/compatibility_test_fail/old/imports.idl b/buildscripts/idl/tests/compatibility_test_fail/old/imports.idl new file mode 100644 index 00000000000..c663eb8b4b4 --- /dev/null +++ b/buildscripts/idl/tests/compatibility_test_fail/old/imports.idl @@ -0,0 +1,38 @@ +# Copyright (C) 2021-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + +structs: + ImportedUnstableNewFieldReply: + description: "This reply contains a field that is stable in the old command but is + unstable in the new command." + fields: + unstableNewField: + type: string
\ No newline at end of file diff --git a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl index dcb3ff6fb95..5e09b67b694 100644 --- a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl +++ b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl @@ -31,6 +31,37 @@ global: imports: - "mongo/idl/basic_types.idl" + - "../buildscripts/idl/tests/compatibility_test_pass/new/imports.idl" + +structs: + StableNewFieldReply: + description: "This reply contains a field that is unstable in the old command but is + stable in the new command." + fields: + stableNewField: + type: string + + RequiredNewFieldReply: + description: "This reply contains a field that is optional in the old command but is + unstable in the new command." + fields: + requiredNewField: + type: string + + AddedNewFieldReply: + description: "This reply contains a field that is added in the new command." + fields: + addedNewField: + type: string + + UnstableOldFieldReply: + description: "This reply contains a field that is unstable in the old command and is + unstable and optional in the new command." + fields: + unstableOldField: + type: string + unstable: true + optional: true commands: testCommand: @@ -41,3 +72,51 @@ commands: strict: true api_version: "1" reply_type: OkReply + + newReplyFieldStable: + description: "new command contains a stable reply field that is unstable + in the corresponding old command and still passes" + command_name: newReplyFieldStable + namespace: ignored + cpp_name: newReplyFieldStable + strict: true + api_version: "1" + reply_type: StableNewFieldReply + + newReplyFieldRequired: + description: "new command contains a required reply field that is optional + in the corresponding old command and still passes" + command_name: newReplyFieldRequired + namespace: ignored + cpp_name: newReplyFieldRequired + strict: true + api_version: "1" + reply_type: RequiredNewFieldReply + + newReplyFieldAdded: + description: "new command adds a new reply field and still passes" + command_name: newReplyFieldAdded + namespace: ignored + cpp_name: newReplyFieldAdded + strict: true + api_version: "1" + reply_type: AddedNewFieldReply + + oldReplyFieldUnstable: + description: "old reply field is unstable so new commmand passes even if its new reply + field is unstable" + command_name: oldReplyFieldUnstable + namespace: ignored + cpp_name: oldReplyFieldUnstable + strict: true + api_version: "1" + reply_type: UnstableOldFieldReply + + importedReplyCommand: + description: "reply is imported and should pass" + command_name: importedReplyCommand + namespace: ignored + cpp_name: importedReplyCommand + strict: true + api_version: "1" + reply_type: ImportedStableNewFieldReply diff --git a/buildscripts/idl/tests/compatibility_test_pass/new/imports.idl b/buildscripts/idl/tests/compatibility_test_pass/new/imports.idl new file mode 100644 index 00000000000..2cd901f7d60 --- /dev/null +++ b/buildscripts/idl/tests/compatibility_test_pass/new/imports.idl @@ -0,0 +1,38 @@ +# Copyright (C) 2021-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + +structs: + ImportedStableNewFieldReply: + description: "This reply contains a field that is unstable in the old command but is + stable in the new command." + fields: + stableNewField: + type: string
\ No newline at end of file diff --git a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl index 54c7c6502ae..72bfc6adcfc 100644 --- a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl +++ b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl @@ -31,6 +31,35 @@ global: imports: - "mongo/idl/basic_types.idl" + - "../buildscripts/idl/tests/compatibility_test_pass/old/imports.idl" + +structs: + StableNewFieldReply: + description: "This reply contains a field that is unstable in the old command but is + stable in the new command." + fields: + stableNewField: + type: string + unstable: true + + RequiredNewFieldReply: + description: "This reply contains a field that is optional in the old command but is + unstable in the new command." + fields: + requiredNewField: + type: string + optional: true + + AddedNewFieldReply: + description: "This reply contains a field that is added in the new command." + + UnstableOldFieldReply: + description: "This reply contains a field that is unstable in the old command and is + unstable and optional in the new command." + fields: + unstableOldField: + type: string + unstable: true commands: testCommand: @@ -50,3 +79,51 @@ commands: strict: true api_version: "" reply_type: OkReply + + newReplyFieldStable: + description: "new command contains a stable reply field that is unstable + in the corresponding old command and still passes" + command_name: newReplyFieldStable + namespace: ignored + cpp_name: newReplyFieldStable + strict: true + api_version: "1" + reply_type: StableNewFieldReply + + newReplyFieldRequired: + description: "new command contains a required reply field that is optional + in the corresponding old command and still passes" + command_name: newReplyFieldRequired + namespace: ignored + cpp_name: newReplyFieldRequired + strict: true + api_version: "1" + reply_type: RequiredNewFieldReply + + newReplyFieldAdded: + description: "new command adds a new reply field and still passes" + command_name: newReplyFieldAdded + namespace: ignored + cpp_name: newReplyFieldAdded + strict: true + api_version: "1" + reply_type: AddedNewFieldReply + + oldReplyFieldUnstable: + description: "old reply field is unstable so new commmand passes even if its new reply + field is unstable" + command_name: oldReplyFieldUnstable + namespace: ignored + cpp_name: oldReplyFieldUnstable + strict: true + api_version: "1" + reply_type: UnstableOldFieldReply + + importedReplyCommand: + description: "reply is imported" + command_name: importedReplyCommand + namespace: ignored + cpp_name: importedReplyCommand + strict: true + api_version: "1" + reply_type: ImportedStableNewFieldReply diff --git a/buildscripts/idl/tests/compatibility_test_pass/old/imports.idl b/buildscripts/idl/tests/compatibility_test_pass/old/imports.idl new file mode 100644 index 00000000000..6710dc5826f --- /dev/null +++ b/buildscripts/idl/tests/compatibility_test_pass/old/imports.idl @@ -0,0 +1,39 @@ +# Copyright (C) 2021-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + +structs: + ImportedStableNewFieldReply: + description: "This reply contains a field that is unstable in the old command but is + stable in the new command." + fields: + stableNewField: + type: string + unstable: true
\ No newline at end of file diff --git a/buildscripts/idl/tests/test_compatibility.py b/buildscripts/idl/tests/test_compatibility.py index ca4ba8c976a..d2b25332b1d 100644 --- a/buildscripts/idl/tests/test_compatibility.py +++ b/buildscripts/idl/tests/test_compatibility.py @@ -61,7 +61,7 @@ class TestIDLCompatibilityChecker(unittest.TestCase): path.join(dir_path, "compatibility_test_fail/new"), ["src"]) self.assertTrue(error_collection.has_errors()) - self.assertTrue(error_collection.count() == 5) + self.assertTrue(error_collection.count() == 9) invalid_api_version_new_error = error_collection.get_error_by_command_name( "invalidAPIVersionNew") @@ -91,11 +91,35 @@ class TestIDLCompatibilityChecker(unittest.TestCase): idl_compatibility_errors.ERROR_ID_DUPLICATE_COMMAND_NAME) self.assertRegex(str(duplicate_command_old_error), "duplicateCommandOld") - removed_command_error = error_collection.get_error( + removed_command_error = error_collection.get_error_by_error_id( idl_compatibility_errors.ERROR_ID_REMOVED_COMMAND) self.assertIsNotNone(removed_command_error) self.assertRegex(str(removed_command_error), "removedCommand") + new_reply_field_unstable_error = error_collection.get_error_by_command_name( + "newReplyFieldUnstable") + self.assertIsNotNone(new_reply_field_unstable_error) + self.assertTrue(new_reply_field_unstable_error.error_id == + idl_compatibility_errors.ERROR_ID_NEW_REPLY_FIELD_UNSTABLE) + self.assertRegex(str(new_reply_field_unstable_error), "newReplyFieldUnstable") + + new_reply_field_optional_error = error_collection.get_error_by_error_id( + idl_compatibility_errors.ERROR_ID_NEW_REPLY_FIELD_OPTIONAL) + self.assertIsNotNone(new_reply_field_optional_error) + self.assertRegex(str(new_reply_field_optional_error), "newReplyFieldOptional") + + new_reply_field_missing_error = error_collection.get_error_by_error_id( + idl_compatibility_errors.ERROR_ID_NEW_REPLY_FIELD_MISSING) + self.assertIsNotNone(new_reply_field_missing_error) + self.assertRegex(str(new_reply_field_missing_error), "newReplyFieldMissing") + + imported_reply_field_unstable_error = error_collection.get_error_by_command_name( + "importedReplyCommand") + self.assertIsNotNone(imported_reply_field_unstable_error) + self.assertTrue(imported_reply_field_unstable_error.error_id == + idl_compatibility_errors.ERROR_ID_NEW_REPLY_FIELD_UNSTABLE) + self.assertRegex(str(imported_reply_field_unstable_error), "importedReplyCommand") + if __name__ == '__main__': unittest.main() |