Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(meili): explicit wait for task interval #62

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/internal/backup/providers/gcp/gcp_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func Test_BackupProviderGCP(t *testing.T) {
defer func() {
if t.Failed() {
r, err := c.Logs(ctx)
assert.NoError(t, err)
require.NoError(t, err)

if err == nil {
logs, err := io.ReadAll(r)
assert.NoError(t, err)
require.NoError(t, err)

fmt.Println(string(logs))
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func Test_BackupProviderGCP(t *testing.T) {
require.NoError(t, err)

_, err = versions.Get("foo")
assert.Error(t, err)
require.Error(t, err)

allVersions := versions.List()
// even if the amount is larger than max backups to keep the fake server
Expand All @@ -129,7 +129,7 @@ func Test_BackupProviderGCP(t *testing.T) {
assert.NotZero(t, v.Date)

getVersion, err := versions.Get(v.Version)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, v, getVersion)

if i == 0 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/backup/providers/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Test_BackupProviderLocal(t *testing.T) {
require.NoError(t, err)

_, err = versions.Get("foo")
assert.Error(t, err)
require.Error(t, err)

allVersions := versions.List()
amount := backupAmount
Expand All @@ -108,7 +108,7 @@ func Test_BackupProviderLocal(t *testing.T) {
assert.NotZero(t, v.Date)

getVersion, err := versions.Get(v.Version)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, v, getVersion)

if i == 0 {
Expand Down
8 changes: 4 additions & 4 deletions cmd/internal/backup/providers/s3/s3_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func Test_BackupProviderS3(t *testing.T) {
defer func() {
if t.Failed() {
r, err := c.Logs(ctx)
assert.NoError(t, err)
require.NoError(t, err)

if err == nil {
logs, err := io.ReadAll(r)
assert.NoError(t, err)
require.NoError(t, err)

fmt.Println(string(logs))
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func Test_BackupProviderS3(t *testing.T) {
require.NoError(t, err)

_, err = versions.Get("foo")
assert.Error(t, err)
require.Error(t, err)

allVersions := versions.List()
require.Len(t, allVersions, backupAmount)
Expand All @@ -123,7 +123,7 @@ func Test_BackupProviderS3(t *testing.T) {
assert.NotZero(t, v.Date)

getVersion, err := versions.Get(v.Version)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, v, getVersion)

if i == 0 {
Expand Down
5 changes: 4 additions & 1 deletion cmd/internal/database/meilisearch/meilisearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func (db *Meilisearch) Backup(ctx context.Context) error {

db.log.Infow("dump creation triggered", "taskUUID", dumpResponse.TaskUID)

dumpTask, err := db.client.WaitForTask(dumpResponse.TaskUID, meilisearch.WaitParams{Context: ctx})
dumpTask, err := db.client.WaitForTask(dumpResponse.TaskUID, meilisearch.WaitParams{
Context: ctx,
Interval: time.Millisecond * 50,
})
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/internal/initializer/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s *backupService) ListBackups(ctx context.Context, _ *v1.ListBackupsReques
response := &v1.BackupListResponse{}
for _, b := range backups {
b := b
response.Backups = append(response.Backups, &v1.Backup{
response.Backups = append(response.GetBackups(), &v1.Backup{
Name: b.Name,
Version: b.Version,
Timestamp: timestamppb.New(b.Date),
Expand All @@ -60,7 +60,7 @@ func (s *backupService) ListBackups(ctx context.Context, _ *v1.ListBackupsReques
}

func (s *backupService) RestoreBackup(ctx context.Context, req *v1.RestoreBackupRequest) (*v1.RestoreBackupResponse, error) {
if req.Version == "" {
if req.GetVersion() == "" {
return nil, status.Error(codes.InvalidArgument, "version to restore must be defined explicitly")
}

Expand All @@ -69,7 +69,7 @@ func (s *backupService) RestoreBackup(ctx context.Context, req *v1.RestoreBackup
return nil, status.Error(codes.Internal, err.Error())
}

version, err := versions.Get(req.Version)
version, err := versions.Get(req.GetVersion())
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/internal/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func Start(ctx context.Context, log *zap.SugaredLogger, addr string) error {
continue
}

if resp.Status == v1.StatusResponse_DONE {
log.Infow("initializer succeeded, database can be started", "message", resp.Message)
if resp.GetStatus() == v1.StatusResponse_DONE {
log.Infow("initializer succeeded, database can be started", "message", resp.GetMessage())
return nil
}

log.Infow("initializer has not yet succeeded", "status", resp.Status, "message", resp.Message)
log.Infow("initializer has not yet succeeded", "status", resp.GetStatus(), "message", resp.GetMessage())
}
}
}
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ var restoreListCmd = &cobra.Command{
}

var data [][]string
for _, b := range backups.Backups {
data = append(data, []string{b.Timestamp.AsTime().String(), b.Name, b.Version})
for _, b := range backups.GetBackups() {
data = append(data, []string{b.GetTimestamp().AsTime().String(), b.GetName(), b.GetVersion()})
}

p := utils.NewTablePrinter()
Expand Down
8 changes: 4 additions & 4 deletions integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ func restoreFlow(t *testing.T, spec *flowSpec) {
return err
}

if len(backups.Backups) == 0 {
if len(backups.GetBackups()) == 0 {
return fmt.Errorf("no backups were made yet")
}

backup = backups.Backups[0]
backup = backups.GetBackups()[0]

return nil
}, retry.Context(ctx), retry.Attempts(0), retry.MaxDelay(2*time.Second))
Expand Down Expand Up @@ -251,11 +251,11 @@ func upgradeFlow(t *testing.T, spec *upgradeFlowSpec) {
return err
}

if len(backups.Backups) == 0 {
if len(backups.GetBackups()) == 0 {
return fmt.Errorf("no backups were made yet")
}

backup = backups.Backups[0]
backup = backups.GetBackups()[0]

return nil
}, retry.Context(ctx), retry.Attempts(0), retry.MaxDelay(2*time.Second))
Expand Down