sessiontest

package
v0.0.0-...-308df95 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-2-Clause, BSD-3-Clause, LGPL-2.1, + 2 more Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SetPass    = false
	SetFail    = true
	CommitPass = true
	CommitFail = false
)

For some operations, 'false' indicates pass, whereas in others, 'true' does. Hide this mess with some enumerated values.

View Source
const (
	NotConfigdUser    = false
	ConfigdUser       = true
	NotInSecretsGroup = false
	InSecretsGroup    = true
)
View Source
const (
	CommitDebugOff = false
	CommitDebugOn  = true
	NoCfgCheck     = false
	CfgCheck       = true
)

Variables

This section is empty.

Functions

func DisableStackLog

func DisableStackLog()

func EnableStackLog

func EnableStackLog()

func TstStartup

func TstStartup(t *testing.T, schema, config string) (*TstSrv, *Session)

Test startup with default authentication settings

func TstStartupMultipleSchemas

func TstStartupMultipleSchemas(
	t *testing.T,
	schemaDefs []TestSchema,
	config string,
) (*TstSrv, *Session)

func TstStartupMultipleSchemasWithCustomAuth

func TstStartupMultipleSchemasWithCustomAuth(
	t *testing.T,
	schemaDefs []TestSchema,
	config string,
	a auth.Auther,
	isConfigdUser, inSecretsGroup bool,
) (*TstSrv, *Session)

func TstStartupSchemaDir

func TstStartupSchemaDir(t *testing.T, schemaDir, config, capabilities string) (*TstSrv, *Session)

func TstStartupWithCapabilities

func TstStartupWithCapabilities(t *testing.T, schema, config, caps string) (*TstSrv, *Session)

Test startup with default authentication settings

func TstStartupWithCustomAuth

func TstStartupWithCustomAuth(
	t *testing.T,
	schema, config string,
	a auth.Auther,
	isConfigdUser, inSecretsGroup bool,
) (*TstSrv, *Session)

func ValidateChanged

func ValidateChanged(t *testing.T, sess *Session, ctx *configd.Context, exp bool)

func ValidateCommit

func ValidateCommit(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	expPass bool,
	expOut ...string,
)

func ValidateCommitMultipleOutput

func ValidateCommitMultipleOutput(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	expPass bool,
	expCfg string,
	expOut []string,
)

func ValidateCommitWithDebug

func ValidateCommitWithDebug(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	expPass bool,
	expCfg string,
	expOut []string,
	expDebug string,
)

func ValidateDelete

func ValidateDelete(t *testing.T, sess *Session, ctx *configd.Context, path []string, exp bool)

exp is whether we expect an error or not (i.e., true means expect error)

func ValidateDeleteTable

func ValidateDeleteTable(t *testing.T, sess *Session, ctx *configd.Context, tbl []ValidateOpTbl)

func ValidateExists

func ValidateExists(t *testing.T, sess *Session, ctx *configd.Context, path []string, exp bool)

func ValidateOperationTable

func ValidateOperationTable(t *testing.T, sess *Session, ctx *configd.Context, tbl []ValidateOpTbl, op Operation)

func ValidateSessOpOutput

func ValidateSessOpOutput(t *testing.T, sess *Session, ctx *configd.Context, exp bool, expOut string, op SessOp)

Do a session operation and validate the output received againt the expected output

func ValidateSet

func ValidateSet(t *testing.T, sess *Session, ctx *configd.Context, path []string, exp bool)

func ValidateSetPath

func ValidateSetPath(t *testing.T, sess *Session, ctx *configd.Context, path []string, exp bool)

exp is whether we expect an error or not (i.e., true means expect error)

func ValidateSetPathTable

func ValidateSetPathTable(t *testing.T, sess *Session, ctx *configd.Context, tbl []ValidateOpTbl)

func ValidateSetTable

func ValidateSetTable(t *testing.T, sess *Session, ctx *configd.Context, tbl []ValidateOpTbl)

func ValidateShow

func ValidateShow(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	path []string,
	hideSecrets bool,
	expectedCfgOrError string,
	expectCfgPresent bool,
)

func ValidateShowContains

func ValidateShowContains(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	path []string,
	hideSecrets bool,
	expectCfgPresent bool,
	expectedToContain ...string,
)

func ValidateShowWithDefaults

func ValidateShowWithDefaults(
	t *testing.T,
	sess *Session,
	ctx *configd.Context,
	path []string,
	hideSecrets bool,
	expectedCfgOrError string,
	expectCfgPresent bool,
)

func ValidateStatus

func ValidateStatus(t *testing.T, sess *Session, ctx *configd.Context, exp ValidateStatusTbl)

func ValidateTestSchemaSnippet

func ValidateTestSchemaSnippet(t *testing.T, schema string,
) (schema.ModelSet, schema.ModelSet, error)

