Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRequest(method, urlVal, data string, header map[string]string) (*http.Request, error)
- func CreateNamespace(baseName string, cli client.Client) (*v1.Namespace, error)
- func CreateSecret() error
- func CreateTestExample(test MultiUserTest) error
- func DefaultErrorFunc(resp TestResp)
- func DefaultSkipFunc() bool
- func DeleteNamespace(ns *v1.Namespace, cli client.Client) error
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- func GetAllUsersAvailable() []string
- func GetUser(user string) string
- func InitGlobalV() error
- func InitMultiConfig() error
- func IsSuccess(code int) bool
- func NameWithUser(name, user string) string
- func OutputMultiUserTestConfig(path string) error
- func PermissionErrorFunc(resp TestResp)
- func PostFile(filename string, fieldName string, target_url string, header map[string]string) (*http.Response, error)
- func Register(key string, loginFunc LoginByUser)
- func RegisterByDefault(test MultiUserTest)
- func RegisterTestAndSteps(test MultiUserTest) error
- func UserContains(user string) bool
- type AuthUser
- type GeneralLogin
- type HttpHelper
- func (h *HttpHelper) BuildRequest(method, urlVal, data, user string, header map[string]string) (*http.Request, error)
- func (h *HttpHelper) Delete(urlVal string) (*http.Response, error)
- func (h *HttpHelper) Get(urlVal string, header map[string]string) (*http.Response, error)
- func (h *HttpHelper) Login(login string) *HttpHelper
- func (h *HttpHelper) MultiUserRequest(method, url, body string, header map[string]string) map[string]MultiRequestResponse
- func (h *HttpHelper) Patch(urlVal, body string, header map[string]string) (*http.Response, error)
- func (h *HttpHelper) Post(urlVal, body string, header map[string]string) (*http.Response, error)
- func (h *HttpHelper) Put(urlVal, body string, header map[string]string) (*http.Response, error)
- func (h *HttpHelper) Request(method, urlVal, data string, header map[string]string) (*http.Response, error)
- func (h *HttpHelper) RequestByUser(method, urlVal, data, user string, header map[string]string) (*http.Response, error)
- type LoginByUser
- type MultiRequestResponse
- type MultiUserTest
- type MultiUserTestConfig
- type MultiUserTestStep
- type TestFunc
- type TestResp
Constants ¶
const ( UserAdmin = "admin" UserTenantAdmin = "tenantAdmin" UserProjectAdmin = "projectAdmin" UserNormal = "user" MultiConfig = "multiConfig.yaml" ResourceReady = "resourceReady" ResourceFailed = "resourceFailed" WorkerNum = "workerNum" )
Variables ¶
var ( // cluster TargetClusterName string PivotClusterName string // quota CubeResourceQuota string // host KubecubeHost string ConsoleHost string // tenant TenantName string ProjectName string NamespaceName string // user Admin string AdminPassword string TenantAdmin string TenantAdminPassword string ProjectAdmin string ProjectAdminPassword string User string UserPassword string // timeout WaitInterval time.Duration WaitTimeout time.Duration HttpRequestTimeout time.Duration // pv PVEnabled bool // CloudShellEnabled cloudShell CloudShellEnabled bool // workload CronJobEnable bool DaemonSetEnable bool DeploymentEnable bool JobEnable bool StatefulSetEnable bool NodeHostName string NodeHostIp string TestImage string ImagePullSecret string StorageClass string // hub Registry string Username string Password string Email string // PivotClusterClient communicate with pivot cluster PivotClusterClient client.Client // TargetClusterClient communicate with target cluster TargetClusterClient client.Client KubeCubeSystem string KubeCubeE2ECM string LoginType string )
var ( ToTestMap = make(map[string]map[string]MultiUserTestStep) TestUser []string TestConfig = make(map[string]MultiUserTest) )
var AllTestMap = make(map[string]struct{})
var ConfigHelper = make([]MultiUserTest, 0)
var SucceedResp = TestResp{ Err: nil, Data: "", }
Functions ¶
func BuildRequest ¶
func CreateNamespace ¶
CreateNamespace Create namespace
func CreateSecret ¶
func CreateSecret() error
func CreateTestExample ¶
func CreateTestExample(test MultiUserTest) error
func DefaultErrorFunc ¶
func DefaultErrorFunc(resp TestResp)
func DefaultSkipFunc ¶
func DefaultSkipFunc() bool
func DeleteNamespace ¶
DeleteNamespace Delete Namespace
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
func GetAllUsersAvailable ¶
func GetAllUsersAvailable() []string
func InitMultiConfig ¶
func InitMultiConfig() error
func NameWithUser ¶
func PermissionErrorFunc ¶
func PermissionErrorFunc(resp TestResp)
func Register ¶
func Register(key string, loginFunc LoginByUser)
func RegisterByDefault ¶
func RegisterByDefault(test MultiUserTest)
func RegisterTestAndSteps ¶
func RegisterTestAndSteps(test MultiUserTest) error
func UserContains ¶
Types ¶
type GeneralLogin ¶
type GeneralLogin struct{}
func (*GeneralLogin) AuthHeader ¶
func (g *GeneralLogin) AuthHeader() string
func (*GeneralLogin) LoginByUser ¶
func (g *GeneralLogin) LoginByUser(user *AuthUser) error
type HttpHelper ¶
type HttpHelper struct { Admin AuthUser TenantAdmin AuthUser ProjectAdmin AuthUser User AuthUser Client http.Client AuthHeader string }
func NewHttpHelper ¶
func NewHttpHelper() *HttpHelper
func (*HttpHelper) BuildRequest ¶
func (h *HttpHelper) BuildRequest(method, urlVal, data, user string, header map[string]string) (*http.Request, error)
build request
func (*HttpHelper) Delete ¶
func (h *HttpHelper) Delete(urlVal string) (*http.Response, error)
delete
func (*HttpHelper) Login ¶
func (h *HttpHelper) Login(login string) *HttpHelper
func (*HttpHelper) MultiUserRequest ¶
func (h *HttpHelper) MultiUserRequest(method, url, body string, header map[string]string) map[string]MultiRequestResponse
multi user request test
func (*HttpHelper) Request ¶
func (h *HttpHelper) Request(method, urlVal, data string, header map[string]string) (*http.Response, error)
default request by admin
func (*HttpHelper) RequestByUser ¶
func (h *HttpHelper) RequestByUser(method, urlVal, data, user string, header map[string]string) (*http.Response, error)
request by user
type LoginByUser ¶
func GetLoginMap ¶
func GetLoginMap(key string) LoginByUser
type MultiRequestResponse ¶
type MultiUserTest ¶
type MultiUserTest struct { TestName string `yaml:"testName"` ContinueIfError bool `yaml:"continueIfError"` Steps []MultiUserTestStep `yaml:"steps"` SkipUsers []string `yaml:"skipUsers"` BeforeEach func() `yaml:"-"` AfterEach func() `yaml:"-"` Skipfunc func() bool `yaml:"-"` ErrorFunc func(resp TestResp) `yaml:"-"` InitStep *MultiUserTestStep `yaml:"-"` FinalStep *MultiUserTestStep `yaml:"-"` }
type MultiUserTestConfig ¶
type MultiUserTestConfig struct { AllUsers []string `yaml:"allUsers"` TestMap []MultiUserTest `yaml:"testMap"` }