Skip to content

Commit 6b377f9

Browse files
authored
validate: add Validator for backup/restore compatibility checks (#4)
* validate: add Validator for backup/restore compatibility checks Introduces a Validator component to verify backup/restore functionality against storage providers. It: - Creates source and restored databases/tables - Runs workloads to generate and mutate data - Executes full + incremental backups - Validates backup metadata (1 full, 1 incremental) - Restores into a new database and compares fingerprints - Cleans up resources after validation It also introduce a simple workload that adds rows into a kv style table. * blob: renamed store.Store to blob.Storage
1 parent 83b8299 commit 6b377f9

File tree

15 files changed

+532
-60
lines changed

15 files changed

+532
-60
lines changed

go.mod

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,25 @@ require (
3737
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
3838
github.com/cockroachdb/redact v1.1.5 // indirect
3939
github.com/davecgh/go-spew v1.1.1 // indirect
40+
github.com/dustin/go-humanize v1.0.1 // indirect
4041
github.com/getsentry/sentry-go v0.27.0 // indirect
42+
github.com/go-ini/ini v1.67.0 // indirect
43+
github.com/goccy/go-json v0.10.5 // indirect
4144
github.com/gogo/protobuf v1.3.2 // indirect
45+
github.com/klauspost/compress v1.18.0 // indirect
46+
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
4247
github.com/kr/text v0.2.0 // indirect
48+
github.com/minio/crc64nvme v1.0.2 // indirect
49+
github.com/minio/md5-simd v1.1.2 // indirect
50+
github.com/philhofer/fwd v1.2.0 // indirect
4351
github.com/pkg/errors v0.9.1 // indirect
4452
github.com/pmezard/go-difflib v1.0.0 // indirect
4553
github.com/rogpeppe/go-internal v1.13.1 // indirect
54+
github.com/rs/xid v1.6.0 // indirect
55+
github.com/tinylib/msgp v1.3.0 // indirect
4656
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
4757
golang.org/x/mod v0.27.0 // indirect
58+
golang.org/x/net v0.42.0 // indirect
4859
golang.org/x/sys v0.34.0 // indirect
4960
golang.org/x/tools v0.35.0 // indirect
5061
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
@@ -61,8 +72,9 @@ require (
6172
github.com/jackc/pgpassfile v1.0.0 // indirect
6273
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
6374
github.com/jackc/puddle/v2 v2.2.2 // indirect
75+
github.com/minio/minio-go/v7 v7.0.95
6476
github.com/stretchr/testify v1.10.0
65-
golang.org/x/crypto v0.39.0 // indirect
77+
golang.org/x/crypto v0.40.0 // indirect
6678
golang.org/x/sync v0.16.0 // indirect
67-
golang.org/x/text v0.26.0 // indirect
79+
golang.org/x/text v0.27.0 // indirect
6880
)

go.sum

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
5454
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5555
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5656
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
57+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
58+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
5759
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
5860
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
5961
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
6062
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
63+
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
64+
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
65+
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
66+
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
6167
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
6268
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
6369
github.com/google/addlicense v1.2.0 h1:W+DP4A639JGkcwBGMDvjSurZHvaq2FN0pP7se9czsKA=
@@ -76,10 +82,23 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
7682
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
7783
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
7884
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
85+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
86+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
87+
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
88+
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
89+
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
7990
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
8091
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
8192
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8293
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
94+
github.com/minio/crc64nvme v1.0.2 h1:6uO1UxGAD+kwqWWp7mBFsi5gAse66C4NXO8cmcVculg=
95+
github.com/minio/crc64nvme v1.0.2/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
96+
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
97+
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
98+
github.com/minio/minio-go/v7 v7.0.95 h1:ywOUPg+PebTMTzn9VDsoFJy32ZuARN9zhB+K3IYEvYU=
99+
github.com/minio/minio-go/v7 v7.0.95/go.mod h1:wOOX3uxS334vImCNRVyIDdXX9OsXDm89ToynKgqUKlo=
100+
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
101+
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
83102
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
84103
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
85104
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -90,18 +109,24 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
90109
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
91110
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
92111
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
112+
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
113+
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
93114
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
94115
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
95116
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
96117
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
97118
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
119+
github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww=
120+
github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
98121
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
99122
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
100123
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
101124
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
102125
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
103126
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
104127
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
128+
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
129+
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
105130
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
106131
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
107132
golang.org/x/lint v0.0.0-20241112194109-818c5a804067 h1:adDmSQyFTCiv19j015EGKJBoaa7ElV0Q1Wovb/4G7NA=
@@ -115,6 +140,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
115140
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
116141
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
117142
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
143+
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
144+
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
118145
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
119146
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
120147
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -129,6 +156,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
129156
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
130157
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
131158
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
159+
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
160+
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
132161
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
133162
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
134163
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=

internal/store/s3.go renamed to internal/blob/s3.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package store
15+
package blob
1616

1717
import (
1818
"context"
@@ -60,7 +60,7 @@ const (
6060
DefaultRegion = "aws-global"
6161
)
6262

63-
// ValidParams lists the valid parameters for the S3 store.
63+
// ValidParams lists the valid parameters for the S3 object storage.
6464
var ValidParams = []string{
6565
AccountParam, SecretParam, TokenParam, EndPointParam,
6666
RegionParam, UsePathStyleParam, SkipChecksum, SkipTLSVerify,
@@ -86,7 +86,7 @@ type s3Store struct {
8686
// S3FromEnv creates a new S3 store from the environment.
8787
// It will try to connect to the S3 service using the environment variables provided,
8888
// and adding any parameters that are required.
89-
func S3FromEnv(ctx *stopper.Context, env *env.Env) (Store, error) {
89+
func S3FromEnv(ctx *stopper.Context, env *env.Env) (Storage, error) {
9090
creds, ok := lookupEnv(env, []string{AccountParam, SecretParam}, []string{TokenParam, RegionParam})
9191
if !ok {
9292
return nil, ErrMissingParam
@@ -105,7 +105,7 @@ func S3FromEnv(ctx *stopper.Context, env *env.Env) (Store, error) {
105105
return initial.try(ctx, initial.BucketName())
106106
}
107107

108-
// BucketName implements Store.
108+
// BucketName implements BlobStorage.
109109
func (s *s3Store) BucketName() string {
110110
cleanedPath := path.Clean(s.dest)
111111
components := strings.Split(cleanedPath, "/")
@@ -115,7 +115,7 @@ func (s *s3Store) BucketName() string {
115115
return components[0]
116116
}
117117

118-
// Params implements Store.
118+
// Params implements BlobStorage.
119119
func (s *s3Store) Params() Params {
120120
params := maps.Clone(s.params)
121121
for param := range params {
@@ -126,7 +126,7 @@ func (s *s3Store) Params() Params {
126126
return params
127127
}
128128

129-
// URL implements Store.
129+
// URL implements BlobStorage.
130130
func (s *s3Store) URL() string {
131131
res := s.escapeValues()
132132
res = fmt.Sprintf("s3://%s?%s", s.dest, res)
@@ -144,8 +144,8 @@ func (s *s3Store) addParam(key string, value string) error {
144144

145145
// candidateConfigs provides a set of candidate configurations for the S3 store.
146146
// TODO(silvano): consider making this public.
147-
func (s *s3Store) candidateConfigs() iter.Seq[Store] {
148-
return func(yield func(Store) bool) {
147+
func (s *s3Store) candidateConfigs() iter.Seq[Storage] {
148+
return func(yield func(Storage) bool) {
149149
combos := [][]string{
150150
{}, // baseline first
151151
{SkipChecksum},
@@ -211,7 +211,7 @@ const (
211211
)
212212

213213
// try attempts to connect to the S3 store using alternative configurations.
214-
func (s *s3Store) try(ctx context.Context, bucketName string) (Store, error) {
214+
func (s *s3Store) try(ctx context.Context, bucketName string) (Storage, error) {
215215
var clientMode aws.ClientLogMode
216216
if s.verbose {
217217
clientMode |= aws.LogRetries | aws.LogRequestWithBody | aws.LogRequestEventMessage | aws.LogResponse | aws.LogResponseEventMessage | aws.LogSigning

internal/store/s3_test.go renamed to internal/blob/s3_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package store
15+
package blob
1616

1717
import (
1818
"fmt"
@@ -110,7 +110,7 @@ func TestS3Alternates(t *testing.T) {
110110
}
111111
gotSeq := s.candidateConfigs()
112112
var got []Params
113-
gotSeq(func(d Store) bool {
113+
gotSeq(func(d Storage) bool {
114114
if alt, ok := d.(*s3Store); ok {
115115
got = append(got, alt.params)
116116
}
@@ -269,14 +269,14 @@ func TestMinioFromEnv(t *testing.T) {
269269
Testing: true,
270270
}
271271

272-
store, err := S3FromEnv(ctx, env)
272+
blobStorage, err := S3FromEnv(ctx, env)
273273
if tt.wantErr != nil {
274-
assert.Nil(t, store)
274+
assert.Nil(t, blobStorage)
275275
assert.ErrorIs(t, err, tt.wantErr)
276276
return
277277
}
278278
require.NoError(t, err)
279-
s3 := (store.(*s3Store))
279+
s3 := (blobStorage.(*s3Store))
280280
assert.Equal(t, tt.want, s3.params)
281281
assert.Regexp(t, fmt.Sprintf("^%s", testPath), s3.dest)
282282
})

internal/store/store.go renamed to internal/blob/storage.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// TODO(silvano): rename this package to "externalStorage"/"blobStorage"
16-
package store
15+
// Package blob provides an interface for interacting with blob storage.
16+
package blob
1717

1818
import (
1919
"iter"
@@ -43,8 +43,8 @@ func (p Params) Iter() iter.Seq2[string, string] {
4343
}
4444
}
4545

46-
// Store represents a destination to perform a backup/restore.
47-
type Store interface {
46+
// Storage represents a destination to perform a backup/restore.
47+
type Storage interface {
4848
// Params returns a copy of the params.
4949
Params() Params
5050
// URL returns a escaped URL.

internal/store/store_test.go renamed to internal/blob/storage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package store
15+
package blob
1616

1717
import (
1818
"testing"

internal/db/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const dropDbStmt = `DROP database IF EXISTS %[1]s CASCADE;`
6363

6464
// Drop removes the database.
6565
func (d *Database) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error {
66-
slog.Info("Dropping database", slog.String("database", d.Name.String()))
66+
slog.Debug("Dropping database", slog.String("database", d.Name.String()))
6767
_, err := conn.Exec(ctx, fmt.Sprintf(dropDbStmt, d.Name))
6868
return err
6969
}

internal/db/ext_conn.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ import (
2525
"github.com/cockroachdb/errors"
2626
"github.com/cockroachdb/field-eng-powertools/semver"
2727
"github.com/cockroachdb/field-eng-powertools/stopper"
28-
"github.com/cockroachlabs-field/blobcheck/internal/store"
28+
"github.com/cockroachlabs-field/blobcheck/internal/blob"
2929
)
3030

3131
// MinVersionForStats is the minimum version required for retrieving statistics.
3232
var MinVersionForStats = semver.MustSemver("v25.1.0")
3333

34-
// ExternalConn represents an external connection to an object store.
34+
// ExternalConn represents an external connection to blob storage.
3535
type ExternalConn struct {
36-
name Ident
37-
store store.Store
36+
name Ident
37+
blob blob.Storage
3838
}
3939

4040
// Stats represents statistics about the external connection.
@@ -58,11 +58,11 @@ type TableBackup struct {
5858

5959
// NewExternalConn creates a new external connection.
6060
func NewExternalConn(
61-
ctx *stopper.Context, conn *pgxpool.Conn, store store.Store,
61+
ctx *stopper.Context, conn *pgxpool.Conn, blob blob.Storage,
6262
) (*ExternalConn, error) {
6363
extConn := &ExternalConn{
64-
name: "_blobcheck_backup",
65-
store: store,
64+
name: "_blobcheck_backup",
65+
blob: blob,
6666
}
6767
err := extConn.Drop(ctx, conn)
6868
if err != nil {
@@ -79,7 +79,6 @@ func (c *ExternalConn) ListTableBackups(
7979
) ([]string, error) {
8080
res := make([]string, 0)
8181
stmt := fmt.Sprintf(backupsStmt, c.String())
82-
slog.Info(stmt)
8382
rows, err := conn.Query(ctx, stmt)
8483
if err != nil {
8584
return nil, err
@@ -119,7 +118,7 @@ func (c *ExternalConn) BackupInfo(
119118
return nil, err
120119
}
121120
t.Full = (backupType == "full")
122-
slog.Info("backup info", "type", backupType, "full",
121+
slog.Debug("backup info", "type", backupType, "full",
123122
t.Full, "table", tableName, "schema", schemeName)
124123
res = append(res, t)
125124
}
@@ -129,22 +128,22 @@ func (c *ExternalConn) BackupInfo(
129128
const createExtConnStmt = `CREATE EXTERNAL CONNECTION '%[1]s' AS '%[2]s'`
130129

131130
func (c *ExternalConn) create(ctx *stopper.Context, conn *pgxpool.Conn) error {
132-
destURL := c.store.URL()
131+
destURL := c.blob.URL()
133132
stmt := fmt.Sprintf(createExtConnStmt, c.name, destURL)
134-
slog.Info("trying", slog.String("url", destURL))
133+
slog.Debug("trying", slog.String("url", destURL))
135134
if _, err := conn.Exec(ctx, stmt); err != nil {
136-
slog.Info("failed", slog.Any("error", err))
135+
slog.Error("failed", slog.Any("error", err))
137136
return err
138137
}
139-
slog.Info("checking existing backups")
138+
slog.Debug("checking existing backups")
140139
backups, err := c.ListTableBackups(ctx, conn)
141140
if err == nil {
142-
slog.Info("success",
141+
slog.Debug("success",
143142
slog.String("url", destURL),
144143
slog.Any("existing", backups))
145144
return nil
146145
}
147-
slog.Info("failed", slog.Any("error", err))
146+
slog.Error("failed", slog.Any("error", err))
148147
return errors.Newf("external connection failed")
149148
}
150149

@@ -156,7 +155,7 @@ func (c *ExternalConn) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error {
156155
var name string
157156
err := conn.QueryRow(ctx, fmt.Sprintf(showExtConnStmt, c.name)).Scan(&name)
158157
if err == pgx.ErrNoRows {
159-
slog.Info("external connection not found", slog.String("name", name))
158+
slog.Debug("external connection not found", slog.String("name", name))
160159
return nil
161160
}
162161
if err != nil {
@@ -204,6 +203,6 @@ func (c *ExternalConn) String() string {
204203
}
205204

206205
// SuggestedParams returns the suggested parameters for the external connection.
207-
func (c *ExternalConn) SuggestedParams() map[string]string {
208-
return c.store.Params()
206+
func (c *ExternalConn) SuggestedParams() blob.Params {
207+
return c.blob.Params()
209208
}

internal/db/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func TestIntegration(t *testing.T) {
5555
r.NoError(err)
5656

5757
extConn := &ExternalConn{
58-
name: "test-conn",
59-
store: &testStore{},
58+
name: "test-conn",
59+
blob: &testBlobStorage{},
6060
}
6161
extConn.create(ctx, conn)
6262
defer func() { a.NoError(extConn.Drop(ctx, conn)) }()

0 commit comments

Comments
 (0)