Documentation
¶
Overview ¶
Copyright 2023 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Package test defines the integration and end-to-end test case for cli core ¶
Package test defines the integration and end-to-end test case for cli core ¶
Copyright 2023 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CLICoreDescribe(text string, body func()) bool
- func ContainsAnyString(stdOut *bytes.Buffer, contains []string) error
- func ContainsString(stdOut *bytes.Buffer, contains string) error
- func CreateDir(dir string) error
- func NotContainsString(stdOut *bytes.Buffer, contains string) error
- func RandomString(length int) string
- type CLIPlugin
- type CliOps
- type ClusterOps
- type CmdOps
- type ConfigLifecycleOps
- type ContainerRuntime
- type DiscoveryOptions
- type Docker
- type Framework
- type GeneratePluginOps
- type ImgpkgOps
- type KindCluster
- type PluginBasicOps
- type PluginCmdOps
- type PluginHelperOps
- type PluginListInfo
- type PluginMeta
- func (p *PluginMeta) GetName() string
- func (p *PluginMeta) GetRegistryDiscoveryURL() string
- func (p *PluginMeta) SetAliases(alias []string) *PluginMeta
- func (p *PluginMeta) SetArch(arch string) *PluginMeta
- func (p *PluginMeta) SetDescription(description string) *PluginMeta
- func (p *PluginMeta) SetDiscoveryType(discoveryType string) *PluginMeta
- func (p *PluginMeta) SetGroup(group string) *PluginMeta
- func (p *PluginMeta) SetHidden(hidden bool) *PluginMeta
- func (p *PluginMeta) SetName(name string) *PluginMeta
- func (p *PluginMeta) SetOS(OSType string) *PluginMeta
- func (p *PluginMeta) SetOptional(optional bool) *PluginMeta
- func (p *PluginMeta) SetSHA(sha string) *PluginMeta
- func (p *PluginMeta) SetTarget(target string) *PluginMeta
- func (p *PluginMeta) SetVersion(version string) *PluginMeta
- type PluginRegistry
- type PluginSourceOps
- type PublishPluginOps
Constants ¶
const ( ConfigFileName = "config.yaml" ConfigNGFileName = "config-ng.yaml" ConfigFileDir = ".config/tanzu/" )
const ( CliCore = "[CLI-Core]" TanzuInit = "tanzu init" TanzuVersion = "tanzu version" ConfigSet = "tanzu config set " ConfigGet = "tanzu config get " ConfigUnset = "tanzu config unset " ConfigInit = "tanzu config init" ConfigServerList = "tanzu config server list" ConfigServerDelete = "tanzu config server delete " AddPluginSource = "tanzu plugin source add --name %s --type %s --uri %s" DeletePluginSource = "tanzu plugin source delete %s" ListPluginsCmd = "tanzu plugin list -o json" KindCreateCluster = "kind create cluster --name " DockerInfo = "docker info" StartDockerUbuntu = "sudo systemctl start docker" StopDockerUbuntu = "sudo systemctl stop docker" TestDir = ".tanzu-cli-e2e" TestPluginsDir = ".e2e-test-plugins" HackToolsBinDir = "/../../../hack/tools/bin" TanzuBinDir = "/../../../bin" )
const ( DefaultCLIPluginBucket = "/tkg/tanzu_core/tanzu-cli-plugins/" DefaultRegistryName = "registry" DefaultRegistryPort = "5001" )
const GeneratedValuesTemplate = `#@data/values
#@overlay/match-child-defaults missing_ok=True
---`
const ImagesTemplate = `---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
kind: ImagesLock`
const ScriptBasedPluginTemplate = `` /* 491-byte string literal not displayed */
Variables ¶
var TestDirPath string
var TestPluginsDirPath string
var TestStandalonePluginsPath string
Functions ¶
func CLICoreDescribe ¶
CLICoreDescribe annotates the test with the CLICore label.
func ContainsAnyString ¶
ContainsAnyString checks that the given buffer contains any of the given set of strings.
func ContainsString ¶
ContainsString checks that the given buffer contains the string.
func NotContainsString ¶
NotContainsString checks that the given buffer not contains the string if contains then throws error.
func RandomString ¶
RandomString generates random string of given length
Types ¶
type CLIPlugin ¶
type CLIPlugin struct {
metav1.TypeMeta `yaml:",inline"`
Metadata metav1.ObjectMeta `json:"metadata"`
Spec cliv1alpha1.CLIPluginSpec `json:"spec"`
}
CLIPlugin for plugin overlay info
type CliOps ¶
type CliOps interface {
CliInit() error
CliVersion() (string, error)
InstallCLI(version string) error
UninstallCLI(version string) error
}
CliOps performs basic cli operations
type ClusterOps ¶
type ClusterOps interface {
CreateCluster(name string, args []string) (output string, err error)
DeleteCluster(name string, args []string) (output string, err error)
ClusterStatus(name string, args []string) (output string, err error)
}
ClusterOps has helper operations to perform on cluster
type CmdOps ¶
type CmdOps interface {
Exec(command string) (stdOut, stdErr *bytes.Buffer, err error)
ExecContainsString(command, contains string) error
ExecContainsAnyString(command string, contains []string) error
ExecContainsErrorString(command, contains string) error
ExecNotContainsStdErrorString(command, contains string) error
ExecNotContainsString(command, contains string) error
}
CmdOps performs the Command line exec operations
type ConfigLifecycleOps ¶
type ConfigLifecycleOps interface {
ConfigSetFeatureFlag(path, value string) error
ConfigGetFeatureFlag(path string) (string, error)
ConfigUnsetFeature(path string) error
ConfigInit() error
GetConfig() (*configapi.ClientConfig, error)
ConfigServerList() error
ConfigServerDelete(serverName string) error
DeleteCLIConfigurationFiles() error
IsCLIConfigurationFilesExists() bool
}
ConfigLifecycleOps performs "tanzu config" command operations
func NewConfOps ¶
func NewConfOps() ConfigLifecycleOps
type ContainerRuntime ¶
type ContainerRuntime interface {
StartContainerRuntime() (output string, err error)
ContainerRuntimeStatus() (status string, err error)
StopContainerRuntime() (output string, err error)
}
ContainerRuntime has operations to perform on container runtime
type DiscoveryOptions ¶
type Docker ¶
type Docker interface {
ContainerRuntime
}
Docker is the container runtime of type docker
type Framework ¶
type Framework struct {
CliOps
Config ConfigLifecycleOps
ClusterOps
PluginCmd PluginCmdOps // performs plugin command operations
PluginHelper PluginHelperOps // helper (pre-setup) for plugin cmd operations
}
Framework has all helper functions to write CLI e2e test cases
func NewFramework ¶
func NewFramework() *Framework
type GeneratePluginOps ¶
type GeneratePluginOps interface {
// GeneratePluginBinaries generates plugin binaries for given plugin metadata and return generated plugin binary file paths
GeneratePluginBinaries(pluginsMeta []*PluginMeta) ([]string, []error)
}
GeneratePluginOps helps to generate script-based plugin binaries, and plugin binaries can be used to perform plugin testing like, add plugin source, list, and install plugins. And call sub-commands such as info and version.
func NewScriptBasedPlugins ¶
func NewScriptBasedPlugins() GeneratePluginOps
type ImgpkgOps ¶
type ImgpkgOps interface {
PushBinary(filepath, registryBucketURL string) (registryURL string, err error)
PushBundle(filepath, registryBucketURL string) (registryURL string, err error)
PullBinary(url string, outputPath string) (stdOut string, err error)
PullBundle(url string, outputPath string) (stdOut string, err error)
}
func NewImgpkgOps ¶
func NewImgpkgOps() ImgpkgOps
type KindCluster ¶
type KindCluster interface {
ClusterOps
}
KindCluster performs k8s KIND cluster operations
func NewKindCluster ¶
func NewKindCluster(docker Docker) KindCluster
type PluginBasicOps ¶
type PluginBasicOps interface {
// ListPlugins lists all plugins by running 'tanzu plugin list' command
ListPlugins() ([]PluginListInfo, error)
}
PluginBasicOps helps to perform the plugin command operations
type PluginCmdOps ¶
type PluginCmdOps interface {
PluginBasicOps
PluginSourceOps
}
PluginCmdOps helps to perform the plugin and its sub-commands lifecycle operations
func NewPluginLifecycleOps ¶
func NewPluginLifecycleOps() PluginCmdOps
type PluginHelperOps ¶
type PluginHelperOps interface {
GeneratePluginOps
PublishPluginOps
}
PluginHelperOps helps to generate and publish plugins
func NewPluginOps ¶
func NewPluginOps(generatePluginOps GeneratePluginOps, publishPluginOps PublishPluginOps) PluginHelperOps
type PluginListInfo ¶
type PluginMeta ¶
type PluginMeta struct {
// contains filtered or unexported fields
}
func NewPluginMeta ¶
func NewPluginMeta() *PluginMeta
func (*PluginMeta) GetName ¶
func (p *PluginMeta) GetName() string
func (*PluginMeta) GetRegistryDiscoveryURL ¶
func (p *PluginMeta) GetRegistryDiscoveryURL() string
func (*PluginMeta) SetAliases ¶
func (p *PluginMeta) SetAliases(alias []string) *PluginMeta
func (*PluginMeta) SetArch ¶
func (p *PluginMeta) SetArch(arch string) *PluginMeta
func (*PluginMeta) SetDescription ¶
func (p *PluginMeta) SetDescription(description string) *PluginMeta
func (*PluginMeta) SetDiscoveryType ¶
func (p *PluginMeta) SetDiscoveryType(discoveryType string) *PluginMeta
func (*PluginMeta) SetGroup ¶
func (p *PluginMeta) SetGroup(group string) *PluginMeta
func (*PluginMeta) SetHidden ¶
func (p *PluginMeta) SetHidden(hidden bool) *PluginMeta
func (*PluginMeta) SetName ¶
func (p *PluginMeta) SetName(name string) *PluginMeta
func (*PluginMeta) SetOS ¶
func (p *PluginMeta) SetOS(OSType string) *PluginMeta
func (*PluginMeta) SetOptional ¶
func (p *PluginMeta) SetOptional(optional bool) *PluginMeta
func (*PluginMeta) SetSHA ¶
func (p *PluginMeta) SetSHA(sha string) *PluginMeta
func (*PluginMeta) SetTarget ¶
func (p *PluginMeta) SetTarget(target string) *PluginMeta
func (*PluginMeta) SetVersion ¶
func (p *PluginMeta) SetVersion(version string) *PluginMeta
type PluginRegistry ¶
type PluginRegistry interface {
// StartRegistry starts plugin registry
StartRegistry() (url string, err error)
// StopRegistry stops plugin registry
StopRegistry() error
// IsRegistryRunning validates plugin registry status
IsRegistryRunning() (bool, error)
// GetRegistryURLWithDefaultCLIPluginsBucket returns the default registry url with default bucket for CLI plugin's
GetRegistryURLWithDefaultCLIPluginsBucket() (url string)
}
func NewLocalOCIRegistry ¶
func NewLocalOCIRegistry(registryName, port string) PluginRegistry
type PluginSourceOps ¶
type PluginSourceOps interface {
// AddPluginDiscoverySource adds plugin discovery source, and returns stdOut and error info
AddPluginDiscoverySource(discoveryOpts *DiscoveryOptions) (string, error)
// DeletePluginDiscoverySource removes the plugin discovery source, and returns stdOut and error info
DeletePluginDiscoverySource(discoveryOpts *DiscoveryOptions) (string, error)
}
PluginSourceOps helps 'plugin source' commands
type PublishPluginOps ¶
type PublishPluginOps interface {
// PublishPluginBinary publishes the plugin binaries to given registry bucket and returns the plugin distribution urls
PublishPluginBinary(pluginsInfo []*PluginMeta) (distributionUrls []string, errs []error)
// GeneratePluginBundle generates plugin bundle in local file system for given plugin metadata
GeneratePluginBundle(pluginsMeta []*PluginMeta) ([]string, []error)
// PublishPluginBundle publishes the plugin bundles to given registry bucket and returns the plugins discovery urls
PublishPluginBundle(pluginsInfo []*PluginMeta) (discoveryUrls []string, errs []error)
}
PublishPluginOps helps to publish plugin binaries and plugin bundles
func NewLocalOCIPluginOps ¶
func NewLocalOCIPluginOps(registry PluginRegistry) PublishPluginOps