Types

type NameDef

type NameDef struct {
	Namespace string
	Prefix    string
}

type Operation

type Operation int
const (
	SET Operation = iota
	SET_PATH
	DELETE
	SET_AND_COMMIT
	DELETE_AND_COMMIT
)

type SessOp

type SessOp int
const (
	COMMIT SessOp = iota
	VALIDATE
)

func (SessOp) String

func (s SessOp) String() string

type TestSchema

type TestSchema struct {
	Name          NameDef
	Imports       []NameDef
	Includes      []string
	BelongsTo     NameDef
	Prefix        string
	SchemaSnippet string
}

Used for creating tests with multiple modules without resorting to reading them in from file as this means you can't read the schema and the test together easily.

func NewTestSchema

func NewTestSchema(namespace, prefix string) *TestSchema

func (*TestSchema) AddBelongsTo

func (ts *TestSchema) AddBelongsTo(namespace, prefix string) *TestSchema

func (*TestSchema) AddImport

func (ts *TestSchema) AddImport(namespace, prefix string) *TestSchema

func (*TestSchema) AddInclude

func (ts *TestSchema) AddInclude(module string) *TestSchema

func (*TestSchema) AddSchemaSnippet

func (ts *TestSchema) AddSchemaSnippet(snippet string) *TestSchema

type TestSpec

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

func NewTestSpec

func NewTestSpec(t *testing.T) *TestSpec

func (*TestSpec) CheckCompLogEntries

func (ts *TestSpec) CheckCompLogEntries(
	name, filter string,
	entries ...schema.TestLogEntry,
)

Checks exact match for number and order of entries, after filtering for given specific type of log entry (eg SetRunning)

func (*TestSpec) ClearCompLogEntries

func (ts *TestSpec) ClearCompLogEntries()

func (*TestSpec) GetCompMgr

func (ts *TestSpec) GetCompMgr() schema.ComponentManager

func (*TestSpec) Init

func (ts *TestSpec) Init() (*TstSrv, *Session)

func (*TestSpec) SetAuther

func (ts *TestSpec) SetAuther(
	auther auth.Auther,
	isConfigdUser bool,
	inSecretsGroup bool,
) *TestSpec

func (*TestSpec) SetCapabilities

func (ts *TestSpec) SetCapabilities(caps string) *TestSpec

func (*TestSpec) SetComponents

func (ts *TestSpec) SetComponents(msName string, comps []string) *TestSpec

func (*TestSpec) SetConfig

func (ts *TestSpec) SetConfig(config string) *TestSpec

func (*TestSpec) SetCurrentState

func (ts *TestSpec) SetCurrentState(model, stateJson string)

func (*TestSpec) SetSchemaDefs

func (ts *TestSpec) SetSchemaDefs(schemaDefs []TestSchema) *TestSpec

func (*TestSpec) SetSchemaDefsByRef

func (ts *TestSpec) SetSchemaDefsByRef(schemaDefs []*TestSchema) *TestSpec

When we have created schemaDefs using NewTestSchema, it is easier to pass by reference.

func (*TestSpec) SetSchemaDir

func (ts *TestSpec) SetSchemaDir(schemaDir string) *TestSpec

func (*TestSpec) SetSessionMgrLog

func (ts *TestSpec) SetSessionMgrLog(smgrLog *bytes.Buffer) *TestSpec

func (*TestSpec) SetSingleSchema

func (ts *TestSpec) SetSingleSchema(singleSchema string) *TestSpec

type TstSrv

type TstSrv struct {
	Ms     schema.ModelSet
	MsFull schema.ModelSet
	Smgr   *SessionMgr
	Cmgr   *CommitMgr
	Auth   auth.Auther
	Dlog   *log.Logger
	Elog   *log.Logger
	Wlog   *log.Logger
	Ctx    *configd.Context
	// contains filtered or unexported fields
}

loosely modelled on Srv from configd/server/server.go

func (*TstSrv) Cleanup

func (ts *TstSrv) Cleanup()

Clean up any resources that we created, but no longer need

func (*TstSrv) LoadConfig

func (ts *TstSrv) LoadConfig(t *testing.T, config string, sess *Session)

type ValidateOpTbl

type ValidateOpTbl struct {
	Description string
	Path        []string
	Value       string
	Result      bool // result of commit if requested, otherwise, set/delete
}

func NewValOpTblEntry

func NewValOpTblEntry(
	desc string,
	path []string,
	value string,
	result bool) ValidateOpTbl

type ValidateStatusTbl

type ValidateStatusTbl struct {
	Path   []string
	Status rpc.NodeStatus
	Err    bool
}

func NewValStatusTblEntry

func NewValStatusTblEntry(
	path []string,
	status rpc.NodeStatus,
	err bool) ValidateStatusTbl

Jump to

Keyboard shortcuts

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