framework

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

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

View Source
const (
	ConfigFileName   = "config.yaml"
	ConfigNGFileName = "config-ng.yaml"
	ConfigFileDir    = ".config/tanzu/"
)
View Source
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"
)
View Source
const (
	DefaultCLIPluginBucket = "/tkg/tanzu_core/tanzu-cli-plugins/"
	DefaultRegistryName    = "registry"
	DefaultRegistryPort    = "5001"
)
View Source
const GeneratedValuesTemplate = `#@data/values
#@overlay/match-child-defaults missing_ok=True

---`
View Source
const ImagesTemplate = `---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
kind: ImagesLock`
View Source
const ScriptBasedPluginTemplate = `` /* 491-byte string literal not displayed */

Variables

View Source
var TestDirPath string
View Source
var TestPluginsDirPath string
View Source
var TestStandalonePluginsPath string

Functions

func CLICoreDescribe

func CLICoreDescribe(text string, body func()) bool

CLICoreDescribe annotates the test with the CLICore label.

func ContainsAnyString

func ContainsAnyString(stdOut *bytes.Buffer, contains []string) error

ContainsAnyString checks that the given buffer contains any of the given set of strings.

func ContainsString

func ContainsString(stdOut *bytes.Buffer, contains string) error

ContainsString checks that the given buffer contains the string.

func CreateDir

func CreateDir(dir string) error

CreateDir creates directory if not exists

func NotContainsString

func NotContainsString(stdOut *bytes.Buffer, contains string) error

NotContainsString checks that the given buffer not contains the string if contains then throws error.

func RandomString

func RandomString(length int) string

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

func NewCliOps

func NewCliOps() CliOps

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

func NewCmdOps

func NewCmdOps() CmdOps

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 DiscoveryOptions struct {
	Name       string
	SourceType string
	URI        string
}

type Docker

type Docker interface {
	ContainerRuntime
}

Docker is the container runtime of type docker

func NewDocker

func NewDocker() 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 PluginListInfo struct {
	Description string `json:"description"`
	Discovery   string `json:"discovery"`
	Name        string `json:"name"`
	Scope       string `json:"scope"`
	Status      string `json:"status"`
	Version     string `json:"version"`
}

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

Jump to

Keyboard shortcuts

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