Documentation ¶
Index ¶
- Constants
- Variables
- func DoNotFailOnTimeout() signInOptFunc
- func ProvideApp1(apis apps.APIs, cfg *istructsmem.AppConfigType, ...) apps.BuiltInAppDef
- func ProvideApp2(apis apps.APIs, cfg *istructsmem.AppConfigType, ...) apps.BuiltInAppDef
- func TestDeadline() time.Time
- func TestRestartPreservingStorage(t *testing.T, cfg *VITConfig, ...)
- func WithApp(appQName istructs.AppQName, updater apps.AppBuilder, appOpts ...AppOptFunc) vitConfigOptFunc
- func WithCleanup(cleanup func(*VIT)) vitConfigOptFunc
- func WithClusterID(clusterID istructs.ClusterID) signUpOptFunc
- func WithInit(initFunc func()) vitConfigOptFunc
- func WithPostInit(postInitFunc func(vit *VIT)) vitConfigOptFunc
- func WithReqOpt(reqOpt coreutils.ReqOptFunc) signUpOptFunc
- func WithVVMConfig(configurer func(cfg *vvm.VVMConfig)) vitConfigOptFunc
- type AppOptFunc
- func WithBuilder(builder apps.AppBuilder) AppOptFunc
- func WithChildWorkspace(wsKind appdef.QName, name, templateName string, templateParams string, ...) AppOptFunc
- func WithUserLogin(name, pwd string, opts ...PostConstructFunc) AppOptFunc
- func WithVerifiedValue(docQName appdef.QName, fieldName string, desiredValue string) AppOptFunc
- func WithWorkspaceTemplate(wsKind appdef.QName, templateName string, templateFS coreutils.EmbedFS) AppOptFunc
- type AppWorkspace
- type BLOB
- type Login
- type PostConstructFunc
- func WithChild(wsKind appdef.QName, name, templateName string, templateParams string, ...) PostConstructFunc
- func WithDoc(name appdef.QName, data map[string]interface{}) PostConstructFunc
- func WithDocWithVerifiedFields(name appdef.QName, ...) PostConstructFunc
- func WithSubject(login string, subjectKind istructs.SubjectKindType, roles []appdef.QName) PostConstructFunc
- type Principal
- type VIT
- func (vit *VIT) CaptureEmail() (msg smtptest.Message)
- func (vit *VIT) CreateWorkspace(wsp WSParams, owner *Principal, opts ...coreutils.ReqOptFunc) *AppWorkspace
- func (vit *VIT) Func(url string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
- func (vit *VIT) GetAny(entity string, ws *AppWorkspace) istructs.RecordID
- func (vit *VIT) GetBLOB(appQName istructs.AppQName, wsid istructs.WSID, blobID istructs.RecordID, ...) *BLOB
- func (vit *VIT) GetCDocChildWorkspace(ws *AppWorkspace) (cdoc map[string]interface{}, id int64)
- func (vit *VIT) GetCDocLoginID(login Login) int64
- func (vit *VIT) GetCDocWSKind(ws *AppWorkspace) (cdoc map[string]interface{}, id int64)
- func (vit *VIT) GetPrincipal(appQName istructs.AppQName, login string) *Principal
- func (vit *VIT) GetSystemPrincipal(appQName istructs.AppQName) *Principal
- func (vit *VIT) InitChildWorkspace(wsd WSParams, ownerIntf interface{}, opts ...coreutils.ReqOptFunc)
- func (vit *VIT) MetricsRequest(client coreutils.IHTTPClient, opts ...coreutils.ReqOptFunc) (resp string)
- func (vit *VIT) MetricsServicePort() int
- func (vit *VIT) MockBuckets(appQName istructs.AppQName, rateLimitName string, bs irates.BucketState)
- func (vit *VIT) NextName() string
- func (vit *VIT) NextNumber() int
- func (vit *VIT) Now() time.Time
- func (vit *VIT) POST(relativeURL string, body string, opts ...coreutils.ReqOptFunc) *coreutils.HTTPResponse
- func (vit *VIT) PostApp(appQName istructs.AppQName, wsid istructs.WSID, funcName string, body string, ...) *coreutils.FuncResponse
- func (vit *VIT) PostProfile(prn *Principal, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
- func (vit *VIT) PostWS(ws *AppWorkspace, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
- func (vit *VIT) PostWSSys(ws *AppWorkspace, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
- func (vit *VIT) ReadBLOB(appQName istructs.AppQName, wsid istructs.WSID, blobID istructs.RecordID, ...) *coreutils.HTTPResponse
- func (vit *VIT) Restart()
- func (vit *VIT) SetMemStorageGetDelay(delay time.Duration)
- func (vit *VIT) SetMemStoragePutDelay(delay time.Duration)
- func (vit *VIT) SetNow(now time.Time)
- func (vit *VIT) SignIn(login Login, optFuncs ...signInOptFunc) (prn *Principal)
- func (vit *VIT) SignUp(loginName, pwd string, appQName istructs.AppQName, opts ...signUpOptFunc) Login
- func (vit *VIT) SignUpDevice(loginName, pwd string, appQName istructs.AppQName, opts ...signUpOptFunc) Login
- func (vit *VIT) SubscribeForN10n(ws *AppWorkspace, projectionQName appdef.QName) federation.OffsetsChan
- func (vit *VIT) SubscribeForN10nProjectionKey(pk in10n.ProjectionKey) federation.OffsetsChan
- func (vit *VIT) SubscribeForN10nUnsubscribe(pk in10n.ProjectionKey) (offsetsChan federation.OffsetsChan, unsubscribe func())
- func (vit *VIT) TearDown()
- func (vit *VIT) TimeAdd(dur time.Duration)
- func (vit *VIT) UploadBLOB(appQName istructs.AppQName, wsid istructs.WSID, blobName string, ...) (blobID istructs.RecordID)
- func (vit *VIT) UploadBLOBs(appQName istructs.AppQName, wsid istructs.WSID, blobs []coreutils.BLOB, ...) (blobIDs []istructs.RecordID)
- func (vit *VIT) WS(appQName istructs.AppQName, wsName string) *AppWorkspace
- func (vit *VIT) WaitFor(consumer func() *coreutils.FuncResponse) *coreutils.FuncResponse
- func (vit *VIT) WaitForChildWorkspace(parentWS *AppWorkspace, wsName string) (ws *AppWorkspace)
- func (vit *VIT) WaitForWorkspace(wsName string, owner *Principal) (ws *AppWorkspace)
- type VITConfig
- type WSParams
- type WorkspaceDescriptor
Constants ¶
const ( TestEmail = "123@123.com" TestEmail2 = "124@124.com" TestServicePort = 10000 App1PkgPath = "github.com/voedger/voedger/pkg/vit/app1pkg" )
Variables ¶
var ( DefaultTestTime = time.UnixMilli(testTimeMillis) // 2022-04-11 11:54:46 +0300 MSK //go:embed schemaTestApp1.vsql SchemaTestApp1FS embed.FS //go:embed schemaTestApp2.vsql SchemaTestApp2FS embed.FS DefaultTestAppEnginesPool = appparts.PoolSize(10, 10, 20) TestAppDeploymentDescriptor = appparts.AppDeploymentDescriptor{ NumParts: 10, EnginePoolSize: DefaultTestAppEnginesPool, NumAppWorkspaces: istructs.DefaultNumAppWorkspaces, } )
var ( QNameApp1_TestWSKind = appdef.NewQName(app1PkgName, "test_ws") QNameApp1_TestWSKind_another = appdef.NewQName(app1PkgName, "test_ws_another") QNameTestView = appdef.NewQName(app1PkgName, "View") QNameApp1_TestEmailVerificationDoc = appdef.NewQName(app1PkgName, "Doc") QNameApp1_DocConstraints = appdef.NewQName(app1PkgName, "DocConstraints") QNameApp1_DocConstraintsString = appdef.NewQName(app1PkgName, "DocConstraintsString") QNameApp1_DocConstraintsFewUniques = appdef.NewQName(app1PkgName, "DocConstraintsFewUniques") QNameApp1_DocConstraintsOldAndNewUniques = appdef.NewQName(app1PkgName, "DocConstraintsOldAndNewUniques") QNameApp1_CDocCategory = appdef.NewQName(app1PkgName, "category") QNameCmdRated = appdef.NewQName(app1PkgName, "RatedCmd") QNameQryRated = appdef.NewQName(app1PkgName, "RatedQry") QNameODoc1 = appdef.NewQName(app1PkgName, "odoc1") QNameODoc2 = appdef.NewQName(app1PkgName, "odoc2") TestSMTPCfg = smtp.Cfg{ Username: "username@gmail.com", } SharedConfig_App1 = NewSharedVITConfig( WithApp(istructs.AppQName_test1_app1, ProvideApp1, WithWorkspaceTemplate(QNameApp1_TestWSKind, "test_template", sys_test_template.TestTemplateFS), WithUserLogin("login", "pwd"), WithUserLogin(TestEmail, "1"), WithUserLogin(TestEmail2, "1"), WithChildWorkspace(QNameApp1_TestWSKind, "test_ws", "test_template", "", "login", map[string]interface{}{"IntFld": 42}, WithChild(QNameApp1_TestWSKind, "test_ws2", "test_template", "", "login", map[string]interface{}{"IntFld": 42}, WithSubject(TestEmail, istructs.SubjectKind_User, []appdef.QName{iauthnz.QNameRoleWorkspaceOwner}))), WithChildWorkspace(QNameApp1_TestWSKind_another, "test_ws_another", "", "", "login", map[string]interface{}{}), ), WithApp(istructs.AppQName_test1_app2, ProvideApp2, WithUserLogin("login", "1")), WithVVMConfig(func(cfg *vvm.VVMConfig) { cfg.Routes["/grafana"] = fmt.Sprintf("http://127.0.0.1:%d", TestServicePort) cfg.RoutesRewrite["/grafana-rewrite"] = fmt.Sprintf("http://127.0.0.1:%d/rewritten", TestServicePort) cfg.RouteDefault = fmt.Sprintf("http://127.0.0.1:%d/not-found", TestServicePort) cfg.RouteDomains["localhost"] = fmt.Sprintf("http://127.0.0.1:%d", TestServicePort) const app1_BLOBMaxSize = 5 cfg.BLOBMaxSize = app1_BLOBMaxSize }), WithCleanup(func(_ *VIT) { MockCmdExec = func(input string, args istructs.ExecCommandArgs) error { panic("") } MockQryExec = func(input string, callback istructs.ExecQueryCallback) error { panic("") } }), ) MockQryExec func(input string, callback istructs.ExecQueryCallback) error MockCmdExec func(input string, args istructs.ExecCommandArgs) error )
Functions ¶
func DoNotFailOnTimeout ¶
func DoNotFailOnTimeout() signInOptFunc
func ProvideApp1 ¶
func ProvideApp1(apis apps.APIs, cfg *istructsmem.AppConfigType, ep extensionpoints.IExtensionPoint) apps.BuiltInAppDef
func ProvideApp2 ¶
func ProvideApp2(apis apps.APIs, cfg *istructsmem.AppConfigType, ep extensionpoints.IExtensionPoint) apps.BuiltInAppDef
func TestDeadline ¶
func TestRestartPreservingStorage ¶
func TestRestartPreservingStorage(t *testing.T, cfg *VITConfig, testBeforeRestart, testAfterRestart func(t *testing.T, vit *VIT))
calls testBeforeRestart() then stops then VIT, then launches new VIT on the same config but with storage from previous VIT then calls testAfterRestart() with the new VIT cfg must be owned
func WithApp ¶
func WithApp(appQName istructs.AppQName, updater apps.AppBuilder, appOpts ...AppOptFunc) vitConfigOptFunc
func WithCleanup ¶
func WithCleanup(cleanup func(*VIT)) vitConfigOptFunc
func WithClusterID ¶
func WithPostInit ¶
func WithPostInit(postInitFunc func(vit *VIT)) vitConfigOptFunc
func WithReqOpt ¶
func WithReqOpt(reqOpt coreutils.ReqOptFunc) signUpOptFunc
func WithVVMConfig ¶
Types ¶
type AppOptFunc ¶
func WithBuilder ¶
func WithBuilder(builder apps.AppBuilder) AppOptFunc
func WithChildWorkspace ¶
func WithChildWorkspace(wsKind appdef.QName, name, templateName string, templateParams string, ownerLoginName string, wsInitData map[string]interface{}, opts ...PostConstructFunc) AppOptFunc
func WithUserLogin ¶
func WithUserLogin(name, pwd string, opts ...PostConstructFunc) AppOptFunc
at MainCluster
func WithVerifiedValue ¶
func WithVerifiedValue(docQName appdef.QName, fieldName string, desiredValue string) AppOptFunc
func WithWorkspaceTemplate ¶
type AppWorkspace ¶
type AppWorkspace struct { WorkspaceDescriptor Owner *Principal // потому что токены принципала обновляются, когда меняется время }
func (*AppWorkspace) AppQName ¶
func (a *AppWorkspace) AppQName() istructs.AppQName
type Login ¶
type PostConstructFunc ¶
type PostConstructFunc func(intf interface{})
func WithChild ¶
func WithChild(wsKind appdef.QName, name, templateName string, templateParams string, ownerLoginName string, wsInitData map[string]interface{}, opts ...PostConstructFunc) PostConstructFunc
func WithSubject ¶
func WithSubject(login string, subjectKind istructs.SubjectKindType, roles []appdef.QName) PostConstructFunc
type Principal ¶
func (*Principal) GetAppQName ¶
type VIT ¶
type VIT struct { T testing.TB *vvm.VoedgerVM *vvm.VVMConfig // contains filtered or unexported fields }
Voedger Integration Test
func NewVITLocalCassandra ¶
func (*VIT) CaptureEmail ¶
CaptureEmail waits for and returns the next sent email no emails during testEmailsAwaitingTimeout -> test failed an email was sent but CaptureEmail is not called -> test will be failed on VIT.TearDown()
func (*VIT) CreateWorkspace ¶
func (vit *VIT) CreateWorkspace(wsp WSParams, owner *Principal, opts ...coreutils.ReqOptFunc) *AppWorkspace
func (*VIT) Func ¶
func (vit *VIT) Func(url string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
func (*VIT) GetCDocChildWorkspace ¶
func (vit *VIT) GetCDocChildWorkspace(ws *AppWorkspace) (cdoc map[string]interface{}, id int64)
func (*VIT) GetCDocLoginID ¶
func (*VIT) GetCDocWSKind ¶
func (vit *VIT) GetCDocWSKind(ws *AppWorkspace) (cdoc map[string]interface{}, id int64)
func (*VIT) GetPrincipal ¶
func (*VIT) GetSystemPrincipal ¶
func (*VIT) InitChildWorkspace ¶
func (vit *VIT) InitChildWorkspace(wsd WSParams, ownerIntf interface{}, opts ...coreutils.ReqOptFunc)
owner could be *vit.Principal or *vit.AppWorkspace
func (*VIT) MetricsRequest ¶
func (vit *VIT) MetricsRequest(client coreutils.IHTTPClient, opts ...coreutils.ReqOptFunc) (resp string)
func (*VIT) MetricsServicePort ¶
func (*VIT) MockBuckets ¶
func (vit *VIT) MockBuckets(appQName istructs.AppQName, rateLimitName string, bs irates.BucketState)
sets `bs` as state of Buckets for `rateLimitName` in `appQName` will be automatically restored on vit.TearDown() to the state the Bucket was before MockBuckets() call
func (*VIT) NextNumber ¶
func (*VIT) POST ¶
func (vit *VIT) POST(relativeURL string, body string, opts ...coreutils.ReqOptFunc) *coreutils.HTTPResponse
func (*VIT) PostProfile ¶
func (vit *VIT) PostProfile(prn *Principal, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
func (*VIT) PostWS ¶
func (vit *VIT) PostWS(ws *AppWorkspace, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
func (*VIT) PostWSSys ¶
func (vit *VIT) PostWSSys(ws *AppWorkspace, funcName string, body string, opts ...coreutils.ReqOptFunc) *coreutils.FuncResponse
PostWSSys is PostWS authorized by the System Token
func (*VIT) SetMemStorageGetDelay ¶
sets delay on IAppStorage.Get() in mem implementation will be automatically reset to 0 on TearDown
func (*VIT) SetMemStoragePutDelay ¶
sets delay on IAppStorage.Put() in mem implementation will be automatically reset to 0 on TearDown
func (*VIT) SignUpDevice ¶
func (*VIT) SubscribeForN10n ¶
func (vit *VIT) SubscribeForN10n(ws *AppWorkspace, projectionQName appdef.QName) federation.OffsetsChan
func (*VIT) SubscribeForN10nProjectionKey ¶
func (vit *VIT) SubscribeForN10nProjectionKey(pk in10n.ProjectionKey) federation.OffsetsChan
will be unsubscribed automatically on vit.TearDown()
func (*VIT) SubscribeForN10nUnsubscribe ¶
func (vit *VIT) SubscribeForN10nUnsubscribe(pk in10n.ProjectionKey) (offsetsChan federation.OffsetsChan, unsubscribe func())
func (*VIT) UploadBLOB ¶
func (*VIT) UploadBLOBs ¶
func (*VIT) WaitFor ¶
func (vit *VIT) WaitFor(consumer func() *coreutils.FuncResponse) *coreutils.FuncResponse
func (*VIT) WaitForChildWorkspace ¶
func (vit *VIT) WaitForChildWorkspace(parentWS *AppWorkspace, wsName string) (ws *AppWorkspace)
func (*VIT) WaitForWorkspace ¶
func (vit *VIT) WaitForWorkspace(wsName string, owner *Principal) (ws *AppWorkspace)
type VITConfig ¶
type VITConfig struct {
// contains filtered or unexported fields
}
func NewOwnVITConfig ¶
func NewOwnVITConfig(opts ...vitConfigOptFunc) VITConfig
func NewSharedVITConfig ¶
func NewSharedVITConfig(opts ...vitConfigOptFunc) VITConfig