You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	Wait between posts (#2355)
* Update abapEnvironmentAssemblePackages.go * Save 6 Seconds in Unit Tests Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com>
This commit is contained in:
		| @@ -61,7 +61,8 @@ func runAbapEnvironmentAssemblePackages(config *abapEnvironmentAssemblePackagesO | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	builds, buildsAlreadyReleased, err := starting(addonDescriptor.Repositories, *conn) | ||||
| 	delayBetweenPostsInSeconds := time.Duration(3 * time.Second) | ||||
| 	builds, buildsAlreadyReleased, err := starting(addonDescriptor.Repositories, *conn, delayBetweenPostsInSeconds) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -127,7 +128,7 @@ func checkIfFailedAndPrintLogs(builds []buildWithRepository) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func starting(repos []abaputils.Repository, conn abapbuild.Connector) ([]buildWithRepository, []buildWithRepository, error) { | ||||
| func starting(repos []abaputils.Repository, conn abapbuild.Connector, delayBetweenPostsInSeconds time.Duration) ([]buildWithRepository, []buildWithRepository, error) { | ||||
| 	var builds []buildWithRepository | ||||
| 	var buildsAlreadyReleased []buildWithRepository | ||||
| 	for _, repo := range repos { | ||||
| @@ -148,6 +149,9 @@ func starting(repos []abaputils.Repository, conn abapbuild.Connector) ([]buildWi | ||||
| 			log.Entry().Infof("Packages %s is in status '%s'. No need to run the assembly", repo.PackageName, repo.Status) | ||||
| 			buildsAlreadyReleased = append(buildsAlreadyReleased, buildRepo) | ||||
| 		} | ||||
|  | ||||
| 		//as batch events in the ABAP Backend need a little time | ||||
| 		time.Sleep(delayBetweenPostsInSeconds) | ||||
| 	} | ||||
| 	return builds, buildsAlreadyReleased, nil | ||||
| } | ||||
|   | ||||
| @@ -78,7 +78,7 @@ func TestStarting(t *testing.T) { | ||||
| 		repo.Status = "R" | ||||
| 		repos = append(repos, repo) | ||||
|  | ||||
| 		builds, buildsAlreadyReleased, err := starting(repos, *conn) | ||||
| 		builds, buildsAlreadyReleased, err := starting(repos, *conn, time.Duration(0*time.Second)) | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.Equal(t, 1, len(builds)) | ||||
| 		assert.Equal(t, 1, len(buildsAlreadyReleased)) | ||||
| @@ -101,7 +101,7 @@ func TestStartingInvalidInput(t *testing.T) { | ||||
| 			Status: "P", | ||||
| 		} | ||||
| 		repos = append(repos, repo) | ||||
| 		_, _, err := starting(repos, *conn) | ||||
| 		_, _, err := starting(repos, *conn, time.Duration(0*time.Second)) | ||||
| 		assert.Error(t, err) | ||||
| 	}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user