Merge remote-tracking branch 'origin/main' into llb-byow

This commit is contained in:
Jeff Mitchell committed 2022-06-10 19:05:27 -04:00
commit 5d3facf561
56 files changed
+1455 -320

No files matched your search

+3
View File
@@ -95,6 +95,9 @@ func Open(dbType DbType, connectionUrl string, opt ...Option) (*DB, error) {
wrappedOpts = append(wrappedOpts, dbw.WithLogger(opts.withGormFormatter))
}
if opts.withMaxOpenConnections > 0 {
if opts.withMaxOpenConnections < 5 {
return nil, fmt.Errorf("max_open_connections cannot be below 5")
}
wrappedOpts = append(wrappedOpts, dbw.WithMaxOpenConnections(opts.withMaxOpenConnections))
}
+10
View File
@@ -22,6 +22,7 @@ func TestOpen(t *testing.T) {
type args struct {
dbType DbType
connectionUrl string
opt []Option
}
tests := []struct {
name string
@@ -44,6 +45,15 @@ func TestOpen(t *testing.T) {
},
wantErr: true,
},
{
name: "invalid - max_open_connections set to 3",
args: args{
dbType: Postgres,
connectionUrl: "",
opt: []Option{WithMaxOpenConnections(3)},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -1,6 +1,7 @@
begin;
-- Replaces the view created in 1/01 to include connections
-- Replaced in 31/0_session_list_no_connections
drop view session_with_state;
create view session_list as
select
@@ -0,0 +1,12 @@
begin;
delete from session
using session_state
where
session.public_id = session_state.session_id
and
session_state.state = 'terminated'
and
session_state.start_time < wt_sub_seconds_from_now(3600);
analyze;
commit;
@@ -0,0 +1,38 @@
begin;
-- Replaces the view created in 2/09_session_list_view
drop view session_list;
create view session_list as
select
s.public_id,
s.user_id,
s.host_id,
s.server_id,
s.server_type,
s.target_id,
s.host_set_id,
s.auth_token_id,
s.scope_id,
s.certificate,
s.expiration_time,
s.connection_limit,
s.tofu_token,
s.key_id,
s.termination_reason,
s.version,
s.create_time,
s.update_time,
s.endpoint,
s.worker_filter,
ss.state,
ss.previous_end_time,
ss.start_time,
ss.end_time
from
session s
join
session_state ss
on
s.public_id = ss.session_id;
commit;