core

package module
v0.0.0-...-6674c16 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 6 Imported by: 15

Documentation

Overview

Package core contains compatibility testing framework core types and functions

Index

Constants

This section is empty.

Variables

SupportedRuntimeVersions Current supported runtime library versions

Functions

func ConstructTestPluginCmd

func ConstructTestPluginCmd(version RuntimeVersion, apis []*API) (string, error)

ConstructTestPluginCmd constructs the specific runtime test plugin command as per runtime version and apis

func Exec

func Exec(command string) (stdOut, stdErr *bytes.Buffer, err error)

Exec the command, exit on error

func ParseStdout

func ParseStdout(s string) (map[RuntimeAPIName][]APILog, error)

ParseStdout convert the string represented std out log into map structure

func ParseStr

func ParseStr(val interface{}) (string, error)

ParseStr converts interface{} to string type

func SetupTempCfgFiles

func SetupTempCfgFiles() (files []*os.File, cleanup func())

SetupTempCfgFiles mock runtime config files

Types

type API

type API struct {
	Name      RuntimeAPIName                  `json:"name" yaml:"name"`
	Version   RuntimeVersion                  `json:"version" yaml:"version"`
	Arguments map[APIArgumentType]interface{} `json:"arguments" yaml:"arguments"`
	Output    *Output                         `json:"output" yaml:"output"`
}

API represents the runtime api to execute

func ParseRuntimeAPIsFromFile

func ParseRuntimeAPIsFromFile(filePath string) ([]API, error)

ParseRuntimeAPIsFromFile reads the filepath and unmarshalls the file content into array of APIs

type APIArgumentType

type APIArgumentType string

APIArgumentType describes all the arguments types required for Runtime APIs

const (
	ClientConfig    APIArgumentType = "clientConfig"
	Context         APIArgumentType = "context"
	ContextName     APIArgumentType = "contextName"
	SetCurrent      APIArgumentType = "setCurrent"
	Server          APIArgumentType = "server"
	ServerName      APIArgumentType = "serverName"
	Name            APIArgumentType = "name"
	Target          APIArgumentType = "target"
	ContextType     APIArgumentType = "contextType"
	Feature         APIArgumentType = "feature"
	Plugin          APIArgumentType = "plugin"
	Key             APIArgumentType = "key"
	Value           APIArgumentType = "value"
	DiscoverySource APIArgumentType = "discoverySource"
)

type APILog

type APILog struct {
	APIResponse *APIResponse `json:"apiResponse" yaml:"apiResponse"`
}

APILog represents the logs/output/errors returned from runtime apis in test plugins

type APIResponse

type APIResponse struct {
	ResponseType ResponseType `json:"responseType" yaml:"responseType"`
	ResponseBody interface{}  `json:"responseBody" yaml:"responseBody"`
}

APIResponse represents the output response returned from runtime apis

type Command

type Command struct {
	APIs []*API `json:"apis" yaml:"apis"`
}

Command represents the list of apis to execute as part of command execution

type Output

type Output struct {
	ValidationStrategy ValidationStrategy `json:"validationstrategy" yaml:"validationstrategy"`
	Result             Result             `json:"result" yaml:"result"`
	Content            string             `json:"content" yaml:"content"`
}

Output represents the runtime api expected output for validation

type ResponseType

type ResponseType string
const (
	MapResponse     ResponseType = "map"
	BooleanResponse ResponseType = "bool"
	StringResponse  ResponseType = "str"
	IntegerResponse ResponseType = "int"
	ErrorResponse   ResponseType = "err"
)

type Result

type Result string
const (
	Success Result = "success"
	Failed  Result = "failed"
)

type RuntimeAPIName

type RuntimeAPIName string

RuntimeAPIName describes all the Runtime APIs

