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

This commit is contained in:
Jim authored and GitHub committed 2022-07-22 10:18:29 -04:00
1 parent c2bfcc0664
commit b3ec54e81b
5 files changed
+44

No files matched your search

+3
View File
@@ -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.
+15
View File
@@ -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) {
+12
View File
@@ -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,
},
}
+8
View File
@@ -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
}
}
+6
View File
@@ -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)
})
}