testutils

package
v5.6.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BookPath = "./resources/books/"
View Source
var BookTitles = []string{"beowulf.txt", "sherlock_holmes.txt", "tale_of_two_cities.txt", "ulysses.txt"}

Functions

func CancelAllJobsForBucket

func CancelAllJobsForBucket(client *ds3.Client, bucketName string)

func ConvertBooksToDs3Objects

func ConvertBooksToDs3Objects(books map[string]models.ReaderWithSizeDecorator) ([]models.Ds3PutObject, error)

func ConvertObjectsIntoObjectNameList

func ConvertObjectsIntoObjectNameList(objects []models.Contents) []string

func DeleteBucket

func DeleteBucket(client *ds3.Client, bucketName string) error

Deletes the specified bucket and returns an error if one occurs

func DeleteBucketContents

func DeleteBucketContents(client *ds3.Client, bucketName string)

func DeleteBucketLogError

func DeleteBucketLogError(t *testing.T, client *ds3.Client, bucketName string) error

Deletes the specified bucket. If an error occurs, it is logged, and the calling test is marked as failed.

func DeleteDataPolicyLogError

func DeleteDataPolicyLogError(t *testing.T, client *ds3.Client, dataPolicyId string) error

Deletes the specified data policy. If an error occurs, it is logged, and the calling test is marked as failed, but continues running.

func DeleteObject

func DeleteObject(client *ds3.Client, bucketName string, objectName string) error

Deletes the specified object. Returns an error if not successful.

func DeleteObjectLogError

func DeleteObjectLogError(t *testing.T, client *ds3.Client, bucketName string, objectName string) error

Deletes the specified object. If an error occurs, it is logged, and the calling test is marked as failed.

func GetBucket

func GetBucket(client *ds3.Client, bucketName string) (*models.GetBucketResponse, error)

Retrieves the specified bucket. Returns an error if unsuccessful.

func GetBucketLogError

func GetBucketLogError(t *testing.T, client *ds3.Client, bucketName string) (*models.GetBucketResponse, error)

Retrieves the specified bucket. If an error occurs, it is logged, and the calling test is marked as failed.

func GetDataPolicyLogError

func GetDataPolicyLogError(t *testing.T, client *ds3.Client, dataPolicyId string) (*models.GetDataPolicySpectraS3Response, error)

Retrieves the specified data policy. If an error occurs, it is logged, and the calling test is marked as failed, but continues running

func GetObject

func GetObject(client *ds3.Client, bucketName string, objectName string) (*models.GetObjectResponse, error)

Retrieves the specified object. Returns an error if not successful.

func GetObjectLogError

func GetObjectLogError(t *testing.T, client *ds3.Client, bucketName string, objectName string) (*models.GetObjectResponse, error)

Retrieves the specified object. If an error occurs, it is logged, and the calling test is marked as failed.

func GetResourceBookAsStream

func GetResourceBookAsStream(book string) (*models.ReadCloserWithSizeDecorator, error)

func GetResourceBooks

func GetResourceBooks() (map[string]models.ReaderWithSizeDecorator, error)

func GetUserByNameLogError

func GetUserByNameLogError(t *testing.T, client *ds3.Client, userName string) (*models.SpectraUser, error)

Retrieves the specified user by name. Expects there to be one user with the specified name. If there is not exactly 1 user with the specified name, it is treated as an error. If an error occurs, it is logged, and the calling test is marked as failed, but continues running.

func LoadBook

func LoadBook(book string) ([]byte, error)

Loads the specified book. Assumes that the book is located in the /resources/books/ folder.

func LoadBookLogError

func LoadBookLogError(t *testing.T, book string) ([]byte, error)

Loads the specified book. If an error occurs, it is logged, and the calling test is marked as failed.

func PutBucket

func PutBucket(client *ds3.Client, bucketName string) error

Puts the specified bucket. Returns an error if not successful.

func PutBucketLogError

func PutBucketLogError(t *testing.T, client *ds3.Client, bucketName string) error

Puts the specified bucket. If an error occurs, it is logged, and the calling test is marked as failed.

func PutDataPolicyLogError

func PutDataPolicyLogError(t *testing.T, client *ds3.Client, dataPolicyName string) (*models.PutDataPolicySpectraS3Response, error)

Creates the specified data policy. If an error occurs, it is logged, and the calling test is marked as failed, but continues running.

func PutEmptyObjects

func PutEmptyObjects(client *ds3.Client, bucketName string, objects []models.Ds3PutObject) error

func PutObject

func PutObject(client *ds3.Client, bucketName string, objectName string, data []byte) error

Puts the specified object. Returns an error if not successful.

func PutObjectLogError

func PutObjectLogError(t *testing.T, client *ds3.Client, bucketName string, objectName string, data []byte) error

Puts the specified object. If an error occurs, it is logged, and the calling test is marked as failed.

func PutObjectWithJobId

func PutObjectWithJobId(client *ds3.Client, bucketName string, objectName string, jobId string, data []byte) error

Puts the specified object. Returns an error if not successful.

func PutTestBooks

func PutTestBooks(client *ds3.Client, bucketName string) error

Puts the test books onto the BP

func TeardownTestEnv

func TeardownTestEnv(client *ds3.Client, ids *TestIds, testBucket string)

Tears down the test environment by deleting all contents in the test bucket and deleting all items created in SetupTestEnv

func VerifyBookContent

func VerifyBookContent(t *testing.T, bookName string, actual io.ReadCloser)

func VerifyFilesOnBP

func VerifyFilesOnBP(t *testing.T, bucketName string, objectNames []string, filePath string, client *ds3.Client)

Retrieves the specified objects from the BP bucket and compares the content to to local files. Assumes that local file names and BP object names are the same.

func VerifyPartialFile

func VerifyPartialFile(t *testing.T, filePath string, length int64, offset int64, actual io.Reader)

Types

type TestIds

type TestIds struct {
	DataPersistenceRuleId *string
	DataPolicyId          *string
	OriginalDataPolicyId  *string
	PoolPartitionId       *string
	StorageDomainId       *string
	StorageDomainMemberId *string
	UserId                *string
}

Used to keep track of all IDs for items created in SetupTestEnv, and used in TeardownTestEnv. Items that have not been initialized are represented with nil, denoting no teardown is required for that element.

func SetupTestEnv

func SetupTestEnv(testBucket string, userName string, envTestNameSpace string) (*ds3.Client, *TestIds, error)

Sets up the test environment by 1) creating a client from environment variables and 2) creating a test bucket 3) creating new data policy 4) setting default user to use new data policy 5) crating a pool partition 6) creating a storage domain 7) creating a storage domain member 8) creating a data persistence rule

Jump to

Keyboard shortcuts

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