Documentation ¶
Index ¶
- Constants
- Variables
- func AddConfiguredMover(ctx *ScenarioContext, name string) error
- func ConfigureAgent(ctx *ScenarioContext) error
- func StartAgent(ctx *ScenarioContext) error
- func StopAgent(ctx *ScenarioContext) error
- func WriteAgentConfig(ctx *ScenarioContext) error
- type AgentDriver
- type Config
- type FileChecksum
- type HsmDriver
- type HsmState
- type ScenarioContext
- func (s *ScenarioContext) AddCleanup(fn cleanupFn)
- func (s *ScenarioContext) Cleanup() error
- func (ctx *ScenarioContext) CreateTestfile(dir, key string) (string, error)
- func (s *ScenarioContext) Fail()
- func (s *ScenarioContext) Failed() bool
- func (s *ScenarioContext) GetKey(key string) (string, error)
- func (s *ScenarioContext) SetKey(key, value string)
- func (s *ScenarioContext) Workdir() string
- type TestFile
Constants ¶
const ( // HsmAgentCfgKey refers to this context's agent config file HsmAgentCfgKey = "agent_config_key" // HsmAgentBinary is the name of the HSM Agent HsmAgentBinary = "lhsmd.race" // HsmPluginPrefix is the base name of data mover plugins HsmPluginPrefix = "lhsm-plugin-" )
const ( // UATConfigFile is the name of the harness configuration file UATConfigFile = ".lhsmd-test" // UATConfigEnvVar is the name of the optional environment variable that // may be set to specify config location UATConfigEnvVar = "LHSMD_UAT_CONFIG_FILE" )
Variables ¶
var HsmDrivers = map[string]driverConstructor{"lfs": LfsDriver}
HsmDrivers is a map of HSM driver names to their driver constructor functions.
Functions ¶
func AddConfiguredMover ¶
func AddConfiguredMover(ctx *ScenarioContext, name string) error
AddConfiguredMover adds a data mover to the agent configuration
func ConfigureAgent ¶
func ConfigureAgent(ctx *ScenarioContext) error
ConfigureAgent creates or updates the Context's agent config
func StartAgent ¶
func StartAgent(ctx *ScenarioContext) error
StartAgent starts the configured agent
func WriteAgentConfig ¶
func WriteAgentConfig(ctx *ScenarioContext) error
WriteAgentConfig writes the agent configuration into the workdir
Types ¶
type AgentDriver ¶
type AgentDriver struct {
// contains filtered or unexported fields
}
AgentDriver allows the harness to drive an HSM agent
func (*AgentDriver) AgentPid ¶
func (ad *AgentDriver) AgentPid() (int, error)
AgentPid returns the pid of the running agent, if available
type Config ¶
type Config struct { HsmDriver string `hcl:"hsm_driver" json:"hsm_driver"` LustrePath string `hcl:"lustre_path" json:"lustre_path"` CleanupOnFailure bool `hcl:"cleanup_on_failure" json:"cleanup_on_failure"` EnableAgentDebug bool `hcl:"enable_agent_debug" json:"enable_agent_debug"` AWSAccessKeyID string `hcl:"aws_access_key_id" json:"aws_access_key_id"` AWSSecretAccessKey string `hcl:"aws_secret_access_key" json:"aws_secret_access_key"` S3Region string `hcl:"s3_region" json:"s3_region"` S3Endpoint string `hcl:"s3_endpoint" json:"s3_endpoint"` S3Bucket string `hcl:"s3_bucket" json:"s3_bucket"` S3Prefix string `hcl:"s3_prefix" json:"s3_prefix"` }
Config holds configuration for the test harness
func LoadConfig ¶
LoadConfig attempts to load a config from one of the default locations
func NewConfig ¶
func NewConfig() *Config
NewConfig initializes a new Config instance with default values
type FileChecksum ¶
type FileChecksum [20]byte
FileChecksum is a calculated checksum
func GetFileChecksum ¶
func GetFileChecksum(filePath string) (FileChecksum, error)
GetFileChecksum returns a checksum of the file's data
type HsmDriver ¶
type HsmDriver interface { // Archive store's the file's data in the archive backend Archive(string) error // Restore explicitly restores the file Restore(string) error // Remove removes the restored file from the archive backend Remove(string) error // Release releases the archived file's space on the filesystem Release(string) error // GetState returns the HsmState for the file GetState(string) (HsmState, error) }
HsmDriver defines an interface to be implemented by a HSM tool driver e.g. lfs hsm_*, ldmc, etc.
func NewMultiHsmDriver ¶
func NewMultiHsmDriver() HsmDriver
NewMultiHsmDriver returns an implementation of HsmDriver which finds an available HSM driver according to the preferred order.
type HsmState ¶
type HsmState string
HsmState indicates the file's status
const ( // HsmUnknown indicates that the file state is unknown HsmUnknown HsmState = "unknown" // HsmUnmanaged indicates that the file is not managed by HSM HsmUnmanaged HsmState = "unmanaged" // HsmUnarchived indicates that the file is managed but unarchived HsmUnarchived HsmState = "unarchived" // HsmArchived indicates that the file is archived HsmArchived HsmState = "archived" // HsmReleased indicates that the file is archived and released HsmReleased HsmState = "released" )
type ScenarioContext ¶
type ScenarioContext struct { sync.Mutex HsmDriver HsmDriver AgentDriver *AgentDriver Config *Config TestFiles map[string]*TestFile // These are per-scenario, unless otherwise configured S3Bucket string S3Prefix string // contains filtered or unexported fields }
ScenarioContext holds per-scenario context. It should be unique for each scenario, in order to avoid leaking state between scenarios.
func NewScenarioContext ¶
func NewScenarioContext(cfg *Config) *ScenarioContext
NewScenarioContext returns a freshly-initialized *ScenarioContext
func (*ScenarioContext) AddCleanup ¶
func (s *ScenarioContext) AddCleanup(fn cleanupFn)
AddCleanup registers a cleanup handler
func (*ScenarioContext) Cleanup ¶
func (s *ScenarioContext) Cleanup() error
Cleanup runs all cleanup functions, and returns an error if any of them fail
func (*ScenarioContext) CreateTestfile ¶
func (ctx *ScenarioContext) CreateTestfile(dir, key string) (string, error)
CreateTestfile creates a test file and adds its path to the context's cleanup queue.
func (*ScenarioContext) Failed ¶
func (s *ScenarioContext) Failed() bool
Failed returns the protected value
func (*ScenarioContext) GetKey ¶
func (s *ScenarioContext) GetKey(key string) (string, error)
GetKey attempts to get the value associated with key, or fails
func (*ScenarioContext) SetKey ¶
func (s *ScenarioContext) SetKey(key, value string)
SetKey inserts or updates a value for a given key
func (*ScenarioContext) Workdir ¶
func (s *ScenarioContext) Workdir() string
Workdir returns the path to the context's working directory, which is created as a tempdir.
type TestFile ¶
type TestFile struct { Path string Checksum FileChecksum }
TestFile describes a test file generated by the harness
func NewTestFile ¶
NewTestFile generates a new test file