@@ -171,6 +171,7 @@ TEST_P(TestVm, AlwaysApplyCanary) {
171
171
// For each create Wasm, canary should be done.
172
172
EXPECT_EQ (canary_count, 1 );
173
173
174
+ bool first = true ;
174
175
std::unordered_set<std::shared_ptr<WasmHandleBase>> reference_holder;
175
176
176
177
for (const auto &root_id : root_ids) {
@@ -195,6 +196,13 @@ TEST_P(TestVm, AlwaysApplyCanary) {
195
196
auto wasm_handle_comp =
196
197
createWasm (vm_key, source, plugin_comp, wasm_handle_factory_comp,
197
198
wasm_handle_clone_factory_for_canary, false );
199
+ // Validate that canarying is cached for the first variant.
200
+ if (first) {
201
+ first = false ;
202
+ EXPECT_EQ (canary_count, 0 );
203
+ continue ;
204
+ }
205
+
198
206
// For each create Wasm, canary should be done.
199
207
EXPECT_EQ (canary_count, 1 );
200
208
@@ -233,30 +241,6 @@ TEST_P(TestVm, AlwaysApplyCanary) {
233
241
}
234
242
}
235
243
}
236
-
237
- {
238
- // Validate that canarying is cached
239
- canary_count = 0 ;
240
- TestContext::resetGlobalLog ();
241
- const auto &root_id = root_ids[0 ];
242
- const auto &vm_id = vm_ids[0 ];
243
- const auto &vm_config = vm_configs[0 ];
244
- const auto &plugin_key = plugin_keys[0 ];
245
- const auto &plugin_config = plugin_configs[0 ];
246
- WasmHandleFactory wasm_handle_factory_comp =
247
- [this , vm_id, vm_config](std::string_view vm_key) -> std::shared_ptr<WasmHandleBase> {
248
- auto base_wasm = std::make_shared<TestWasm>(
249
- newVm (), std::unordered_map<std::string, std::string>(), vm_id, vm_config, vm_key);
250
- return std::make_shared<WasmHandleBase>(base_wasm);
251
- };
252
- const auto plugin_comp = std::make_shared<PluginBase>(plugin_name, root_id, vm_id, engine_,
253
- plugin_config, fail_open, plugin_key);
254
- const auto vm_key = makeVmKey (vm_id, vm_config, " common_code" );
255
- // Create a base Wasm by createWasm.
256
- auto wasm_handle_comp = createWasm (vm_key, source, plugin_comp, wasm_handle_factory_comp,
257
- wasm_handle_clone_factory_for_canary, false );
258
- EXPECT_EQ (canary_count, 0 );
259
- }
260
244
}
261
245
262
246
} // namespace proxy_wasm
0 commit comments