feature (server): add new error codes for downstream workers DAG (#2275)

pull/2278/head
Jim 4 years ago committed by GitHub
parent c2bfcc0664
commit b3ec54e81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,6 +40,9 @@ const (
InvalidDynamicCredential Code = 116 // InvalidDynamicCredential represents that a dynamic credential for a session was in an invalid state
JobAlreadyRunning Code = 117 // JobAlreadyRunning represents that a Job is already running when an attempt to run again was made
SubtypeAlreadyRegistered Code = 118 // SubtypeAlreadyRegistered represents that a value has already been registered in the subtype registry system.
NoPathFound = 119 // NoPathFound represents an error when no path is found to a worker
WorkerNotFound = 120 // WorkerNotFound represents an error when a worker is not found in the graph of downstream workers
CycleFound = 121 // CycleFound represents an error when a cycle is found between a parent and child worker
AuthAttemptExpired Code = 198 // AuthAttemptExpired represents an expired authentication attempt
AuthMethodInactive Code = 199 // AuthMethodInactive represents an error that means the auth method is not active.

@ -312,6 +312,21 @@ func TestCode_Both_String_Info(t *testing.T) {
c: UnexpectedRowsAffected,
want: UnexpectedRowsAffected,
},
{
name: "NoPathFound",
c: NoPathFound,
want: NoPathFound,
},
{
name: "CycleFound",
c: CycleFound,
want: CycleFound,
},
{
name: "WorkerNotFound",
c: WorkerNotFound,
want: WorkerNotFound,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

@ -252,4 +252,16 @@ var errorCodeInfo = map[Code]Info{
Message: "unexpected number of rows affected",
Kind: Integrity,
},
NoPathFound: {
Message: "unexpected number of rows affected",
Kind: State,
},
WorkerNotFound: {
Message: "worker not found",
Kind: State,
},
CycleFound: {
Message: "cycle found",
Kind: State,
},
}

@ -39,6 +39,7 @@ type options struct {
withTestPkiWorkerAuthorized bool
withTestPkiWorkerKeyId *string
withWorkerType WorkerType
withRoot string
}
func getDefaultOptions() options {
@ -172,3 +173,10 @@ func WithWorkerType(with WorkerType) Option {
o.withWorkerType = with
}
}
// WithRoot provides an optional root worker id.
func WithRoot(workerId string) Option {
return func(o *options) {
o.withRoot = workerId
}
}

@ -164,4 +164,10 @@ func Test_GetOpts(t *testing.T) {
opts = getOpts(WithWorkerType(KmsWorkerType))
assert.Equal(t, KmsWorkerType, opts.withWorkerType)
})
t.Run("WithRoot", func(t *testing.T) {
opts := getDefaultOptions()
assert.Empty(t, opts.withRoot)
opts = getOpts(WithRoot("a"))
assert.Equal(t, "a", opts.withRoot)
})
}

Loading…
Cancel
Save