40
40
from pymongo import MongoClient
41
41
42
42
# Permit imports from "buildscripts".
43
- sys .path .append (os .path .normpath (os .path .join (os .path .abspath (__file__ ), ' ../../..' )))
43
+ sys .path .append (os .path .normpath (os .path .join (os .path .abspath (__file__ ), " ../../.." )))
44
44
45
45
# pylint: disable=wrong-import-position
46
46
from idl import syntax
53
53
from buildscripts .resmokelib .testing .fixtures .standalone import MongoDFixture
54
54
# pylint: enable=wrong-import-position
55
55
56
- LOGGER_NAME = ' check-idl-definitions'
56
+ LOGGER_NAME = " check-idl-definitions"
57
57
LOGGER = logging .getLogger (LOGGER_NAME )
58
58
59
59
@@ -68,8 +68,9 @@ def is_test_or_third_party_idl(idl_path: str) -> bool:
68
68
return False
69
69
70
70
71
- def get_command_definitions (api_version : str , directory : str ,
72
- import_directories : List [str ]) -> Dict [str , syntax .Command ]:
71
+ def get_command_definitions (
72
+ api_version : str , directory : str , import_directories : List [str ]
73
+ ) -> Dict [str , syntax .Command ]:
73
74
"""Get parsed IDL definitions of commands in a given API version."""
74
75
75
76
LOGGER .info ("Searching for command definitions in %s" , directory )
@@ -109,22 +110,30 @@ def list_commands_for_api(api_version: str, mongod_or_mongos: str, install_dir:
109
110
logger = loggers .new_fixture_logger ("ShardedClusterFixture" , 0 )
110
111
logger .parent = LOGGER
111
112
fixture = fixturelib .make_fixture (
112
- "ShardedClusterFixture" , logger , 0 , dbpath_prefix = dbpath .name ,
113
- mongos_executable = mongos_executable , mongod_executable = mongod_executable ,
114
- mongod_options = {"set_parameters" : {}})
113
+ "ShardedClusterFixture" ,
114
+ logger ,
115
+ 0 ,
116
+ dbpath_prefix = dbpath .name ,
117
+ mongos_executable = mongos_executable ,
118
+ mongod_executable = mongod_executable ,
119
+ mongod_options = {"set_parameters" : {}},
120
+ )
115
121
116
122
fixture .setup ()
117
123
fixture .await_ready ()
118
124
119
125
try :
120
126
client = MongoClient (fixture .get_driver_connection_url ()) # type: MongoClient
121
- reply = client .admin .command (' listCommands' ) # type: Mapping[str, Any]
127
+ reply = client .admin .command (" listCommands" ) # type: Mapping[str, Any]
122
128
commands = {
123
- name
124
- for name , info in reply ['commands' ].items () if api_version in info ['apiVersions' ]
129
+ name for name , info in reply ["commands" ].items () if api_version in info ["apiVersions" ]
125
130
}
126
- logging .info ("Found %s commands in API Version %s on %s" , len (commands ), api_version ,
127
- mongod_or_mongos )
131
+ logging .info (
132
+ "Found %s commands in API Version %s on %s" ,
133
+ len (commands ),
134
+ api_version ,
135
+ mongod_or_mongos ,
136
+ )
128
137
return commands
129
138
finally :
130
139
fixture .teardown ()
@@ -144,13 +153,16 @@ def assert_command_sets_equal(api_version: str, command_sets: Dict[str, Set[str]
144
153
for other_name , other_commands in it :
145
154
if commands != other_commands :
146
155
if commands - other_commands :
147
- LOGGER .error ("%s has commands not in %s: %s" , name , other_name ,
148
- commands - other_commands )
156
+ LOGGER .error (
157
+ "%s has commands not in %s: %s" , name , other_name , commands - other_commands
158
+ )
149
159
if other_commands - commands :
150
- LOGGER .error ("%s has commands not in %s: %s" , other_name , name ,
151
- other_commands - commands )
160
+ LOGGER .error (
161
+ "%s has commands not in %s: %s" , other_name , name , other_commands - commands
162
+ )
152
163
raise AssertionError (
153
- f"{ name } and { other_name } have different commands in API Version { api_version } " )
164
+ f"{ name } and { other_name } have different commands in API Version { api_version } "
165
+ )
154
166
155
167
156
168
def remove_skipped_commands (command_sets : Dict [str , Set [str ]]):
@@ -173,10 +185,15 @@ def remove_skipped_commands(command_sets: Dict[str, Set[str]]):
173
185
def main ():
174
186
"""Run the script."""
175
187
arg_parser = argparse .ArgumentParser (description = __doc__ )
176
- arg_parser .add_argument ("--include" , type = str , action = "append" ,
177
- help = "Directory to search for IDL import files" )
178
- arg_parser .add_argument ("--install-dir" , dest = "install_dir" , required = True ,
179
- help = "Directory to search for MongoDB binaries" )
188
+ arg_parser .add_argument (
189
+ "--include" , type = str , action = "append" , help = "Directory to search for IDL import files"
190
+ )
191
+ arg_parser .add_argument (
192
+ "--install-dir" ,
193
+ dest = "install_dir" ,
194
+ required = True ,
195
+ help = "Directory to search for MongoDB binaries" ,
196
+ )
180
197
arg_parser .add_argument ("-v" , "--verbose" , action = "count" , help = "Enable verbose logging" )
181
198
arg_parser .add_argument ("api_version" , metavar = "API_VERSION" , help = "API Version to check" )
182
199
args = arg_parser .parse_args ()
0 commit comments