2022-05-09 10:03:19 -04:00
|
|
|
-- Copyright (c) HashiCorp, Inc.
|
|
|
|
|
-- SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2022-05-09 10:03:19 -04:00
|
|
|
begin;
|
2023-05-25 15:19:42 +00:00
|
|
|
select plan(12);
|
2022-05-09 10:03:19 -04:00
|
|
|
|
|
|
|
|
-- Ensure session state table is populated
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
|
|
|
|
|
2023-05-25 15:19:42 +00:00
|
|
|
select is(count(*), 3::bigint) from session where target_id = 't_________cb';
|
2023-05-16 14:07:35 -07:00
|
|
|
select is(count(*), 3::bigint) from session where target_id = 'tssh______cb';
|
2023-05-25 15:19:42 +00:00
|
|
|
|
2022-05-09 10:03:19 -04:00
|
|
|
-- Delete target, expect no errors
|
|
|
|
|
delete from target where public_id='t_________cb';
|
|
|
|
|
select is(count(*), 0::bigint) from target where public_id='t_________cb';
|
|
|
|
|
|
2023-05-25 15:19:42 +00:00
|
|
|
delete from target where public_id='tssh______cb';
|
|
|
|
|
select is(count(*), 0::bigint) from target where public_id='tssh______cb';
|
|
|
|
|
|
2022-05-09 10:03:19 -04:00
|
|
|
-- Ensure we no longer have sessions associated with this target
|
|
|
|
|
select is(count(*), 0::bigint) from session where target_id = 't_________cb';
|
2023-05-25 15:19:42 +00:00
|
|
|
select is(count(*), 0::bigint) from session where target_id = 'tssh______cb';
|
2022-05-09 10:03:19 -04:00
|
|
|
|
|
|
|
|
-- Ensure sessions that were pending or active are now in canceling state
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
|
|
|
|
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
|
|
|
|
|
|
|
|
|
select * from finish();
|
2023-05-25 15:19:42 +00:00
|
|
|
rollback;
|