Documentation ¶
Overview ¶
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- Variables
- func AddMpath(t *testing.T, path string)
- func AssertMountpathCount(t *testing.T, availableCount, disabledCount int)
- func BaseAPIParams(urls ...string) api.BaseParams
- func BucketExists(tb testing.TB, proxyURL string, bck cmn.Bck) (bool, error)
- func BucketsContain(bcks cmn.Bcks, qbck cmn.QueryBcks) bool
- func CheckErrIsNotFound(t *testing.T, err error)
- func CheckObjIsPresent(proxyURL string, bck cmn.Bck, objName string) bool
- func CheckPathExists(t *testing.T, path string, dir bool)
- func CheckPathNotExists(t *testing.T, path string)
- func CheckSkip(tb testing.TB, args SkipTestArgs)
- func CleanupNode(t *testing.T, pid int)
- func CleanupRemoteBucket(t *testing.T, proxyURL string, bck cmn.Bck, prefix string)
- func ClearMaintenance(bp api.BaseParams, tsi *cluster.Snode)
- func CreateBucketWithCleanup(tb testing.TB, proxyURL string, bck cmn.Bck, props *cmn.BucketPropsToUpdate)
- func CreateFileFromReader(t *testing.T, fileName string, r io.Reader) string
- func Del(proxyURL string, bck cmn.Bck, object string, wg *sync.WaitGroup, ...) error
- func DeployNode(t *testing.T, node *cluster.Snode, conf *cmn.Config, ...) int
- func DestroyBucket(tb testing.TB, proxyURL string, bck cmn.Bck)
- func EnsureObjectsExist(t *testing.T, params api.BaseParams, bck cmn.Bck, objectsNames ...string)
- func EnsureOrigClusterState(t *testing.T)
- func EvictObjects(t *testing.T, proxyURL string, bck cmn.Bck, objList []string)
- func EvictRemoteBucket(tb testing.TB, proxyURL string, bck cmn.Bck)
- func FilesEqual(file1, file2 string) (bool, error)
- func GenerateNonexistentBucketName(prefix string, bp api.BaseParams) (string, error)
- func GenerateNotConflictingObjectName(baseName, newNamePrefix string, bck cmn.Bck, smap *cluster.Smap) string
- func GetClusterConfig(t *testing.T) (config *cmn.Config)
- func GetClusterMap(tb testing.TB, url string) *cluster.Smap
- func GetClusterStats(t *testing.T, proxyURL string) stats.Cluster
- func GetDaemonConfig(t *testing.T, node *cluster.Snode) *cmn.Config
- func GetICProxy(t testing.TB, smap *cluster.Smap, ignoreID string) *cluster.Snode
- func GetNamedStatsVal(ds *stats.Node, name string) int64
- func GetObjectAtime(t *testing.T, bp api.BaseParams, bck cmn.Bck, object, timeFormat string) (time.Time, string)
- func GetPrimaryProxy(proxyURL string) (*cluster.Snode, error)
- func GetPrimaryURL() string
- func GetProxyReadiness(proxyURL string) error
- func GetTargetsMountpaths(t *testing.T, smap *cluster.Smap, params api.BaseParams) map[*cluster.Snode][]string
- func InitCluster(proxyURL string, clusterType ClusterType) (err error)
- func InitLocalCluster()
- func JoinCluster(proxyURL string, node *cluster.Snode) (string, error)
- func ListObjectNames(proxyURL string, bck cmn.Bck, prefix string, objectCountLimit uint, ...) ([]string, error)
- func NewClientWithProxy(proxyURL string) *http.Client
- func PrepareDirTree(tb testing.TB, desc DirTreeDesc) (string, []string)
- func PrepareMountPaths(t *testing.T, cnt int) fs.MPI
- func Put(proxyURL string, bck cmn.Bck, objName string, reader readers.Reader, ...)
- func PutObjRR(bp api.BaseParams, bck cmn.Bck, objName string, objSize int64, ...) error
- func PutObject(t *testing.T, bck cmn.Bck, objName string, reader readers.Reader)
- func PutObjectInRemoteBucketWithoutCachingLocally(t *testing.T, bck cmn.Bck, object string, objContent cos.ReadOpenCloser)
- func PutRR(tb testing.TB, bp api.BaseParams, objSize int64, cksumType string, bck cmn.Bck, ...) []string
- func PutRandObjs(args PutObjectsArgs) ([]string, int, error)
- func RandomObjDir(dirLen, maxDepth int) (dir string)
- func RandomProxyURL(ts ...*testing.T) (url string)
- func RemoveMpaths(t *testing.T, mpaths fs.MPI)
- func RemoveNodeFromSmap(proxyURL, sid string) error
- func RestoreNode(cmd RestoreCmd, asPrimary bool, tag string) error
- func RestoreTarget(t *testing.T, proxyURL string, target *cluster.Snode) (rebID string, newSmap *cluster.Smap)
- func RmTargetSkipRebWait(t *testing.T, proxyURL string, smap *cluster.Smap) (*cluster.Smap, *cluster.Snode)
- func SetBackendBck(t *testing.T, bp api.BaseParams, srcBck, dstBck cmn.Bck)
- func SetClusterConfig(t *testing.T, nvs cos.StrKVs)
- func SetClusterConfigUsingMsg(t *testing.T, toUpdate *cmn.ConfigToUpdate)
- func SetXattrCksum(fqn string, bck cmn.Bck, cksum *cos.Cksum) error
- func ShortSkipf(tb testing.TB, a ...any)
- func WaitForBucket(proxyURL string, query cmn.QueryBcks, exists bool) error
- func WaitForClusterState(proxyURL, reason string, origVer int64, pcnt, tcnt int, ignoreIDs ...string) (*cluster.Smap, error)
- func WaitForClusterStateActual(proxyURL, reason string, origVersion int64, proxyCnt, targetCnt int, ...) (*cluster.Smap, error)
- func WaitForDSortToFinish(proxyURL, managerUUID string) (allAborted bool, err error)
- func WaitForNewSmap(proxyURL string, prevVersion int64) (newSmap *cluster.Smap, err error)
- func WaitForNodeToTerminate(pid int, timeout ...time.Duration) error
- func WaitForObjectToBeDowloaded(bp api.BaseParams, bck cmn.Bck, objName string, timeout time.Duration) error
- func WaitForRebalAndResil(t testing.TB, bp api.BaseParams, timeouts ...time.Duration)
- func WaitForRebalanceByID(t *testing.T, origTargetCnt int, bp api.BaseParams, rebID string, ...)
- func WaitForResilvering(t *testing.T, bp api.BaseParams, target *cluster.Snode)
- func WaitNodeAdded(bp api.BaseParams, nodeID string) (*cluster.Smap, error)
- func WaitNodeReady(url string, opts ...*WaitRetryOpts) (err error)
- type ClusterType
- type ContentTypeDesc
- type Ctx
- type DirTreeDesc
- type E2EFramework
- type ObjectsDesc
- type ObjectsOut
- type PutObjectsArgs
- type RestoreCmd
- type SkipTestArgs
- type WaitRetryOpts
Constants ¶
const ( // This value is holds the input of 'proxyURLFlag' from init_tests.go. // It is used in BaseAPIParams to determine if the cluster is running // on a // 1. local instance (no docker) - works // 2. local docker instance - works // 3. AWS-deployed cluster - not tested (but runs mainly with Ansible) MockDaemonID = "MOCK" )
Variables ¶
Functions ¶
func AssertMountpathCount ¶
func BaseAPIParams ¶
func BaseAPIParams(urls ...string) api.BaseParams
func CheckErrIsNotFound ¶
func CheckPathNotExists ¶
func CheckSkip ¶
func CheckSkip(tb testing.TB, args SkipTestArgs)
func CleanupRemoteBucket ¶
func ClearMaintenance ¶
func ClearMaintenance(bp api.BaseParams, tsi *cluster.Snode)
func CreateBucketWithCleanup ¶
func CreateBucketWithCleanup(tb testing.TB, proxyURL string, bck cmn.Bck, props *cmn.BucketPropsToUpdate)
CreateBucketWithCleanup, destroys bucket if exists and creates new. The bucket is destroyed on test completion.
func CreateFileFromReader ¶
func DeployNode ¶
func DestroyBucket ¶
is usually called to cleanup (via tb.Cleanup)
func EnsureObjectsExist ¶
func EnsureOrigClusterState ¶
EnsureOrigClusterState verifies the cluster has the same nodes after tests If a node is killed, it restores the node
func FilesEqual ¶
func GenerateNonexistentBucketName ¶
func GenerateNonexistentBucketName(prefix string, bp api.BaseParams) (string, error)
func GenerateNotConflictingObjectName ¶
func GenerateNotConflictingObjectName(baseName, newNamePrefix string, bck cmn.Bck, smap *cluster.Smap) string
Generates an object name that hashes to a different target than `baseName`.
func GetICProxy ¶
Return the first proxy from smap that is IC member. The primary proxy has higher priority.
func GetObjectAtime ¶
func GetPrimaryProxy ¶
GetPrimaryProxy returns the primary proxy
func GetPrimaryURL ¶
func GetPrimaryURL() string
func GetProxyReadiness ¶
func GetTargetsMountpaths ¶
func InitCluster ¶
func InitCluster(proxyURL string, clusterType ClusterType) (err error)
InitCluster initializes the environment necessary for testing against an AIS cluster. NOTE:
the function is also used for testing by NVIDIA/ais-k8s Operator
func InitLocalCluster ¶
func InitLocalCluster()
InitLocalCluster initializes AIS cluster that must be either:
- deployed locally using `make deploy` command and accessible @ localhost:8080, or
- deployed in local docker environment, or
- provided via `AIS_ENDPOINT` environment variable
In addition, try to query remote AIS cluster that may or may not be locally deployed as well.
func JoinCluster ¶
Add an alive node that is not in SMap to the cluster. Use to add a new node to the cluster or get back a node removed by `RemoveNodeFromSmap`
func ListObjectNames ¶
func ListObjectNames(proxyURL string, bck cmn.Bck, prefix string, objectCountLimit uint, cached bool) ([]string, error)
ListObjectNames returns a slice of object names of all objects that match the prefix in a bucket
func NewClientWithProxy ¶
func PrepareDirTree ¶
func PrepareDirTree(tb testing.TB, desc DirTreeDesc) (string, []string)
func PutObjectInRemoteBucketWithoutCachingLocally ¶
func PutObjectInRemoteBucketWithoutCachingLocally(t *testing.T, bck cmn.Bck, object string, objContent cos.ReadOpenCloser)
Put an object into a cloud bucket and evict it afterwards - can be used to test cold GET
func PutRandObjs ¶
func PutRandObjs(args PutObjectsArgs) ([]string, int, error)
func RandomObjDir ¶
func RandomProxyURL ¶
func RemoveNodeFromSmap ¶
Internal API to remove a node from Smap: use it to unregister MOCK targets/proxies. Use `JoinCluster` to attach node back.
func RestoreNode ¶
func RestoreNode(cmd RestoreCmd, asPrimary bool, tag string) error
func RestoreTarget ¶
func RestoreTarget(t *testing.T, proxyURL string, target *cluster.Snode) (rebID string, newSmap *cluster.Smap)
Restore a node put into maintenance: in this case the node is in Smap and canceling maintenance gets the node back.
func RmTargetSkipRebWait ¶
func SetBackendBck ¶
func SetClusterConfigUsingMsg ¶
func SetClusterConfigUsingMsg(t *testing.T, toUpdate *cmn.ConfigToUpdate)
func ShortSkipf ¶
func WaitForBucket ¶
waitForBucket waits until all targets ack having ais bucket created or deleted
func WaitForClusterState ¶
func WaitForClusterState(proxyURL, reason string, origVer int64, pcnt, tcnt int, ignoreIDs ...string) (*cluster.Smap, error)
WaitForClusterState waits until a cluster reaches specified state, meaning: - smap has version larger than origVersion - number of active proxies is equal proxyCnt, unless proxyCnt == 0 - number of active targets is equal targetCnt, unless targetCnt == 0.
It returns the smap which satisfies those requirements. NOTE: Upon successful return from this function cluster state might have already changed.
func WaitForClusterStateActual ¶
func WaitForClusterStateActual(proxyURL, reason string, origVersion int64, proxyCnt, targetCnt int, syncIgnoreIDs ...string) (*cluster.Smap, error)
WaitForClusterStateActual waits until a cluster reaches specified state, meaning: - smap has version larger than origVersion - number of proxies in Smap is equal proxyCnt, unless proxyCnt == 0 - number of targets in Smap is equal targetCnt, unless targetCnt == 0.
It returns the smap which satisfies those requirements.
func WaitForDSortToFinish ¶
WaitForDSortToFinish waits until all dSorts jobs finished without failure or all jobs abort.
func WaitForNewSmap ¶
func WaitForRebalAndResil ¶
TODO -- FIXME: revise and rewrite
Waits for both resilver and rebalance to complete. If they were not started, this function treats them as completed and returns. If timeout set, if any of rebalances doesn't complete before timeout the function ends with fatal.
func WaitForRebalanceByID ¶
func WaitForResilvering ¶
func WaitNodeAdded ¶
func WaitNodeReady ¶
func WaitNodeReady(url string, opts ...*WaitRetryOpts) (err error)
Types ¶
type ClusterType ¶
type ClusterType string
const ( ClusterTypeLocal ClusterType = "local" ClusterTypeDocker ClusterType = "docker" ClusterTypeK8s ClusterType = "k8s" )
Cluster type used for test
type ContentTypeDesc ¶
type DirTreeDesc ¶
type DirTreeDesc struct { InitDir string // Directory where the tree is created (can be empty). Dirs int // Number of (initially empty) directories at each depth (we recurse into single directory at each depth). Files int // Number of files at each depth. Depth int // Depth of tree/nesting. Empty bool // Determines if there is a file somewhere in the directories. }
type E2EFramework ¶
type E2EFramework struct { Dir string Vars map[string]string // Custom variables passed to input and output files. }
func (*E2EFramework) RunE2ETest ¶
func (f *E2EFramework) RunE2ETest(fileName string)
type ObjectsDesc ¶
type ObjectsDesc struct { CTs []ContentTypeDesc // Content types which are interesting for the test. MountpathsCnt int // Number of mountpaths to be created. ObjectSize int64 }
type ObjectsOut ¶
type ObjectsOut struct { Dir string T cluster.Target Bck cmn.Bck FQNs map[string][]string // ContentType => FQN MpathObjectsCnt map[string]int // mpath -> # objects on the mpath }
func PrepareObjects ¶
func PrepareObjects(t *testing.T, desc ObjectsDesc) *ObjectsOut
type PutObjectsArgs ¶
type RestoreCmd ¶
command used to restore a node
func GetRestoreCmd ¶
func GetRestoreCmd(si *cluster.Snode) RestoreCmd
func ShutdownNode ¶
func ShutdownNode(_ *testing.T, bp api.BaseParams, node *cluster.Snode) (pid int, cmd RestoreCmd, err error)
type SkipTestArgs ¶
type WaitRetryOpts ¶
Directories ¶
Path | Synopsis |
---|---|
Package archive provides common low-level utilities for testing archives
|
Package archive provides common low-level utilities for testing archives |
Package cryptorand
|
Package cryptorand |
Packager docker provides common utilities for managing containerized AIS deployments
|
Packager docker provides common utilities for managing containerized AIS deployments |
Package readers provides implementation for common reader types
|
Package readers provides implementation for common reader types |
Package tassert provides common asserts for tests
|
Package tassert provides common asserts for tests |
Package tetl provides helpers for ETL.
|
Package tetl provides helpers for ETL. |
Package tlog provides common logf and logln primitives for dev tools
|
Package tlog provides common logf and logln primitives for dev tools |
Package trand provides random string for dev tools and tests
|
Package trand provides random string for dev tools and tests |