Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-dgraph-core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ permissions:
jobs:
dgraph-core-tests:
if: github.event.pull_request.draft == false
runs-on: warp-ubuntu-latest-x64-4x
runs-on: warp-ubuntu-latest-x64-16x
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
Expand Down
6 changes: 3 additions & 3 deletions acl/acl_curl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (asuite *AclTestSuite) TestCurlAuthorization() {
return []string{"-H", fmt.Sprintf("X-Dgraph-AccessToken:%s", jwt),
"--ipv4",
"-H", "Content-Type: application/dql",
"-d", query, testutil.SockAddrHttp + "/query"}
"-d", query, testutil.GetSockAddrHttp() + "/query"}
}
testutil.VerifyCurlCmd(t, queryArgs(hc.AccessJwt), &testutil.CurlFailureConfig{
ShouldFail: false,
Expand All @@ -60,7 +60,7 @@ func (asuite *AclTestSuite) TestCurlAuthorization() {
"-H", "Content-Type: application/rdf",
"-d", fmt.Sprintf(`{ set {
_:a <%s> "string" .
}}`, predicateToWrite), testutil.SockAddrHttp + "/mutate"}
}}`, predicateToWrite), testutil.GetSockAddrHttp() + "/mutate"}

}

Expand All @@ -71,7 +71,7 @@ func (asuite *AclTestSuite) TestCurlAuthorization() {

alterArgs := func(jwt string) []string {
return []string{"-H", fmt.Sprintf("X-Dgraph-AccessToken:%s", jwt),
"-d", fmt.Sprintf(`%s: int .`, predicateToAlter), testutil.SockAddrHttp + "/alter"}
"-d", fmt.Sprintf(`%s: int .`, predicateToAlter), testutil.GetSockAddrHttp() + "/alter"}
}
testutil.VerifyCurlCmd(t, alterArgs(hc.AccessJwt), &testutil.CurlFailureConfig{
ShouldFail: true,
Expand Down
7 changes: 7 additions & 0 deletions check_upgrade/check_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ package checkupgrade
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"testing"
"time"

Expand All @@ -26,6 +28,11 @@ 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
6 changes: 6 additions & 0 deletions dgraph/cmd/dgraphimport/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -301,6 +303,10 @@ 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
2 changes: 1 addition & 1 deletion dgraph/cmd/increment/increment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func readBestEffort(t *testing.T, dg *dgo.Dgraph, pred string, M int) {
}

func setup(t *testing.T) *dgo.Dgraph {
dg, err := testutil.DgraphClientWithGroot(testutil.SockAddr)
dg, err := testutil.DgraphClientWithGroot(testutil.GetSockAddr())
if err != nil {
t.Fatalf("Error while getting a dgraph client: %v", err)
}
Expand Down
11 changes: 9 additions & 2 deletions dgraph/cmd/live/load-json/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package live

import (
"context"
"fmt"
"os"
"path/filepath"
"runtime"
Expand All @@ -22,7 +23,7 @@ import (
"github.com/hypermodeinc/dgraph/v25/x"
)

var alphaService = testutil.SockAddr
var alphaService = testutil.GetSockAddr()

var (
testDataDir string
Expand Down Expand Up @@ -161,11 +162,17 @@ 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)

var err error
dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr)
dg, err = testutil.DgraphClientWithGroot(testutil.GetSockAddr())
x.Panic(err)

// Try to create any files in a dedicated temp directory that gets cleaned up
Expand Down
12 changes: 9 additions & 3 deletions dgraph/cmd/live/load-uids/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestLiveLoadExportedSchema(t *testing.T) {
}
}`,
}
token := testutil.GrootHttpLogin("http://" + testutil.SockAddrHttp + "/admin")
token := testutil.GrootHttpLogin("http://" + testutil.GetSockAddrHttp() + "/admin")
resp := testutil.MakeGQLRequestWithAccessJwt(t, params, token.AccessJwt)
require.Nilf(t, resp.Errors, resp.Errors.Error())

Expand Down Expand Up @@ -351,8 +351,14 @@ 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
alphaService = testutil.SockAddr

x.AssertTrue(strings.Count(alphaName, "_") == 2)
left := strings.Index(alphaName, "_")
Expand All @@ -365,7 +371,7 @@ func TestMain(m *testing.M) {
fmt.Printf("Using test data dir: %s\n", testDataDir)

var err error
dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr)
dg, err = testutil.DgraphClientWithGroot(testutil.GetSockAddr())
if err != nil {
log.Fatalf("Error while getting a dgraph client: %v", err)
}
Expand Down
11 changes: 11 additions & 0 deletions dgraph/cmd/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
package version

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

"github.com/stretchr/testify/require"
Expand All @@ -16,6 +18,15 @@ 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()
}

