Documentation
¶
Overview ¶
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package tools provides common tools and utilities for all unit and integration tests
- Copyright (c) 2018-2025, 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, na, nd 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 *meta.Snode)
- func CreateBucket(tb testing.TB, proxyURL string, bck cmn.Bck, props *cmn.BpropsToSet, ...)
- 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 *meta.Snode, conf *cmn.Config, localConf *cmn.LocalConfig) int
- func DestroyBucket(tb testing.TB, proxyURL string, bck cmn.Bck)
- func DisableRebalance(t *testing.T)
- func EnableRebalance(t *testing.T)
- 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, lst []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 *meta.Smap) string
- func GetClusterConfig(t *testing.T) (config *cmn.Config)
- func GetClusterMap(tb testing.TB, url string) *meta.Smap
- func GetClusterStats(t *testing.T, proxyURL string) stats.Cluster
- func GetDaemonConfig(t *testing.T, node *meta.Snode) *cmn.Config
- func GetICProxy(t testing.TB, smap *meta.Smap, ignoreID string) *meta.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) (*meta.Snode, error)
- func GetPrimaryURL() string
- func GetProxyReadiness(proxyURL string) error
- func GetTargetsMountpaths(t *testing.T, smap *meta.Smap, params api.BaseParams) map[*meta.Snode][]string
- func InitCluster(proxyURL string, clusterType ClusterType) (err error)
- func InitLocalCluster()
- func JoinCluster(proxyURL string, node *meta.Snode) (string, error)
- func ListObjectNames(proxyURL string, bck cmn.Bck, prefix string, objectCountLimit int64, ...) ([]string, error)
- func ModifyLOM(t *testing.T, fqn string, bck cmn.Bck, modify func(*testing.T, *core.LOM))
- 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 RemoveNodeUnsafe(proxyURL, sid string) error
- func RestoreNode(cmd RestoreCmd, asPrimary bool, tag string) error
- func RestoreTarget(t *testing.T, proxyURL string, target *meta.Snode) (rebID string, newSmap *meta.Smap)
- func RmTargetSkipRebWait(t *testing.T, proxyURL string, smap *meta.Smap) (*meta.Smap, *meta.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.ConfigToSet)
- func SetRemAisConfig(t *testing.T, nvs cos.StrKVs)
- func SetXattrCksum(fqn string, bck cmn.Bck, cksum *cos.Cksum) error
- func ShortSkipf(tb testing.TB, a ...any)
- func WaitForClusterState(proxyURL, reason string, origVer int64, pcnt, tcnt int, ignoreIDs ...string) (*meta.Smap, error)
- func WaitForClusterStateActual(proxyURL, reason string, origVersion int64, proxyCnt, targetCnt int, ...) (*meta.Smap, error)
- func WaitForDsortToFinish(proxyURL, managerUUID string) (allAborted bool, err error)
- func WaitForNewSmap(proxyURL string, prevVersion int64) (newSmap *meta.Smap, err error)
- func WaitForObjectToBeDowloaded(bp api.BaseParams, bck cmn.Bck, objName string, timeout time.Duration) error
- func WaitForPID(pid int) error
- func WaitForRebalAndResil(t testing.TB, bp api.BaseParams, timeouts ...time.Duration)
- func WaitForRebalanceByID(t *testing.T, bp api.BaseParams, rebID string, timeouts ...time.Duration)
- func WaitForResilvering(t *testing.T, bp api.BaseParams, target *meta.Snode)
- func WaitNodeAdded(bp api.BaseParams, nodeID string) (*meta.Smap, error)
- func WaitNodePubAddrNotInUse(si *meta.Snode, timeout time.Duration) error
- func WaitNodeReady(url string, opts ...*WaitRetryOpts) (err error)
- type ClusterType
- type ContentTypeDesc
- type DirTreeDesc
- type E2EFramework
- type ObjectsDesc
- type ObjectsOut
- type PutObjectsArgs
- type RestoreCmd
- type SkipTestArgs
- type WaitRetryOpts
Constants ¶
const ( WaitClusterStartup = 20 * time.Second RebalanceStartTimeout = 10 * time.Second MaxCplaneTimeout = 10 * time.Second CopyBucketTimeout = 3 * time.Minute MultiProxyTestTimeout = 3 * time.Minute DsortFinishTimeout = 6 * time.Minute RebalanceTimeout = 2 * time.Minute EvictPrefetchTimeout = 2 * time.Minute BucketCleanupTimeout = time.Minute )
times and timeouts
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 ¶
var ( RemoteCluster struct { UUID string Alias string URL string } LoggedUserToken string )
var ErrTimedOutStabilize = errors.New("timed out waiting for the cluster to stabilize")
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 *meta.Snode)
func CreateBucket ¶ added in v1.3.19
func CreateFileFromReader ¶
func DeployNode ¶
func DestroyBucket ¶
is usually called to cleanup (via tb.Cleanup)
func DisableRebalance ¶ added in v1.3.24
func EnableRebalance ¶ added in v1.3.24
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 *meta.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 `RemoveNodeUnsafe`
func ListObjectNames ¶
func ListObjectNames(proxyURL string, bck cmn.Bck, prefix string, objectCountLimit int64, 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 RemoveNodeUnsafe ¶ added in v1.3.18
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 *meta.Snode) (rebID string, newSmap *meta.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.ConfigToSet)
func ShortSkipf ¶
func WaitForClusterState ¶
func WaitForClusterState(proxyURL, reason string, origVer int64, pcnt, tcnt int, ignoreIDs ...string) (*meta.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) (*meta.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 ¶ added in v1.3.21
WaitForDsortToFinish waits until all dSorts jobs finished without failure or all jobs abort.
func WaitForNewSmap ¶
func WaitForPID ¶ added in v1.3.21
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 WaitNodePubAddrNotInUse ¶ added in v1.3.20
as the name implies
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. FileSize int64 // Size of each file. 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 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 *meta.Snode) RestoreCmd
func ShutdownNode ¶
func ShutdownNode(_ *testing.T, bp api.BaseParams, node *meta.Snode) (pid int, cmd RestoreCmd, rebID string, err error)
type SkipTestArgs ¶
type WaitRetryOpts ¶
Directories
¶
Path | Synopsis |
---|---|
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 archive provides common low-level utilities for testing archives
|
Package archive provides common low-level utilities for testing archives |
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 |