Support opening repository in read-only mode (#4302)
Useful for running read only operations against the repository --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
b44585ba1c
commit
4814154928
@ -184,6 +184,7 @@ func (w *conn) commonConnect(
|
|||||||
ClientOptions: repo.ClientOptions{
|
ClientOptions: repo.ClientOptions{
|
||||||
Username: opts.User,
|
Username: opts.User,
|
||||||
Hostname: opts.Host,
|
Hostname: opts.Host,
|
||||||
|
ReadOnly: opts.ReadOnly,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ type Options struct {
|
|||||||
// ViewTimestamp is the time at which the repo should be opened at if
|
// ViewTimestamp is the time at which the repo should be opened at if
|
||||||
// immutable backups are being used. If nil then the current time is used.
|
// immutable backups are being used. If nil then the current time is used.
|
||||||
ViewTimestamp *time.Time `json:"viewTimestamp"`
|
ViewTimestamp *time.Time `json:"viewTimestamp"`
|
||||||
|
ReadOnly bool `json:"readonly,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Maintenance struct {
|
type Maintenance struct {
|
||||||
|
|||||||
@ -393,6 +393,31 @@ func (suite *RepositoryIntegrationSuite) TestConnect_DisableMetrics() {
|
|||||||
assert.Equal(t, r.GetID(), r.GetID())
|
assert.Equal(t, r.GetID(), r.GetID())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *RepositoryIntegrationSuite) TestConnect_ReadOnly() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.NewContext(t)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
// need to initialize the repository before we can test connecting to it.
|
||||||
|
st := storeTD.NewPrefixedS3Storage(t)
|
||||||
|
|
||||||
|
repo, err := Initialize(
|
||||||
|
ctx,
|
||||||
|
account.Account{},
|
||||||
|
st,
|
||||||
|
control.DefaultOptions(),
|
||||||
|
ctrlRepo.Retention{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// now re-connect
|
||||||
|
r, err := Connect(ctx, account.Account{}, st, repo.GetID(), control.Options{Repo: ctrlRepo.Options{ReadOnly: true}})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// now we have repoID beforehand
|
||||||
|
assert.Equal(t, r.GetID(), r.GetID())
|
||||||
|
}
|
||||||
|
|
||||||
// Test_Options tests that the options are passed through to the repository
|
// Test_Options tests that the options are passed through to the repository
|
||||||
// correctly
|
// correctly
|
||||||
func (suite *RepositoryIntegrationSuite) Test_Options() {
|
func (suite *RepositoryIntegrationSuite) Test_Options() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user