1717
1818class OrchestrationJobMatcherTest extends BaseClientFunctionalTest
1919{
20+ private ?string $ configurationId = null ;
21+ private ?string $ componentId = null ;
22+
23+ public function tearDown (): void
24+ {
25+ if ($ this ->configurationId !== null && $ this ->componentId !== null ) {
26+ $ storageClient = new StorageClient ([
27+ 'token ' => (string ) getenv ('TEST_STORAGE_API_TOKEN ' ),
28+ 'url ' => (string ) getenv ('TEST_STORAGE_API_URL ' ),
29+ ]);
30+ $ componentsApi = new Components ($ storageClient );
31+ $ componentsApi ->deleteConfiguration ($ this ->componentId , $ this ->configurationId );
32+ }
33+ parent ::tearDown ();
34+ }
35+
2036 private function getOrchestrationConfiguration (): array
2137 {
2238 return [
@@ -89,13 +105,14 @@ private function createOrchestrationLikeJobs(array $configurationData, array $cr
89105 $ configuration ->setConfiguration ($ configurationData );
90106 $ configuration ->setName ($ this ->getName ());
91107 $ configuration ->setComponentId (JobFactory::ORCHESTRATOR_COMPONENT );
92- $ orchestrationConfigurationId = $ componentsApi ->addConfiguration ($ configuration )['id ' ];
108+ $ this ->componentId = JobFactory::ORCHESTRATOR_COMPONENT ;
109+ $ this ->configurationId = $ componentsApi ->addConfiguration ($ configuration )['id ' ];
93110 $ orchestrationJob = $ this ->getNewJobFactory ()->createNewJob (
94111 [
95112 '#tokenString ' => getenv ('TEST_STORAGE_API_TOKEN ' ),
96113 'configData ' => [],
97114 'componentId ' => JobFactory::ORCHESTRATOR_COMPONENT ,
98- 'configId ' => $ orchestrationConfigurationId ,
115+ 'configId ' => $ this -> configurationId ,
99116 'mode ' => 'run ' ,
100117 'parentRunId ' => '' ,
101118 'orchestrationJobId ' => null ,
@@ -119,7 +136,7 @@ private function createOrchestrationLikeJobs(array $configurationData, array $cr
119136 '#tokenString ' => getenv ('TEST_STORAGE_API_TOKEN ' ),
120137 'configData ' => $ configData ,
121138 'componentId ' => JobFactory::ORCHESTRATOR_COMPONENT ,
122- 'configId ' => $ orchestrationConfigurationId ,
139+ 'configId ' => $ this -> configurationId ,
123140 'mode ' => 'run ' ,
124141 'orchestrationJobId ' => $ orchestrationJob ->getId (),
125142 'parentRunId ' => $ orchestrationJob ->getId (),
@@ -147,20 +164,19 @@ private function createOrchestrationLikeJobs(array $configurationData, array $cr
147164
148165 return [
149166 'orchestrationJobId ' => $ orchestrationJob ->getId (),
150- 'orchestrationConfigurationId ' => $ orchestrationConfigurationId ,
167+ 'orchestrationConfigurationId ' => $ this -> configurationId ,
151168 'jobIds ' => $ jobIds ,
152169 ];
153170 }
154171
155172 public function testMatcherFull (): void
156173 {
157174 $ client = $ this ->getClient ();
158- $ result = $ this ->createOrchestrationLikeJobs ($ this ->getOrchestrationConfiguration (), []);
159175 [
160176 'orchestrationJobId ' => $ orchestrationJobId ,
161177 'orchestrationConfigurationId ' => $ orchestrationConfigurationId ,
162178 'jobIds ' => $ jobIds ,
163- ] = $ result ;
179+ ] = $ this -> createOrchestrationLikeJobs ( $ this -> getOrchestrationConfiguration (), []) ;
164180
165181 $ matcher = new OrchestrationJobMatcher ($ client );
166182 $ results = $ matcher ->matchTaskJobsForOrchestrationJob ($ orchestrationJobId );
@@ -197,24 +213,16 @@ public function testMatcherFull(): void
197213 ),
198214 $ results ,
199215 );
200-
201- $ storageClient = new StorageClient ([
202- 'token ' => (string ) getenv ('TEST_STORAGE_API_TOKEN ' ),
203- 'url ' => (string ) getenv ('TEST_STORAGE_API_URL ' ),
204- ]);
205- $ componentsApi = new Components ($ storageClient );
206- $ componentsApi ->deleteConfiguration (JobFactory::ORCHESTRATOR_COMPONENT , $ orchestrationConfigurationId );
207216 }
208217
209218 public function testMatcherPartial (): void
210219 {
211220 $ client = $ this ->getClient ();
212- $ result = $ this ->createOrchestrationLikeJobs ($ this ->getOrchestrationConfiguration (), ['92543 ' ]);
213221 [
214222 'orchestrationJobId ' => $ orchestrationJobId ,
215223 'orchestrationConfigurationId ' => $ orchestrationConfigurationId ,
216224 'jobIds ' => $ jobIds ,
217- ] = $ result ;
225+ ] = $ this -> createOrchestrationLikeJobs ( $ this -> getOrchestrationConfiguration (), [ ' 92543 ' ]) ;
218226
219227 $ matcher = new OrchestrationJobMatcher ($ client );
220228 $ results = $ matcher ->matchTaskJobsForOrchestrationJob ($ orchestrationJobId );
@@ -268,7 +276,6 @@ public function testMatcherInvalidConfiguration(
268276 array $ configurationData ,
269277 string $ expectedMessage ,
270278 ): void {
271- $ client = $ this ->getClient ();
272279 $ storageClient = new StorageClient ([
273280 'token ' => (string ) getenv ('TEST_STORAGE_API_TOKEN ' ),
274281 'url ' => (string ) getenv ('TEST_STORAGE_API_URL ' ),
@@ -279,27 +286,24 @@ public function testMatcherInvalidConfiguration(
279286 $ configuration ->setConfiguration ($ configurationData );
280287 $ configuration ->setName ($ this ->getName ());
281288 $ configuration ->setComponentId ($ componentId );
282- $ orchestrationConfigurationId = $ componentsApi ->addConfiguration ($ configuration )['id ' ];
289+ $ this ->componentId = $ componentId ;
290+ $ this ->configurationId = $ componentsApi ->addConfiguration ($ configuration )['id ' ];
283291 $ orchestrationJob = $ this ->getNewJobFactory ()->createNewJob (
284292 [
285293 '#tokenString ' => getenv ('TEST_STORAGE_API_TOKEN ' ),
286294 'configData ' => [],
287- 'componentId ' => $ componentId ,
288- 'configId ' => $ orchestrationConfigurationId ,
295+ 'componentId ' => $ componentId ,
296+ 'configId ' => $ this -> configurationId ,
289297 'mode ' => 'run ' ,
290298 'parentRunId ' => '' ,
291299 'orchestrationJobId ' => null ,
292300 ],
293301 );
294302 $ orchestrationJobId = $ queueClient ->createJob ($ orchestrationJob )->getId ();
295- $ matcher = new OrchestrationJobMatcher ($ client );
296- try {
297- $ this ->expectException (OrchestrationJobMatcherValidationException::class);
298- $ this ->expectExceptionMessageMatches ($ expectedMessage );
299- $ matcher ->matchTaskJobsForOrchestrationJob ($ orchestrationJobId );
300- } finally {
301- $ componentsApi ->deleteConfiguration ($ componentId , $ orchestrationConfigurationId );
302- }
303+ $ matcher = new OrchestrationJobMatcher ($ queueClient );
304+ $ this ->expectException (OrchestrationJobMatcherValidationException::class);
305+ $ this ->expectExceptionMessageMatches ($ expectedMessage );
306+ $ matcher ->matchTaskJobsForOrchestrationJob ($ orchestrationJobId );
303307 }
304308
305309 public function invalidConfigurationProvider (): Generator
0 commit comments