dgraphtest

package
v25.0.0-custom-qt-impr... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

README

Run Tests Against Dgraph Cloud

Setup Env Variables

  1. set TEST_DGRAPH_CLOUD_CLUSTER_URL to the URL that the dgo client should use
  2. set TEST_DGRAPH_CLOUD_CLUSTER_TOKEN to one of API keys that you can generate on the Settings page on the cloud UI
  3. TEST_DGRAPH_CLOUD_ACL to false if ACLs are disabled. By default, ACLs are assumed to be enabled.

Schema Mode

The tests require the Schema Mode to be set to Flexible from the Settings page on the cloud UI.

Running Tests

go test -tags=cloud ./...

Documentation

Index

Constants

View Source
const (
	DefaultAlphaPDir = "/data/alpha/p"
	DefaultBackupDir = "/data/backups"
	DefaultExportDir = "/data/exports"
)

Variables

This section is empty.

Functions

func AddData

func AddData(gc *dgraphapi.GrpcClient, pred string, start, end int) error

AddData will insert a total of end-start triples into the database.

func IsHigherVersion

func IsHigherVersion(higher, lower string) (bool, error)

IsHigherVersion checks whether "higher" is the higher version compared to "lower"

func ShouldSkipTest

func ShouldSkipTest(t *testing.T, minVersion, clusterVersion string)

ShouldSkipTest skips a given test if clusterVersion < minVersion

Types

type BulkOpts

type BulkOpts struct {
	DataFiles      []string
	SchemaFiles    []string
	GQLSchemaFiles []string
	OutDir         string
}

type ClusterConfig

type ClusterConfig struct {
	// contains filtered or unexported fields
}

ClusterConfig stores all config for setting up a dgraph cluster

func NewClusterConfig

func NewClusterConfig() ClusterConfig

NewClusterConfig generates a default ClusterConfig

func (ClusterConfig) GetClusterVolume

func (cc ClusterConfig) GetClusterVolume(volume string) string

func (ClusterConfig) WithACL

func (cc ClusterConfig) WithACL(aclTTL time.Duration) ClusterConfig

WithAcl enables ACL feature for Dgraph cluster

func (ClusterConfig) WithAclAlg

func (cc ClusterConfig) WithAclAlg(alg jwt.SigningMethod) ClusterConfig

WithAclAlg sets the JWT signing algorithm for dgraph ACLs

func (ClusterConfig) WithAlphaVolume

func (cc ClusterConfig) WithAlphaVolume(volname, dir string) ClusterConfig

WithAlphaVolume allows creating a shared volumes across alphas with name volname and mount directory specified as dir inside the container

func (ClusterConfig) WithBulkLoadOutDir

func (cc ClusterConfig) WithBulkLoadOutDir(dir string) ClusterConfig

WithBulkLoadOutDir sets the out dir for the bulk loader. This ensures that the same p directory is used while setting up alphas.

func (ClusterConfig) WithCustomPlugins

func (cc ClusterConfig) WithCustomPlugins() ClusterConfig

Enables generation of the custom_plugins in testutil/custom_plugins

func (ClusterConfig) WithEncryption

func (cc ClusterConfig) WithEncryption() ClusterConfig

WithEncryption enables encryption for the cluster

func (ClusterConfig) WithExposedPortOffset

func (cc ClusterConfig) WithExposedPortOffset(offset uint64) ClusterConfig

WithExposedPortOffset allows exposing the alpha/zero ports (5080, 6080, 8080 and 9080) to fixed ports (port (5080, 6080, 8080 and 9080) + offset + id (0, 1, 2 ...)) on the host.

func (ClusterConfig) WithGraphqlLambdaURL

func (cc ClusterConfig) WithGraphqlLambdaURL(url string) ClusterConfig

WithGraphqlLambdaURL sets the graphql lambda url for alpha

func (ClusterConfig) WithMCP

func (cc ClusterConfig) WithMCP() ClusterConfig

WithMcp sets the mcp flag for alpha

func (ClusterConfig) WithNormalizeCompatibilityMode

func (cc ClusterConfig) WithNormalizeCompatibilityMode(mode string) ClusterConfig

WithNormalizeCompatibilityMode sets the normalize-compatibility-mode feature flag for alpha

func (ClusterConfig) WithNumAlphas

func (cc ClusterConfig) WithNumAlphas(n int) ClusterConfig

WithNumAlphas sets the number of alphas in the cluster

func (ClusterConfig) WithNumZeros

func (cc ClusterConfig) WithNumZeros(n int) ClusterConfig

WithNumZeros sets the number of zero nodes in the Dgraph cluster

