@@ -88,8 +88,11 @@ When('we run the job to replicate existing objects with status {string}',
88
88
await createAndRunPod ( this , podManifest ) ;
89
89
} ) ;
90
90
91
- Then ( 'the object should eventually {string} replicated' , { timeout : 360_000 } ,
92
- async function ( this : Zenko , replicate : 'be' | 'fail to be' ) {
91
+ Then ( 'the object replication should eventually {string}' , { timeout : 360_000 } ,
92
+ async function (
93
+ this : Zenko ,
94
+ expectedOutcome : 'succeed' | 'fail' | 'never happen'
95
+ ) {
93
96
const objectName = this . getSaved < string > ( 'objectName' ) ;
94
97
const bucketSource = this . getSaved < string > ( 'bucketName' ) ;
95
98
const startTime = Date . now ( ) ;
@@ -110,13 +113,25 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
110
113
} > ( response . stdout || '{}' ) ;
111
114
assert ( parsed . ok ) ;
112
115
const replicationStatus = parsed . result ?. ReplicationStatus ;
116
+ console . log ( `testing 0 ${ expectedOutcome } - Response stdout:` , response . stdout ) ;
117
+ console . log ( `testing 1 ${ expectedOutcome } - Full response:` , JSON . stringify ( response , null , 2 ) ) ;
118
+ console . log ( `testing 2 ${ expectedOutcome } - Parsed result:` , JSON . stringify ( parsed , null , 2 ) ) ;
119
+ console . log ( `testing 3 ${ expectedOutcome } - Parsed result:` , JSON . stringify ( parsed . result , null , 2 ) ) ;
120
+ console . log ( `testing 4 ${ expectedOutcome } - Replication status: ${ replicationStatus } ` ) ;
113
121
114
- if ( replicate === 'be' ) {
122
+ if ( ( expectedOutcome === 'succeed' || expectedOutcome === 'fail' ) &&
123
+ ( replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING' ) ) {
124
+ continue ;
125
+ }
126
+
127
+ switch ( expectedOutcome ) {
128
+ case 'succeed' :
115
129
assert . notStrictEqual ( replicationStatus , 'FAILED' , `replication failed for object ${ objectName } ` ) ;
116
130
if ( replicationStatus === 'COMPLETED' ) {
117
131
return ;
118
132
}
119
- } else if ( replicate === 'fail to be' ) {
133
+ break ;
134
+ case 'fail' :
120
135
assert . notStrictEqual (
121
136
replicationStatus ,
122
137
'COMPLETED' ,
@@ -125,12 +140,17 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
125
140
if ( replicationStatus === 'FAILED' ) {
126
141
return ;
127
142
}
143
+ break ;
144
+ case 'never happen' :
145
+ // When the replication is not expected to happen, replicationStatus is never set
146
+ assert . strictEqual ( replicationStatus , undefined , 'expected object to have no ReplicationStatus (should remain undefined)' ) ;
147
+ break ;
128
148
}
129
- if ( replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING' ) {
130
- continue ;
131
- }
132
149
}
133
- assert . fail ( `Timeout: Object '${ objectName } ' is still pending/processing after timeout` ) ;
150
+ if ( expectedOutcome === 'never happen' ) {
151
+ return ;
152
+ }
153
+ assert . fail ( `Timeout: Object '${ objectName } ' is still in pending/processing state after timeout` ) ;
134
154
} ) ;
135
155
136
156
Then (
0 commit comments