@@ -263,4 +263,85 @@ test.describe('Vat Manager', () => {
263263 minimalClusterConfig . vats . main . parameters . name ,
264264 ) ;
265265 } ) ;
266+
267+ test ( 'should collect garbage' , async ( ) => {
268+ await popupPage . click ( 'button:text("Database Inspector")' ) ;
269+ await expect ( messageOutput ) . toContainText (
270+ '{"key":"vats.terminated","value":"[]"}' ,
271+ ) ;
272+ const v3Values = [
273+ '{"key":"e.nextPromiseId.v3","value":"2"}' ,
274+ '{"key":"e.nextObjectId.v3","value":"1"}' ,
275+ '{"key":"ko3.owner","value":"v3"}' ,
276+ '{"key":"v3.c.ko3","value":"R o+0"}' ,
277+ '{"key":"v3.c.o+0","value":"ko3"}' ,
278+ '{"key":"v3.c.kp3","value":"R p-1"}' ,
279+ '{"key":"v3.c.p-1","value":"kp3"}' ,
280+ ] ;
281+ const v1ko3Values = [
282+ '{"key":"v1.c.ko3","value":"R o-2"}' ,
283+ '{"key":"v1.c.o-2","value":"ko3"}' ,
284+ '{"key":"ko3.refCount","value":"2,2"}' ,
285+ '{"key":"kp3.state","value":"fulfilled"}' ,
286+ '{"key":"kp3.value","value"' ,
287+ ] ;
288+ await expect ( messageOutput ) . toContainText (
289+ '{"key":"kp3.refCount","value":"2"}' ,
290+ ) ;
291+ await expect ( messageOutput ) . toContainText ( '{"key":"vatConfig.v3","value"' ) ;
292+ for ( const value of v3Values ) {
293+ await expect ( messageOutput ) . toContainText ( value ) ;
294+ }
295+ for ( const value of v1ko3Values ) {
296+ await expect ( messageOutput ) . toContainText ( value ) ;
297+ }
298+ await popupPage . click ( 'button:text("Vat Manager")' ) ;
299+ await popupPage . locator ( 'td button:text("Terminate")' ) . last ( ) . click ( ) ;
300+ await expect ( messageOutput ) . toContainText ( 'Terminated vat "v3"' ) ;
301+ await popupPage . locator ( '[data-testid="clear-logs-button"]' ) . click ( ) ;
302+ await expect ( messageOutput ) . toContainText ( '' ) ;
303+ await popupPage . click ( 'button:text("Database Inspector")' ) ;
304+ await expect ( messageOutput ) . toContainText (
305+ '{"key":"vats.terminated","value":"[\\"v3\\"]"}' ,
306+ ) ;
307+ await expect ( messageOutput ) . not . toContainText (
308+ '{"key":"vatConfig.v3","value"' ,
309+ ) ;
310+ for ( const value of v3Values ) {
311+ await expect ( messageOutput ) . toContainText ( value ) ;
312+ }
313+ await popupPage . click ( 'button:text("Vat Manager")' ) ;
314+ await popupPage . click ( 'button:text("Collect Garbage")' ) ;
315+ await expect ( messageOutput ) . toContainText ( 'Garbage collected' ) ;
316+ await popupPage . locator ( '[data-testid="clear-logs-button"]' ) . click ( ) ;
317+ await expect ( messageOutput ) . toContainText ( '' ) ;
318+ await popupPage . click ( 'button:text("Database Inspector")' ) ;
319+ // v3 is gone
320+ for ( const value of v3Values ) {
321+ await expect ( messageOutput ) . not . toContainText ( value ) ;
322+ }
323+ // ko3 reference still exists for v1
324+ for ( const value of v1ko3Values ) {
325+ await expect ( messageOutput ) . toContainText ( value ) ;
326+ }
327+ // kp3 reference dropped to 1
328+ await expect ( messageOutput ) . toContainText (
329+ '{"key":"kp3.refCount","value":"1"}' ,
330+ ) ;
331+ await popupPage . click ( 'button:text("Vat Manager")' ) ;
332+ // delete v1
333+ await popupPage . locator ( 'td button:text("Terminate")' ) . first ( ) . click ( ) ;
334+ await expect ( messageOutput ) . toContainText ( 'Terminated vat "v1"' ) ;
335+ await popupPage . click ( 'button:text("Collect Garbage")' ) ;
336+ await expect ( messageOutput ) . toContainText ( 'Garbage collected' ) ;
337+ await popupPage . locator ( '[data-testid="clear-logs-button"]' ) . click ( ) ;
338+ await expect ( messageOutput ) . toContainText ( '' ) ;
339+ await popupPage . click ( 'button:text("Database Inspector")' ) ;
340+ await expect ( messageOutput ) . toContainText (
341+ '{"key":"vats.terminated","value":"[]"}' ,
342+ ) ;
343+ for ( const value of v1ko3Values ) {
344+ await expect ( messageOutput ) . not . toContainText ( value ) ;
345+ }
346+ } ) ;
266347} ) ;
0 commit comments