func TestDgraphVersion(t *testing.T) {
tmpPath := t.TempDir()
configPath := filepath.Join(tmpPath, "config.yml")
Expand Down
4 changes: 2 additions & 2 deletions dgraph/cmd/zero/zero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestRemoveNode(t *testing.T) {

func TestIdLeaseOverflow(t *testing.T) {
dialOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
con, err := grpc.NewClient(testutil.SockAddrZero, dialOpts...)
con, err := grpc.NewClient(testutil.GetSockAddrZero(), dialOpts...)
require.NoError(t, err)
zc := pb.NewZeroClient(con)

Expand All @@ -55,7 +55,7 @@ func TestIdLeaseOverflow(t *testing.T) {

func TestIdBump(t *testing.T) {
dialOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
con, err := grpc.NewClient(testutil.SockAddrZero, dialOpts...)
con, err := grpc.NewClient(testutil.GetSockAddrZero(), dialOpts...)
require.NoError(t, err)
zc := pb.NewZeroClient(con)

Expand Down
18 changes: 9 additions & 9 deletions dgraph/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
service: zero
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
command:
Expand All @@ -32,7 +32,7 @@ services:
service: zero
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
command:
Expand All @@ -52,7 +52,7 @@ services:
service: zero
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
command:
Expand All @@ -64,7 +64,7 @@ services:
working_dir: /data/alpha1
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down Expand Up @@ -95,7 +95,7 @@ services:
- alpha1
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down Expand Up @@ -126,7 +126,7 @@ services:
- alpha2
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down Expand Up @@ -157,7 +157,7 @@ services:
- alpha3
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down Expand Up @@ -188,7 +188,7 @@ services:
- alpha4
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down Expand Up @@ -219,7 +219,7 @@ services:
- alpha5
volumes:
- type: bind
source: $GOPATH/bin
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
target: /gobin
read_only: true
- type: bind
Expand Down
4 changes: 2 additions & 2 deletions dgraphtest/compose_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewComposeCluster() *ComposeCluster {
}

func (c *ComposeCluster) Client() (*dgraphapi.GrpcClient, func(), error) {
dg, err := dgo.NewClient(testutil.SockAddr,
dg, err := dgo.NewClient(testutil.GetSockAddr(),
dgo.WithGrpcOption(grpc.WithTransportCredentials(insecure.NewCredentials())))
if err != nil {
return nil, nil, err
Expand All @@ -31,7 +31,7 @@ func (c *ComposeCluster) Client() (*dgraphapi.GrpcClient, func(), error) {

// HTTPClient creates an HTTP client
func (c *ComposeCluster) HTTPClient() (*dgraphapi.HTTPClient, error) {
httpClient, err := dgraphapi.GetHttpClient(testutil.SockAddrHttp, testutil.SockAddrZeroHttp)
httpClient, err := dgraphapi.GetHttpClient(testutil.GetSockAddrHttp(), testutil.GetSockAddrZeroHttp())
if err != nil {
return nil, err
}
Expand Down
16 changes: 11 additions & 5 deletions dgraphtest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (c *LocalCluster) containerHealthCheck(url func(c *LocalCluster) (string, e
return errors.Wrapf(err, "error getting health URL %v", endpoint)
}

for range 60 {
for attempt := range 60 {
time.Sleep(waitDurBeforeRetry)

endpoint, err = url(c)
Expand All @@ -555,12 +555,16 @@ func (c *LocalCluster) containerHealthCheck(url func(c *LocalCluster) (string, e

req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
log.Printf("[WARNING] error building req for endpoint [%v], err: [%v]", endpoint, err)
if attempt > 10 {
log.Printf("[WARNING] error building req for endpoint [%v], err: [%v]", endpoint, err)
}
continue
}
body, err := dgraphapi.DoReq(req)
if err != nil {
log.Printf("[WARNING] error hitting health endpoint [%v], err: [%v]", endpoint, err)
if attempt > 10 {
log.Printf("[WARNING] error hitting health endpoint [%v], err: [%v]", endpoint, err)
}
continue
}
resp := string(body)
Expand Down Expand Up @@ -602,13 +606,15 @@ func (c *LocalCluster) waitUntilLogin() error {

ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
defer cancel()
for range 10 {
for attempt := range 10 {
err := client.Login(ctx, dgraphapi.DefaultUser, dgraphapi.DefaultPassword)
if err == nil {
log.Printf("[INFO] login succeeded")
return nil
}
log.Printf("[WARNING] error trying to login: %v", err)
if attempt > 10 {
log.Printf("[WARNING] error trying to login: %v", err)
}
time.Sleep(waitDurBeforeRetry)
}
return errors.New("error during login")
Expand Down
4 changes: 2 additions & 2 deletions graphql/e2e/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
groupOneHTTP = testutil.ContainerAddr("alpha1", 8080)
groupTwoHTTP = testutil.ContainerAddr("alpha2", 8080)
groupThreeHTTP = testutil.ContainerAddr("alpha3", 8080)
groupOnegRPC = testutil.SockAddr
groupOnegRPC = testutil.GetSockAddr()

groupOneGraphQLServer = "http://" + groupOneHTTP + "/graphql"
groupTwoGraphQLServer = "http://" + groupTwoHTTP + "/graphql"
Expand Down Expand Up @@ -681,7 +681,7 @@ func TestDeleteSchemaAndExport(t *testing.T) {

require.Equal(t, "Success", testutil.JsonGet(data, "export", "response", "code").(string))
taskId := testutil.JsonGet(data, "export", "taskId").(string)
testutil.WaitForTask(t, taskId, false, testutil.SockAddrHttp)
testutil.WaitForTask(t, taskId, false, testutil.GetSockAddrHttp())

// applying a new schema should still work
newSchemaResp := common.AssertUpdateGQLSchemaSuccess(t, groupOneHTTP, schema, nil)
Expand Down
2 changes: 1 addition & 1 deletion query/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ type DispatchBoardCard {

`

const ngramVersionHash = "5d9fd2ed444b9ca1d3b03e7a51f5f92fc407cbaa"
const ngramVersionHash = "d7dfe3b4282fa3543e811c5538f86d39268961ba"

func populateCluster(dc dgraphapi.Cluster) {
x.Panic(client.Alter(context.Background(), &api.Operation{DropAll: true}))
Expand Down
Loading