func (ClusterConfig) WithRefillInterval

func (cc ClusterConfig) WithRefillInterval(interval time.Duration) ClusterConfig

WithRefillInterval sets the refill interval for replenishing UIDs

func (ClusterConfig) WithReplicas

func (cc ClusterConfig) WithReplicas(n int) ClusterConfig

WithReplicas sets the number of replicas in each alpha group

func (ClusterConfig) WithSnapshotConfig

func (cc ClusterConfig) WithSnapshotConfig(snapShotAfterEntries uint64,
	snapshotAfterDuration time.Duration) ClusterConfig

func (ClusterConfig) WithUidLease

func (cc ClusterConfig) WithUidLease(uidLease int) ClusterConfig

WithUidLease sets the number of UIDs to replenish after refill interval

func (ClusterConfig) WithVerbosity

func (cc ClusterConfig) WithVerbosity(v int) ClusterConfig

WithVerbosity sets the verbosity level for the logs

func (ClusterConfig) WithVersion

func (cc ClusterConfig) WithVersion(version string) ClusterConfig

WithVersion sets the Dgraph version for the cluster

type ComposeCluster

type ComposeCluster struct{}

func NewComposeCluster

func NewComposeCluster() *ComposeCluster

func (*ComposeCluster) AlphasHealth

func (c *ComposeCluster) AlphasHealth() ([]string, error)

func (*ComposeCluster) AlphasLogs

func (c *ComposeCluster) AlphasLogs() ([]string, error)

func (*ComposeCluster) AssignUids

func (c *ComposeCluster) AssignUids(client *dgo.Dgraph, num uint64) error

func (*ComposeCluster) Client

func (c *ComposeCluster) Client() (*dgraphapi.GrpcClient, func(), error)

func (*ComposeCluster) GetEncKeyPath

func (c *ComposeCluster) GetEncKeyPath() (string, error)

func (*ComposeCluster) GetRepoDir

func (c *ComposeCluster) GetRepoDir() (string, error)

GetRepoDir returns the repositroty directory of the cluster

func (*ComposeCluster) GetVersion

func (c *ComposeCluster) GetVersion() string

func (*ComposeCluster) HTTPClient

func (c *ComposeCluster) HTTPClient() (*dgraphapi.HTTPClient, error)

HTTPClient creates an HTTP client

type DCloudCluster

type DCloudCluster struct {
	// contains filtered or unexported fields
}

func NewDCloudCluster

func NewDCloudCluster() (*DCloudCluster, error)

func (*DCloudCluster) AlphasHealth

func (c *DCloudCluster) AlphasHealth() ([]string, error)

func (*DCloudCluster) AlphasLogs

func (c *DCloudCluster) AlphasLogs() ([]string, error)

func (*DCloudCluster) AssignUids

func (c1 *DCloudCluster) AssignUids(client *dgo.Dgraph, num uint64) error

AssignUids moves the max assigned UIDs by the given number. Note that we this performs dropall after moving the max assigned.

func (*DCloudCluster) Client

func (c *DCloudCluster) Client() (*dgraphapi.GrpcClient, func(), error)

func (*DCloudCluster) GetEncKeyPath

func (c *DCloudCluster) GetEncKeyPath() (string, error)

func (*DCloudCluster) GetRepoDir

func (c *DCloudCluster) GetRepoDir() (string, error)

GetRepoDir returns the repositroty directory of the cluster

func (*DCloudCluster) GetVersion

func (c *DCloudCluster) GetVersion() string

func (*DCloudCluster) HTTPClient

func (c *DCloudCluster) HTTPClient() (*dgraphapi.HTTPClient, error)

type Dataset

type Dataset struct {
	// contains filtered or unexported fields
}

func GetDataset

func GetDataset(d DatasetType) *Dataset

func (*Dataset) DataFilePath

func (d *Dataset) DataFilePath() string

func (*Dataset) GqlSchemaPath

func (d *Dataset) GqlSchemaPath() string

func (*Dataset) SchemaPath

func (d *Dataset) SchemaPath() string

type DatasetType

type DatasetType int
const (
	OneMillionDataset DatasetType = iota
	TwentyOneMillionDataset
)

type LiveOpts

type LiveOpts struct {
	DataFiles      []string
	SchemaFiles    []string
	GqlSchemaFiles []string
}

LiveOpts are options that are used for running live loader.

type LocalCluster

type LocalCluster struct {
	// contains filtered or unexported fields
}

LocalCluster is a local dgraph cluster

func NewLocalCluster

func NewLocalCluster(conf ClusterConfig) (*LocalCluster, error)

NewLocalCluster creates a new local dgraph cluster with given configuration