const (
	SetContextAPI           RuntimeAPIName = "SetContext"
	AddContextAPI           RuntimeAPIName = "AddContext"
	GetContextAPIName       RuntimeAPIName = "GetContext"
	DeleteContextAPI        RuntimeAPIName = "DeleteContext"
	RemoveContextAPI        RuntimeAPIName = "RemoveContext"
	SetCurrentContextAPI    RuntimeAPIName = "SetCurrentContext"
	GetCurrentContextAPI    RuntimeAPIName = "GetCurrentContext"
	RemoveCurrentContextAPI RuntimeAPIName = "RemoveCurrentContext"
	GetActiveContextAPI     RuntimeAPIName = "GetActiveContext"

	SetServerAPI           RuntimeAPIName = "SetServer"
	AddServerAPI           RuntimeAPIName = "AddServer"
	PutServerAPI           RuntimeAPIName = "PutServer"
	GetServerAPI           RuntimeAPIName = "GetServer"
	DeleteServerAPI        RuntimeAPIName = "DeleteServer"
	RemoveServerAPI        RuntimeAPIName = "RemoveServer"
	SetCurrentServerAPI    RuntimeAPIName = "SetCurrentServer"
	GetCurrentServerAPI    RuntimeAPIName = "GetCurrentServer"
	RemoveCurrentServerAPI RuntimeAPIName = "RemoveCurrentServer"

	SetFeatureAPI         RuntimeAPIName = "SetFeature"
	IsFeatureEnabledAPI   RuntimeAPIName = "IsFeatureEnabled"
	IsFeatureActivatedAPI RuntimeAPIName = "IsFeatureActivated"
	DeleteFeatureAPI      RuntimeAPIName = "DeleteFeature"

	SetEnvAPI               RuntimeAPIName = "SetEnv"
	GetEnvAPI               RuntimeAPIName = "GetEnv"
	DeleteEnvAPI            RuntimeAPIName = "DeleteEnv"
	GetEnvConfigurationsAPI RuntimeAPIName = "GetEnvConfigurations"

	SetCLIDiscoverySourceAPI    RuntimeAPIName = "SetCLIDiscoverySource"
	GetCLIDiscoverySourceAPI    RuntimeAPIName = "GetCLIDiscoverySource"
	DeleteCLIDiscoverySourceAPI RuntimeAPIName = "DeleteCLIDiscoverySource"

	GetMetadataAPI                     RuntimeAPIName = "GetMetadata"
	GetConfigMetadataAPI               RuntimeAPIName = "GetConfigMetadata"
	GetConfigMetadataPatchStrategyAPI  RuntimeAPIName = "GetConfigMetadataPatchStrategy"
	SetConfigMetadataPatchStrategyAPI  RuntimeAPIName = "SetConfigMetadataPatchStrategy"
	GetConfigMetadataSettingsAPI       RuntimeAPIName = "GetConfigMetadataSettings"
	GetConfigMetadataSettingAPI        RuntimeAPIName = "GetConfigMetadataSetting"
	IsConfigMetadataSettingsEnabledAPI RuntimeAPIName = "IsConfigMetadataSettingsEnabled"
	UseUnifiedConfigAPI                RuntimeAPIName = "UseUnifiedConfig"
	DeleteConfigMetadataSettingAPI     RuntimeAPIName = "DeleteConfigMetadataSetting"
	SetConfigMetadataSettingAPI        RuntimeAPIName = "SetConfigMetadataSetting"

	GetClientConfigAPI   RuntimeAPIName = "GetClientConfig"
	StoreClientConfigAPI RuntimeAPIName = "StoreClientConfig"
)

type RuntimeAPIVersion

type RuntimeAPIVersion struct {
	RuntimeVersion RuntimeVersion `json:"runtimeVersion,omitempty" yaml:"runtimeVersion,omitempty"`
}

RuntimeAPIVersion represents the runtime library versions used in XXXOpts structs

func (*RuntimeAPIVersion) Validate

func (r *RuntimeAPIVersion) Validate() (bool, error)

Validate to verify passed version is valid and supported

type RuntimeVersion

type RuntimeVersion string

RuntimeVersion Runtime library versions

const (
	Version0116   RuntimeVersion = "v0.11.6"
	Version0254   RuntimeVersion = "v0.25.4"
	Version0280   RuntimeVersion = "v0.28.0"
	Version090    RuntimeVersion = "v0.90.0"
	Version102    RuntimeVersion = "v1.0.2"
	VersionLatest RuntimeVersion = "latest"
)

func (RuntimeVersion) IsRuntimeVersionSupported

func (version RuntimeVersion) IsRuntimeVersionSupported() bool

IsRuntimeVersionSupported check whether version is currently supported

type TestCase

type TestCase struct {
	Commands []*Command `json:"commands" yaml:"commands"`
}

TestCase represents the list of commands to execute as part of test case

func NewTestCase

func NewTestCase() *TestCase

NewTestCase creates an instance of TestCase

func (*TestCase) Add

func (t *TestCase) Add(command ...*Command) *TestCase

Add series of commands to test case to be executed in sequence

type ValidationStrategy

type ValidationStrategy string

ValidationStrategy used to describe the validation strategy. default is non-strict

const ValidationStrategyStrict ValidationStrategy = "strict"

ValidationStrategyStrict used to compare deep equality of objects

Jump to

Keyboard shortcuts

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