Skip to content
Closed
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
12 changes: 2 additions & 10 deletions check_upgrade/check_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ package checkupgrade
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"testing"
"time"

Expand All @@ -28,11 +25,6 @@ import (
)

func TestCheckUpgrade(t *testing.T) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping live load-uids tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
conf := dgraphtest.NewClusterConfig().WithNumAlphas(1).WithNumZeros(1).WithReplicas(1).
WithACL(time.Hour).WithVersion("57aa5c4ac")
c, err := dgraphtest.NewLocalCluster(conf)
Expand Down Expand Up @@ -88,7 +80,7 @@ func TestCheckUpgrade(t *testing.T) {
"--namespace", "1",
}

cmd := exec.Command(filepath.Join(c1.GetTempDir(), "dgraph"), args...)
cmd := exec.Command(c1.HostDgraphBinaryPath(), args...)
out, err := cmd.CombinedOutput()
require.NoError(t, err)
actualOutput := string(out)
Expand All @@ -108,7 +100,7 @@ func TestQueryDuplicateNodes(t *testing.T) {
WithACL(time.Hour).WithVersion("57aa5c4ac").WithAclAlg(jwt.GetSigningMethod("HS256"))
c, err := dgraphtest.NewLocalCluster(conf)
require.NoError(t, err)
// defer func() { c.Cleanup(t.Failed()) }()
defer func() { c.Cleanup(t.Failed()) }()
require.NoError(t, c.Start())
gc, cleanup, err := c.Client()
require.NoError(t, err)
Expand Down
7 changes: 0 additions & 7 deletions dgraph/cmd/dgraphimport/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -326,11 +324,6 @@ func runImportTest(t *testing.T, tt testcase) {

// setupBulkCluster creates and configures a cluster for bulk loading data
func setupBulkCluster(t *testing.T, numAlphas int, encrypted bool) (*dgraphtest.LocalCluster, string) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
t.Skip("Skipping test on non-Linux platforms due to dgraph binary dependency")
}

baseDir := t.TempDir()
bulkConf := dgraphtest.NewClusterConfig().
WithNumAlphas(numAlphas).
Expand Down
7 changes: 0 additions & 7 deletions dgraph/cmd/live/load-json/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package live

import (
"context"
"fmt"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -162,12 +161,6 @@ func TestLiveLoadJSONMultipleFiles(t *testing.T) {
}

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping live load-json tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}

_, thisFile, _, _ := runtime.Caller(0)
testDataDir = filepath.Dir(thisFile)

Expand Down
6 changes: 0 additions & 6 deletions dgraph/cmd/live/load-uids/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,6 @@ func TestLiveLoadFileNameMultipleCorrect(t *testing.T) {
}

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping live load-uids tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}

alphaService = testutil.GetSockAddr()
alphaName = testutil.Instance

Expand Down
7 changes: 0 additions & 7 deletions dgraph/cmd/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
package version

import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -19,11 +17,6 @@ import (

// Test `dgraph version` with an empty config file.
func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping version tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
m.Run()
}

Expand Down
45 changes: 39 additions & 6 deletions dgraphtest/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"

Expand All @@ -28,9 +29,18 @@ func (c *LocalCluster) dgraphImage() string {
return "dgraph/dgraph:local"
}