func (*LocalCluster) AlphaClient

func (c *LocalCluster) AlphaClient(id int) (*dgraphapi.GrpcClient, func(), error)

func (*LocalCluster) AlphasHealth

func (c *LocalCluster) AlphasHealth() ([]string, error)

AlphasHealth returns response of health endpoint for all alphas

func (*LocalCluster) AlphasLogs

func (c *LocalCluster) AlphasLogs() ([]string, error)

AlphasLogs returns logs of all the alpha containers

func (*LocalCluster) AssignUids

func (c *LocalCluster) AssignUids(_ *dgo.Dgraph, num uint64) error

AssignUids talks to zero to assign the given number of uids

func (*LocalCluster) BulkLoad

func (c *LocalCluster) BulkLoad(opts BulkOpts) error

func (*LocalCluster) Cleanup

func (c *LocalCluster) Cleanup(verbose bool)

func (*LocalCluster) Client

func (c *LocalCluster) Client() (*dgraphapi.GrpcClient, func(), error)

Client returns a grpc client that can talk to any Alpha in the cluster

func (*LocalCluster) GeneratePlugins

func (c *LocalCluster) GeneratePlugins(raceEnabled bool) error

func (*LocalCluster) GetAlphaGrpcEndpoint

func (c *LocalCluster) GetAlphaGrpcEndpoint(id int) (string, error)

func (*LocalCluster) GetAlphaGrpcPublicPort

func (c *LocalCluster) GetAlphaGrpcPublicPort(id int) (string, error)

func (*LocalCluster) GetAlphaHttpPublicPort

func (c *LocalCluster) GetAlphaHttpPublicPort(id int) (string, error)

func (*LocalCluster) GetEncKeyPath

func (c *LocalCluster) GetEncKeyPath() (string, error)

GetEncKeyPath returns the path to the encryption key file when encryption is enabled. It returns an empty string otherwise. The path to the encryption file is valid only inside the alpha container.

func (*LocalCluster) GetRepoDir

func (c *LocalCluster) GetRepoDir() (string, error)

GetRepoDir returns the repositroty directory of the cluster

func (*LocalCluster) GetTempDir

func (c *LocalCluster) GetTempDir() string

func (*LocalCluster) GetVersion

func (c *LocalCluster) GetVersion() string

GetVersion returns the version of dgraph the cluster is running

func (*LocalCluster) GetZeroGrpcPublicPort

func (c *LocalCluster) GetZeroGrpcPublicPort(id int) (string, error)

func (*LocalCluster) HTTPClient

func (c *LocalCluster) HTTPClient() (*dgraphapi.HTTPClient, error)

HTTPClient creates an HTTP client

func (*LocalCluster) HealthCheck

func (c *LocalCluster) HealthCheck(zeroOnly bool) error

func (*LocalCluster) KillAlpha

func (c *LocalCluster) KillAlpha(id int) error

func (*LocalCluster) LiveLoad

func (c *LocalCluster) LiveLoad(opts LiveOpts) error

LiveLoad runs the live loader with provided options

func (*LocalCluster) LiveLoadFromExport

func (c *LocalCluster) LiveLoadFromExport(exportDir string) error

LiveLoadFromExport runs the live loader from the output of dgraph export The exportDir is the directory present inside the container. This function first copies all the files on the host and then runs the live loader.

func (*LocalCluster) Start

func (c *LocalCluster) Start() error

func (*LocalCluster) StartAlpha

func (c *LocalCluster) StartAlpha(id int) error

func (*LocalCluster) StartZero

func (c *LocalCluster) StartZero(id int) error

func (*LocalCluster) Stop

func (c *LocalCluster) Stop() error

func (*LocalCluster) StopAlpha

func (c *LocalCluster) StopAlpha(id int) error

func (*LocalCluster) StopZero

func (c *LocalCluster) StopZero(id int) error

func (*LocalCluster) Upgrade

func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error

Upgrades the cluster to the provided dgraph version

type UpgradeCombo

type UpgradeCombo struct {
	Before   string
	After    string
	Strategy UpgradeStrategy
}

UpgradeCombo represents a version combination before and after the upgrade, and the strategy for upgrading

func AllUpgradeCombos

func AllUpgradeCombos(v20 bool) []UpgradeCombo

AllUpgradeCombos returns all possible upgrade combinations for which tests need to run

type UpgradeStrategy

type UpgradeStrategy int

UpgradeStrategy is an Enum that defines various upgrade strategies

const (
	BackupRestore UpgradeStrategy = iota
	ExportImport
	InPlace
)

func (UpgradeStrategy) String

func (u UpgradeStrategy) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL