@@ -242,7 +242,13 @@ func mockSearch(t *testing.T, workerServer *worker.Server, wg *sync.WaitGroup, f
242
242
func newV2Server (t * testing.T , dir string , enableJWT bool , fail bool ) (* v2.Server , * worker.Server , jobqueue.JobQueue , context.CancelFunc ) {
243
243
q , err := fsjobqueue .New (dir )
244
244
require .NoError (t , err )
245
- workerServer := worker .NewServer (nil , q , worker.Config {BasePath : "/api/worker/v1" , JWTEnabled : enableJWT , TenantProviderFields : []string {"rh-org-id" , "account_id" }})
245
+ workerConfig := worker.Config {
246
+ ArtifactsDir : t .TempDir (),
247
+ BasePath : "/api/worker/v1" ,
248
+ JWTEnabled : enableJWT ,
249
+ TenantProviderFields : []string {"rh-org-id" , "account_id" },
250
+ }
251
+ workerServer := worker .NewServer (nil , q , workerConfig )
246
252
247
253
distros := distrofactory .NewTestDefault ()
248
254
require .NotNil (t , distros )
@@ -1834,3 +1840,59 @@ func TestSearchArchErrors(t *testing.T) {
1834
1840
"reason": "Request could not be validated"
1835
1841
}` , "operation_id" , "details" )
1836
1842
}
1843
+
1844
+ // TestComposeRequestMetadata tests that the original ComposeRequest is included with the
1845
+ // metadata response.
1846
+ func TestComposeRequestMetadata (t * testing.T ) {
1847
+ srv , wrksrv , _ , cancel := newV2Server (t , t .TempDir (), false , false )
1848
+ defer cancel ()
1849
+
1850
+ request := fmt .Sprintf (`
1851
+ {
1852
+ "distribution": "%s",
1853
+ "image_requests":[{
1854
+ "architecture": "%s",
1855
+ "image_type": "aws",
1856
+ "repositories": [{
1857
+ "baseurl": "somerepo.org",
1858
+ "rhsm": false
1859
+ }],
1860
+ "upload_options": {
1861
+ "region": "eu-central-1"
1862
+ }
1863
+ }]
1864
+ }` , test_distro .TestDistro1Name , test_distro .TestArch3Name )
1865
+ test .TestRoute (t , srv .Handler ("/api/image-builder-composer/v2" ), false , "POST" , "/api/image-builder-composer/v2/compose" , request , http .StatusCreated , `
1866
+ {
1867
+ "href": "/api/image-builder-composer/v2/compose",
1868
+ "kind": "ComposeId"
1869
+ }` , "id" )
1870
+
1871
+ jobId , _ , jobType , args , dynArgs , err := wrksrv .RequestJob (context .Background (), test_distro .TestArch3Name , []string {worker .JobTypeOSBuild }, []string {"" }, uuid .Nil )
1872
+ require .NoError (t , err )
1873
+ require .Equal (t , worker .JobTypeOSBuild , jobType )
1874
+
1875
+ var osbuildJob worker.OSBuildJob
1876
+ err = json .Unmarshal (args , & osbuildJob )
1877
+ require .NoError (t , err )
1878
+ require .Equal (t , 0 , len (osbuildJob .Manifest ))
1879
+ require .NotEqual (t , 0 , len (dynArgs [0 ]))
1880
+
1881
+ test .TestRoute (t , srv .Handler ("/api/image-builder-composer/v2" ), false , "GET" , fmt .Sprintf ("/api/image-builder-composer/v2/composes/%v" , jobId ), `` , http .StatusOK , fmt .Sprintf (`
1882
+ {
1883
+ "href": "/api/image-builder-composer/v2/composes/%v",
1884
+ "kind": "ComposeStatus",
1885
+ "id": "%v",
1886
+ "image_status": {"status": "building"},
1887
+ "status": "pending"
1888
+ }` , jobId , jobId ))
1889
+
1890
+ // metadata response should include the ComposeRequest even when build is not done
1891
+ test .TestRoute (t , srv .Handler ("/api/image-builder-composer/v2" ), false , "GET" , fmt .Sprintf ("/api/image-builder-composer/v2/composes/%v/metadata" , jobId ), `` , http .StatusOK ,
1892
+ fmt .Sprintf (`{
1893
+ "href": "/api/image-builder-composer/v2/composes/%[1]v/metadata",
1894
+ "id": "%[1]v",
1895
+ "kind": "ComposeMetadata",
1896
+ "request": %s
1897
+ }` , jobId , request ))
1898
+ }
0 commit comments