@@ -24,6 +24,8 @@ import (
2424
2525const noPW = ""
2626
27+ const defStoreMemSize = 0.2
28+
2729func TestRunServer (t * testing.T ) {
2830 const testPW = "foobar"
2931 for _ , tc := range []struct {
@@ -34,6 +36,12 @@ func TestRunServer(t *testing.T) {
3436 name : "Insecure" ,
3537 instantiation : func (t * testing.T ) (* sql.DB , func ()) { return testserver .NewDBForTest (t ) },
3638 },
39+ {
40+ name : "InsecureWithCustomizedMemSize" ,
41+ instantiation : func (t * testing.T ) (* sql.DB , func ()) {
42+ return testserver .NewDBForTest (t , testserver .SetStoreMemSizeOpt (0.3 ))
43+ },
44+ },
3745 {
3846 name : "SecureClientCert" ,
3947 instantiation : func (t * testing.T ) (* sql.DB , func ()) { return testserver .NewDBForTest (t , testserver .SecureOpt ()) },
@@ -44,34 +52,46 @@ func TestRunServer(t *testing.T) {
4452 return testserver .NewDBForTest (t , testserver .SecureOpt (), testserver .RootPasswordOpt (testPW ))
4553 },
4654 },
55+ {
56+ name : "InsecureTenantStoreOnDisk" ,
57+ instantiation : func (t * testing.T ) (* sql.DB , func ()) {
58+ return testserver .NewDBForTest (t , testserver .StoreOnDiskOpt ())
59+ },
60+ },
61+ {
62+ name : "SecureTenantStoreOnDisk" ,
63+ instantiation : func (t * testing.T ) (* sql.DB , func ()) {
64+ return testserver .NewDBForTest (t , testserver .SecureOpt (), testserver .StoreOnDiskOpt ())
65+ },
66+ },
4767 {
4868 name : "InsecureTenant" ,
4969 instantiation : func (t * testing.T ) (* sql.DB , func ()) {
50- return newTenantDBForTest (t , false /* secure */ , false /* proxy */ , noPW )
70+ return newTenantDBForTest (t , false /* secure */ , false /* proxy */ , noPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
5171 },
5272 },
5373 {
5474 name : "SecureTenant" ,
5575 instantiation : func (t * testing.T ) (* sql.DB , func ()) {
56- return newTenantDBForTest (t , true /* secure */ , false /* proxy */ , noPW )
76+ return newTenantDBForTest (t , true /* secure */ , false /* proxy */ , noPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
5777 },
5878 },
5979 {
6080 name : "SecureTenantCustomPassword" ,
6181 instantiation : func (t * testing.T ) (* sql.DB , func ()) {
62- return newTenantDBForTest (t , true /* secure */ , false /* proxy */ , testPW )
82+ return newTenantDBForTest (t , true /* secure */ , false /* proxy */ , testPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
6383 },
6484 },
6585 {
6686 name : "SecureTenantThroughProxy" ,
6787 instantiation : func (t * testing.T ) (* sql.DB , func ()) {
68- return newTenantDBForTest (t , true /* secure */ , true /* proxy */ , noPW )
88+ return newTenantDBForTest (t , true /* secure */ , true /* proxy */ , noPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
6989 },
7090 },
7191 {
7292 name : "SecureTenantThroughProxyCustomPassword" ,
7393 instantiation : func (t * testing.T ) (* sql.DB , func ()) {
74- return newTenantDBForTest (t , true /* secure */ , true /* proxy */ , testPW )
94+ return newTenantDBForTest (t , true /* secure */ , true /* proxy */ , testPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
7595 },
7696 },
7797 } {
@@ -105,15 +125,25 @@ type tenantInterface interface {
105125// newTenantDBForTest is a testing helper function that starts a TestServer
106126// process and a SQL tenant process pointed at this TestServer. A sql connection
107127// to the tenant and a cleanup function are returned.
108- func newTenantDBForTest (t * testing.T , secure bool , proxy bool , pw string ) (* sql.DB , func ()) {
128+ func newTenantDBForTest (
129+ t * testing.T , secure bool , proxy bool , pw string , diskStore bool , storeMemSize float64 ,
130+ ) (* sql.DB , func ()) {
109131 t .Helper ()
110132 var opts []testserver.TestServerOpt
111133 if secure {
112134 opts = append (opts , testserver .SecureOpt ())
113135 }
136+ if diskStore {
137+ opts = append (opts , testserver .StoreOnDiskOpt ())
138+ }
114139 if pw != "" {
115140 opts = append (opts , testserver .RootPasswordOpt (pw ))
116141 }
142+ if storeMemSize >= 0 {
143+ opts = append (opts , testserver .SetStoreMemSizeOpt (storeMemSize ))
144+ } else {
145+ t .Fatal ("Percentage memory size for data storage cannot be nagative" )
146+ }
117147 ts , err := testserver .NewTestServer (opts ... )
118148 if err != nil {
119149 t .Fatal (err )
@@ -138,7 +168,7 @@ func newTenantDBForTest(t *testing.T, secure bool, proxy bool, pw string) (*sql.
138168}
139169
140170func TestTenant (t * testing.T ) {
141- db , stop := newTenantDBForTest (t , false /* secure */ , false /* proxy */ , noPW )
171+ db , stop := newTenantDBForTest (t , false /* secure */ , false /* proxy */ , noPW , false /* diskStore */ , defStoreMemSize /* storeMemSize */ )
142172 defer stop ()
143173 if _ , err := db .Exec ("SELECT 1" ); err != nil {
144174 t .Fatal (err )
0 commit comments