Skip to content

Commit 404e66d

Browse files
committed
[core] Add possibility for testplugin call to fail
1 parent 34ed4ad commit 404e66d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

core/integration/testplugin/plugin.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
100100
message = "running testplugin.Noop"
101101
}
102102

103+
doFailS, ok := varStack["testplugin_fail"]
104+
if !ok {
105+
doFailS = "false"
106+
}
107+
doFail, convErr := strconv.ParseBool(doFailS)
108+
if convErr != nil {
109+
doFail = false
110+
}
111+
103112
stack = make(map[string]interface{})
104113
stack["Noop"] = func() (out string) { // must formally return string even when we return nothing
105114
log.WithField("partition", envId).
@@ -132,6 +141,40 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
132141

133142
return
134143
}
144+
stack["Test"] = func() (out string) { // must formally return string even when we return nothing
145+
log.WithField("partition", envId).
146+
WithField("level", infologger.IL_Ops).
147+
WithField("rolepath", call.GetParentRolePath()).
148+
WithField("trigger", call.GetTraits().Trigger).
149+
WithField("await", call.GetTraits().Await).
150+
Infof("executing testplugin.Test call: %s", message)
151+
152+
rn := varStack["run_number"]
153+
var (
154+
runNumber64 int64
155+
err error
156+
)
157+
runNumber64, err = strconv.ParseInt(rn, 10, 32)
158+
if err != nil {
159+
runNumber64 = 0
160+
}
161+
162+
timeout := callable.AcquireTimeout(TESTPLUGIN_GENERAL_OP_TIMEOUT, varStack, "Test", envId)
163+
defer log.WithField("partition", envId).
164+
WithField("level", infologger.IL_Ops).
165+
WithField("rolepath", call.GetParentRolePath()).
166+
WithField("trigger", call.GetTraits().Trigger).
167+
WithField("await", call.GetTraits().Await).
168+
WithField("runNumber", runNumber64).
169+
Infof("executed testplugin.Test call in %s", timeout)
170+
171+
time.Sleep(timeout)
172+
if doFail {
173+
call.VarStack["__call_error"] = "error triggered in testplugin.Test call"
174+
}
175+
176+
return
177+
}
135178

136179
return
137180
}

0 commit comments

Comments
 (0)