Skip to content

Commit df7d545

Browse files
authored
Update generated files for Evergreen config and future functions (#1068)
* Update future-functions generator * Ensure collections are serialized in block style
1 parent cad30e9 commit df7d545

File tree

11 files changed

+72
-22
lines changed

11 files changed

+72
-22
lines changed

build/evergreen_config_generator/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def represent_config_object(self, obj):
7272

7373

7474
def yaml_dump(obj):
75-
return yaml.dump(obj, Dumper=_Dumper)
75+
return yaml.dump(obj, Dumper=_Dumper, default_flow_style=False)
7676

7777

7878
def generate(config, path):
@@ -90,4 +90,4 @@ def generate(config, path):
9090
#
9191
####################################
9292
''')
93-
f.write(yaml_dump(config))
93+
f.write(yaml_dump(config))

build/generate-future-functions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
from collections import namedtuple
3333
from os.path import basename, dirname, join as joinpath, normpath
3434

35-
from jinja2 import Environment, FileSystemLoader # Please "pip install jinja2".
35+
# Please "pip install jinja2".
36+
from jinja2 import Environment, FileSystemLoader
3637

3738
this_dir = dirname(__file__)
3839
template_dir = joinpath(this_dir, 'future_function_templates')
@@ -60,6 +61,7 @@
6061

6162
# Const fundamental.
6263
typedef("const_char_ptr", "const char *"),
64+
typedef("bool_ptr", "bool *"),
6365

6466
# libbson.
6567
typedef("bson_error_ptr", "bson_error_t *"),
@@ -98,7 +100,8 @@
98100
"const mongoc_find_and_modify_opts_t *"),
99101
typedef("const_mongoc_iovec_ptr", "const mongoc_iovec_t *"),
100102
typedef("const_mongoc_read_prefs_ptr", "const mongoc_read_prefs_t *"),
101-
typedef("const_mongoc_write_concern_ptr", "const mongoc_write_concern_t *"),
103+
typedef("const_mongoc_write_concern_ptr",
104+
"const mongoc_write_concern_t *"),
102105
]
103106

104107
type_list = [T.name for T in typedef_list]
@@ -451,6 +454,7 @@
451454
[param("mongoc_topology_ptr", "topology"),
452455
param("mongoc_ss_optype_t", "optype"),
453456
param("const_mongoc_read_prefs_ptr", "read_prefs"),
457+
param("bool_ptr", "must_use_primary"),
454458
param("bson_error_ptr", "error")]),
455459

456460
future_function("mongoc_gridfs_ptr",

src/libmongoc/tests/mock_server/future-functions.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,8 @@ BSON_THREAD_FUN (background_mongoc_topology_select, data)
10341034
future_value_get_mongoc_topology_ptr (future_get_param (future, 0)),
10351035
future_value_get_mongoc_ss_optype_t (future_get_param (future, 1)),
10361036
future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
1037-
NULL /* chosen read mode, unused here */,
1038-
future_value_get_bson_error_ptr (future_get_param (future, 3))
1037+
future_value_get_bool_ptr (future_get_param (future, 3)),
1038+
future_value_get_bson_error_ptr (future_get_param (future, 4))
10391039
));
10401040

10411041
future_resolve (future, return_value);
@@ -2563,10 +2563,11 @@ future_topology_select (
25632563
mongoc_topology_ptr topology,
25642564
mongoc_ss_optype_t optype,
25652565
const_mongoc_read_prefs_ptr read_prefs,
2566+
bool_ptr must_use_primary,
25662567
bson_error_ptr error)
25672568
{
25682569
future_t *future = future_new (future_value_mongoc_server_description_ptr_type,
2569-
4);
2570+
5);
25702571

25712572
future_value_set_mongoc_topology_ptr (
25722573
future_get_param (future, 0), topology);
@@ -2577,8 +2578,11 @@ future_topology_select (
25772578
future_value_set_const_mongoc_read_prefs_ptr (
25782579
future_get_param (future, 2), read_prefs);
25792580

2581+
future_value_set_bool_ptr (
2582+
future_get_param (future, 3), must_use_primary);
2583+
25802584
future_value_set_bson_error_ptr (
2581-
future_get_param (future, 3), error);
2585+
future_get_param (future, 4), error);
25822586

25832587
future_start (future, background_mongoc_topology_select);
25842588
return future;

src/libmongoc/tests/mock_server/future-functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ future_topology_select (
490490
mongoc_topology_ptr topology,
491491
mongoc_ss_optype_t optype,
492492
const_mongoc_read_prefs_ptr read_prefs,
493+
bool_ptr must_use_primary,
493494
bson_error_ptr error
494495
);
495496

src/libmongoc/tests/mock_server/future-value.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ future_value_get_const_char_ptr (future_value_t *future_value)
168168
return future_value->value.const_char_ptr_value;
169169
}
170170

171+
void
172+
future_value_set_bool_ptr (future_value_t *future_value, bool_ptr value)
173+
{
174+
future_value->type = future_value_bool_ptr_type;
175+
future_value->value.bool_ptr_value = value;
176+
}
177+
178+
bool_ptr
179+
future_value_get_bool_ptr (future_value_t *future_value)
180+
{
181+
BSON_ASSERT (future_value->type == future_value_bool_ptr_type);
182+
return future_value->value.bool_ptr_value;
183+
}
184+
171185
void
172186
future_value_set_bson_error_ptr (future_value_t *future_value, bson_error_ptr value)
173187
{

src/libmongoc/tests/mock_server/future-value.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef char * char_ptr;
2222
typedef char ** char_ptr_ptr;
2323
typedef void * void_ptr;
2424
typedef const char * const_char_ptr;
25+
typedef bool * bool_ptr;
2526
typedef bson_error_t * bson_error_ptr;
2627
typedef bson_t * bson_ptr;
2728
typedef const bson_t * const_bson_ptr;
@@ -61,6 +62,7 @@ typedef enum {
6162
future_value_uint32_t_type,
6263
future_value_void_ptr_type,
6364
future_value_const_char_ptr_type,
65+
future_value_bool_ptr_type,
6466
future_value_bson_error_ptr_type,
6567
future_value_bson_ptr_type,
6668
future_value_const_bson_ptr_type,
@@ -109,6 +111,7 @@ typedef struct _future_value_t
109111
uint32_t uint32_t_value;
110112
void_ptr void_ptr_value;
111113
const_char_ptr const_char_ptr_value;
114+
bool_ptr bool_ptr_value;
112115
bson_error_ptr bson_error_ptr_value;
113116
bson_ptr bson_ptr_value;
114117
const_bson_ptr const_bson_ptr_value;
@@ -245,6 +248,15 @@ const_char_ptr
245248
future_value_get_const_char_ptr (
246249
future_value_t *future_value);
247250

251+
void
252+
future_value_set_bool_ptr(
253+
future_value_t *future_value,
254+
bool_ptr value);
255+
256+
bool_ptr
257+
future_value_get_bool_ptr (
258+
future_value_t *future_value);
259+
248260
void
249261
future_value_set_bson_error_ptr(
250262
future_value_t *future_value,

src/libmongoc/tests/mock_server/future.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,18 @@ future_get_const_char_ptr (future_t *future)
145145
abort ();
146146
}
147147

148+
bool_ptr
149+
future_get_bool_ptr (future_t *future)
150+
{
151+
if (future_wait (future)) {
152+
return future_value_get_bool_ptr (&future->return_value);
153+
}
154+
155+
fprintf (stderr, "%s timed out\n", BSON_FUNC);
156+
fflush (stderr);
157+
abort ();
158+
}
159+
148160
bson_error_ptr
149161
future_get_bson_error_ptr (future_t *future)
150162
{

src/libmongoc/tests/mock_server/future.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ future_get_void_ptr (future_t *future);
7272
const_char_ptr
7373
future_get_const_char_ptr (future_t *future);
7474

75+
bool_ptr
76+
future_get_bool_ptr (future_t *future);
77+
7578
bson_error_ptr
7679
future_get_bson_error_ptr (future_t *future);
7780

src/libmongoc/tests/test-mongoc-topology-reconcile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ _test_topology_reconcile_sharded (bool pooled)
246246

247247
primary_read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY);
248248
future = future_topology_select (
249-
client->topology, MONGOC_SS_READ, primary_read_prefs, &error);
249+
client->topology, MONGOC_SS_READ, primary_read_prefs, NULL, &error);
250250

251251
/* mongos */
252252
request = mock_server_receives_any_hello (mongos);

src/libmongoc/tests/test-mongoc-topology-scanner.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ test_topology_scanner_discovery (void)
185185
secondary_pref = mongoc_read_prefs_new (MONGOC_READ_SECONDARY_PREFERRED);
186186

187187
future = future_topology_select (
188-
client->topology, MONGOC_SS_READ, secondary_pref, &error);
188+
client->topology, MONGOC_SS_READ, secondary_pref, NULL, &error);
189189

190190
/* a single scan discovers *and* checks the secondary */
191191
request = mock_server_receives_any_hello (primary);
@@ -265,7 +265,7 @@ test_topology_scanner_oscillate (void)
265265

266266
BSON_ASSERT (!scanner->async->ncmds);
267267
future = future_topology_select (
268-
client->topology, MONGOC_SS_READ, primary_pref, &error);
268+
client->topology, MONGOC_SS_READ, primary_pref, NULL, &error);
269269

270270
/* a single scan discovers servers 0 and 1 */
271271
request = mock_server_receives_any_hello (server0);

0 commit comments

Comments
 (0)