// setupBinary sets up the dgraph binary. The binary is expected to be a version
// compiled that is compatible with the host OS and architecture. Search this repo
// for DGRAPH_BINARY to learn its use.
// setupBinary sets up dgraph binaries in tempBinDir.
//
// On Linux a single "dgraph" binary from $GOPATH/bin serves both Docker
// containers and local commands (bulk/live loader).
//
// On non-Linux (macOS) two binaries are placed in tempBinDir:
// - "dgraph" – a Linux binary for Docker containers, from
// $GOPATH/linux_<arch> (or LINUX_GOBIN if set).
// - "dgraph_host" – the host-native binary for local commands,
// from $GOPATH/bin.
//
// Both are produced by "make install".
func (c *LocalCluster) setupBinary() error {
if err := ensureDgraphClone(); err != nil {
panic(err)
Expand All @@ -43,11 +53,34 @@ func (c *LocalCluster) setupBinary() error {
}
}
if c.conf.version == localVersion {
if os.Getenv("GOPATH") == "" {
gopath := os.Getenv("GOPATH")
if gopath == "" {
return errors.New("GOPATH is not set")
}
fromDir := filepath.Join(os.Getenv("GOPATH"), "bin")
return copyBinary(fromDir, c.tempBinDir, c.conf.version)

if runtime.GOOS == "linux" {
// On Linux $GOPATH/bin/dgraph is both the native and Docker binary.
return copyBinary(filepath.Join(gopath, "bin"), c.tempBinDir, c.conf.version)
}

// Non-Linux (macOS): need separate Linux and host-native binaries.
// 1. Copy the Linux binary (for Docker containers) as "dgraph".
linuxDir := os.Getenv("LINUX_GOBIN")
if linuxDir == "" {
linuxDir = filepath.Join(gopath, "linux_"+runtime.GOARCH)
}
if err := copyBinary(linuxDir, c.tempBinDir, c.conf.version); err != nil {
return err
}

// 2. Copy the host-native binary (for local bulk/live commands) as "dgraph_host".
hostSrc := filepath.Join(gopath, "bin", "dgraph")

hostDst := filepath.Join(c.tempBinDir, "dgraph_host")
if err := copy(hostSrc, hostDst); err != nil {
return errors.Wrapf(err, "error copying host-native binary from [%v] to [%v]", hostSrc, hostDst)
}
return nil
}

binaryPath := filepath.Join(binariesPath, fmt.Sprintf(binaryNameFmt, c.conf.version))
Expand Down
25 changes: 14 additions & 11 deletions dgraphtest/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"

Expand All @@ -28,6 +29,17 @@ import (
"github.com/dgraph-io/dgraph/v25/x"
)

// HostDgraphBinaryPath returns the path to the host-OS-native dgraph binary
// in tempBinDir. On Linux this is simply "dgraph" (the same binary used by
// Docker containers). On non-Linux (macOS) it is "dgraph_host", a separate
// native binary copied by setupBinary().
func (c *LocalCluster) HostDgraphBinaryPath() string {
if runtime.GOOS == "linux" {
return filepath.Join(c.tempBinDir, "dgraph")
}
return filepath.Join(c.tempBinDir, "dgraph_host")
}

var datafiles = map[string]string{
"1million.schema": "https://github.com/dgraph-io/dgraph-benchmarks/blob/main/data/1million.schema?raw=true",
"1million.rdf.gz": "https://github.com/dgraph-io/dgraph-benchmarks/blob/main/data/1million.rdf.gz?raw=true",
Expand Down Expand Up @@ -245,7 +257,7 @@ func (c *LocalCluster) LiveLoad(opts LiveOpts) error {
}

log.Printf("[INFO] running live loader with args: [%v]", strings.Join(args, " "))
cmd := exec.Command(filepath.Join(c.tempBinDir, "dgraph"), args...)
cmd := exec.Command(c.HostDgraphBinaryPath(), args...)
if out, err := cmd.CombinedOutput(); err != nil {
return errors.Wrapf(err, "error running live loader: %v", string(out))
} else {
Expand Down Expand Up @@ -505,17 +517,8 @@ func (c *LocalCluster) BulkLoad(opts BulkOpts) error {
args = append(args, "-g", strings.Join(opts.GQLSchemaFiles, ","))
}

// dgraphCmdPath := os.Getenv("DGRAPH_CMD_PATH")
// if dgraphCmdPath == "" {
// dgraphCmdPath = filepath.Join(c.tempBinDir, "dgraph")
// }

log.Printf("[INFO] running bulk loader with args: [%v]", strings.Join(args, " "))
binaryName := "dgraph"
if os.Getenv("DGRAPH_BINARY") != "" {
binaryName = filepath.Base(os.Getenv("DGRAPH_BINARY"))
}
cmd := exec.Command(filepath.Join(c.tempBinDir, binaryName), args...)
cmd := exec.Command(c.HostDgraphBinaryPath(), args...)
if out, err := cmd.CombinedOutput(); err != nil {
return errors.Wrapf(err, "error running bulk loader: %v", string(out))
} else {
Expand Down
6 changes: 0 additions & 6 deletions systest/1million/1million_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -44,11 +43,6 @@ func Test1Million(t *testing.T) {
}

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping 1million tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
noschemaFile := filepath.Join(testutil.TestDataDirectory, "1million-noindex.schema")
rdfFile := filepath.Join(testutil.TestDataDirectory, "1million.rdf.gz")
if err := testutil.MakeDirEmpty([]string{"out/0", "out/1", "out/2"}); err != nil {
Expand Down
5 changes: 0 additions & 5 deletions systest/21million/bulk/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ func BenchmarkQueries(b *testing.B) {
}

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping 21million bulk tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
schemaFile := filepath.Join(testutil.TestDataDirectory, "21million.schema")
rdfFile := filepath.Join(testutil.TestDataDirectory, "21million.rdf.gz")
if err := testutil.MakeDirEmpty([]string{"out/0", "out/1", "out/2"}); err != nil {
Expand Down
6 changes: 0 additions & 6 deletions systest/audit_encrypted/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"fmt"
"os"
"os/exec"
"runtime"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -21,11 +20,6 @@ import (
)

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping audit_encrypted tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
m.Run()
}

Expand Down
5 changes: 0 additions & 5 deletions systest/cdc/cdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"time"

Expand All @@ -24,10 +23,6 @@ import (
)

func TestCDC(t *testing.T) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
t.Skip("Skipping test on non-Linux platforms due to dgraph binary dependency")
}
defer os.RemoveAll("./cdc_logs/sink.log")
path := testutil.DgraphBinaryPath()
cmd := exec.Command(path, "increment", "--num", "10",
Expand Down
7 changes: 0 additions & 7 deletions systest/export/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

Expand All @@ -32,11 +30,6 @@ import (
)

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping export tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
m.Run()
}

Expand Down
6 changes: 0 additions & 6 deletions systest/integration2/bulk_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
package main

import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -65,10 +63,6 @@ const (
)

func TestBulkLoaderNoDqlSchema(t *testing.T) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
t.Skip("Skipping test on non-Linux platforms due to dgraph binary dependency")
}
conf := dgraphtest.NewClusterConfig().WithNumAlphas(2).WithNumZeros(1).
WithACL(time.Hour).WithReplicas(1).WithBulkLoadOutDir(t.TempDir())
c, err := dgraphtest.NewLocalCluster(conf)
Expand Down
6 changes: 0 additions & 6 deletions systest/ldbc/ldbc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -72,11 +71,6 @@ func TestQueries(t *testing.T) {
}

func TestMain(m *testing.M) {
if runtime.GOOS != "linux" && os.Getenv("DGRAPH_BINARY") == "" {
fmt.Println("Skipping LDBC tests on non-Linux platforms due to dgraph binary dependency")
fmt.Println("You can set the DGRAPH_BINARY environment variable to path of a native dgraph binary to run these tests")
os.Exit(0)
}
noschemaFile := filepath.Join(testutil.TestDataDirectory, "ldbcTypes.schema")
rdfFile := testutil.TestDataDirectory
if err := testutil.MakeDirEmpty([]string{"out/0"}); err != nil {
Expand Down
Loading
Loading