Skip to content

Commit

Permalink
feat(restore_test): rewrite no replication test
Browse files Browse the repository at this point in the history
TestRestoreTablesNoReplicationIntegration is rewritten so that it's prettier, and it works well with new default tombstone_gc mode repair.
  • Loading branch information
Michal-Leszczynski committed Jun 4, 2024
1 parent 807d17d commit a560f44
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/service/restore/restore_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"testing"

"github.com/pkg/errors"
. "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
Expand Down Expand Up @@ -44,3 +45,47 @@ func TestRestoreTablesUserIntegration(t *testing.T) {
newKs := randomizedName("ks_")
ExecStmt(t, userSession, fmt.Sprintf("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}", newKs))
}

func TestRestoreTablesNoReplicationIntegration(t *testing.T) {
h := newTestHelper(t, ManagedSecondClusterHosts(), ManagedClusterHosts())

ks := randomizedName("no_rep_ks_")
tab := randomizedName("tab_")
Printf("Create non replicated %s.%s in both cluster", ks, tab)
ksStmt := fmt.Sprintf("CREATE KEYSPACE %q WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", ks)
tabStmt := fmt.Sprintf("CREATE TABLE %q.%q (id int PRIMARY KEY, data int)", ks, tab)
ExecStmt(t, h.srcCluster.rootSession, ksStmt)
ExecStmt(t, h.srcCluster.rootSession, tabStmt)
ExecStmt(t, h.dstCluster.rootSession, ksStmt)
ExecStmt(t, h.dstCluster.rootSession, tabStmt)

Print("Fill created table")
stmt := fmt.Sprintf("INSERT INTO %q.%q (id, data) VALUES (?, ?)", ks, tab)
q := h.srcCluster.rootSession.Query(stmt, []string{"id", "data"})
defer q.Release()
for i := 0; i < 100; i++ {
if err := q.Bind(i, i).Exec(); err != nil {
t.Fatal(errors.Wrap(err, "fill table"))
}
}

Print("Run backup")
loc := []Location{testLocation("no-replication", "")}
S3InitBucket(t, loc[0].Path)
ksFilter := []string{ks}
tag := h.runBackup(t, map[string]any{
"location": loc,
"keyspace": ksFilter,
})

Print("Run restore")
grantRestoreTablesPermissions(t, h.dstCluster.rootSession, ksFilter, h.dstUser)
h.runRestore(t, map[string]any{
"location": loc,
"keyspace": ksFilter,
"snapshot_tag": tag,
"restore_tables": true,
})

h.validateIdenticalTables(t, []table{{ks: ks, tab: tab}})
}

0 comments on commit a560f44

Please sign in to comment.