Skip to content
Open
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: 2 additions & 6 deletions dgraph/cmd/dgraphimport/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func TestEmptyBulkOutDir(t *testing.T) {
}

func TestDrainModeAfterStartSnapshotStream(t *testing.T) {
t.Skip("Skipping... sometimes the query for schema succeeds even when the server is in draining mode")

tests := []struct {
name string
numAlphas int
Expand Down Expand Up @@ -123,8 +121,6 @@ func TestDrainModeAfterStartSnapshotStream(t *testing.T) {
}

func TestImportApis(t *testing.T) {
t.Skip("Skipping import tests due to persistent flakiness with container networking and Raft leadership issues")

tests := []testcase{
{
name: "SingleGroupShutTwoAlphasPerGroup",
Expand Down Expand Up @@ -391,12 +387,12 @@ func verifyImportResults(t *testing.T, gc *dgraphapi.GrpcClient, downAlphas int)
}

retryDelay := time.Second
hasAllPredicates := true

// Get expected predicates first
var expectedSchemaObj map[string]interface{}
require.NoError(t, json.Unmarshal([]byte(expectedSchema), &expectedSchemaObj))
expectedPredicates := getPredicateMap(expectedSchemaObj)
var hasAllPredicates bool

for i := 0; i < maxRetries; i++ {
// Checking client connection again here because an import operation may be in progress on the rejoined alpha
Expand All @@ -412,7 +408,7 @@ func verifyImportResults(t *testing.T, gc *dgraphapi.GrpcClient, downAlphas int)
// Get actual predicates
actualPredicates := getPredicateMap(actualSchema)

// Check if all expected predicates are present
hasAllPredicates = true
for predName := range expectedPredicates {
if _, exists := actualPredicates[predName]; !exists {
hasAllPredicates = false
Expand Down
4 changes: 2 additions & 2 deletions dgraphtest/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ func downloadFile(fname, url string) error {
cmd := exec.Command("wget", "-O", fname, url)
cmd.Dir = datasetFilesPath

if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("error downloading file %s: %s", fname, string(out))
if _, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("error downloading file %s: %w", fname, err)
}
return nil
}
3 changes: 1 addition & 2 deletions dgraphtest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@ func (c *LocalCluster) Client() (*dgraphapi.GrpcClient, func(), error) {
var conns []*grpc.ClientConn
for _, aa := range c.alphas {
if !aa.isRunning {
// QUESTIONS(shivaji): Should this be 'continue' instead of a break from the loop
break
continue
}
url, err := aa.alphaURL(c)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions systest/backup/nfs-backup/Untitled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alpha1_backup_clust_ha
15 changes: 8 additions & 7 deletions systest/backup/nfs-backup/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ var (
)

func TestBackupHAClust(t *testing.T) {
t.Skip("Skipping HA backup test via NFS")
backupRestoreTest(t, "alpha1_backup_clust_ha", "zero1_backup_clust_ha",
"alpha4_restore_clust_ha", backupDstHA)
}

func TestBackupNonHAClust(t *testing.T) {
t.Skip("Skipping Non-HA backup test via NFS")
backupRestoreTest(t, "alpha7_backup_clust_non_ha", "zero7_backup_clust_non_ha",
"alpha8_restore_clust_non_ha", backupDstNonHA)
}
Expand All @@ -61,18 +59,21 @@ func backupRestoreTest(t *testing.T, backupAlphaName string, backupZeroName stri
backupZero := testutil.ContainerInstance{Name: backupZeroName, Prefix: testutil.DockerPrefix}
require.NoError(t, backupZero.BestEffortWaitForHealthy(6080))

// Resolve addresses after containers are healthy
backupAlphaSocketAddr := testutil.ContainerAddr(backupAlphaName, 9080)
backupAlphaSocketAddrHttp := testutil.ContainerAddr(backupAlphaName, 8080)
restoreAlphaAddr := testutil.ContainerAddr(restoreAlphaName, 8080)
backupZeroAddr := testutil.ContainerAddr(backupZeroName, 6080)
backupAlphaSocketAddr := testutil.ContainerAddrRetry(backupAlphaName, 9080)
backupAlphaSocketAddrHttp := testutil.ContainerAddrRetry(backupAlphaName, 8080)
restoreAlphaAddr := testutil.ContainerAddrRetry(restoreAlphaName, 8080)
backupZeroAddr := testutil.ContainerAddrRetry(backupZeroName, 6080)

var dg *dgo.Dgraph
var err error
ctx := context.Background()

// Wait for gRPC connection to be ready with retries
t.Log("Waiting for gRPC connection to be ready...")
fmt.Println("=================================================")
fmt.Println("backup alpha addess ------>", backupAlphaSocketAddr)
fmt.Println("=================================================")

for i := 0; i < 30; i++ {
var connErr error
dg, connErr = dgo.Open(fmt.Sprintf("dgraph://%s?sslmode=disable", backupAlphaSocketAddr))
Expand Down
24 changes: 24 additions & 0 deletions testutil/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ func ContainerAddrWithHost(name string, privatePort uint16, host string) string
return host + ":" + strconv.Itoa(int(privatePort))
}

func ContainerAddrWithHostRetry(name string, privatePort uint16, host string) string {
maxAttempts := 30
for attempt := range maxAttempts {
fmt.Printf("Attempt %d to get container address for %s:%d with host %s\n", attempt, name, privatePort, host)
c := getContainer(name)
for _, p := range c.Ports {
if p.PrivatePort == privatePort {
// Found the mapping - return immediately without waiting
return host + ":" + strconv.Itoa(int(p.PublicPort))
}
}

if attempt < maxAttempts-1 {
time.Sleep(500 * time.Millisecond)
}
}

return host + ":" + strconv.Itoa(int(privatePort))
}

func ContainerAddrLocalhost(name string, privatePort uint16) string {
return ContainerAddrWithHost(name, privatePort, "localhost")
}
Expand All @@ -234,6 +254,10 @@ func ContainerAddr(name string, privatePort uint16) string {
return ContainerAddrWithHost(name, privatePort, "0.0.0.0")
}

func ContainerAddrRetry(name string, privatePort uint16) string {
return ContainerAddrWithHostRetry(name, privatePort, "0.0.0.0")
}

// DockerStart starts the specified services.
func DockerRun(instance string, op int) error {
c := getContainer(instance)
Expand Down
10 changes: 2 additions & 8 deletions worker/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func InStream(stream api.Dgraph_StreamExtSnapshotServer) error {
return fmt.Errorf("failed to establish stream with leader: %v", err)
}
glog.Infof("[import] [forward %d -> %d] start", groups().Node.gid, groupId)
glog.Infof("[import] [forward %d -> %d] start", groups().Node.MyAddr, groups().Leader(groupId).Addr)
glog.Infof("[import] [forward %v -> %d] start", groups().Node.MyAddr, groups().Leader(groupId).Addr)

glog.Infof("[import] sending forward true to leader of group [%v]", groupId)
forwardReq := &api.StreamExtSnapshotRequest{Forward: true}
Expand All @@ -313,12 +313,6 @@ func InStream(stream api.Dgraph_StreamExtSnapshotServer) error {
func pipeTwoStream(in api.Dgraph_StreamExtSnapshotServer, out pb.Worker_StreamExtSnapshotClient, groupId uint32) error {
currentGroup := groups().Node.gid
ctx := in.Context()
if err := out.Send(&api.StreamExtSnapshotRequest{GroupId: groupId}); err != nil {
return fmt.Errorf("send groupId downstream(%d): %w", groupId, err)
}
if _, err := out.Recv(); err != nil {
return fmt.Errorf("ack groupId downstream(%d): %w", groupId, err)
}

for {
if err := ctx.Err(); err != nil {
Expand Down Expand Up @@ -487,7 +481,7 @@ func streamInGroup(stream api.Dgraph_StreamExtSnapshotServer, forward bool) erro
if forward {
// We are not going to return any error from here because we care about the majority of nodes.
// If the majority of nodes are able to receive the data, the remaining ones can catch up later.
glog.Infof("[import] Streaming external snapshot to [%v] from [%v] forward [%v]", member.Addr, node.MyAddr)
glog.Infof("[import] Streaming external snapshot to [%v] from [%v]", member.Addr, node.MyAddr)
eg.Go(func() error {
glog.Infof(`[import:forward] streaming external snapshot to [%v] from [%v]`, member.Addr, node.MyAddr)
if member.AmDead {
Expand Down
Loading