@@ -6,6 +6,9 @@ String launchUnitTests = "yes"
66String launchIntegrationTests = " yes"
77String [] pimVersions = [" 1.7" , " 2.0" ]
88String [] supportedPhpVersions = [" 5.6" , " 7.0" , " 7.1" ]
9+ String verboseOutputs = " yes"
10+ String dotsPerLine = " 50"
11+
912def clientConfig = [
1013 " php-http/guzzle6-adapter" : [" phpVersion" : supportedPhpVersions, " psrImplem" : [" guzzlehttp/psr7" ]],
1114 " php-http/guzzle5-adapter" : [" phpVersion" : supportedPhpVersions, " psrImplem" : [" guzzlehttp/psr7" , " zendframework/zend-diactoros" , " slim/slim" ]],
@@ -28,13 +31,19 @@ try {
2831 string(defaultValue : pimVersions. join(' ,' ), description : ' PIM edition the tests should run on' , name : ' requiredPimVersions' ),
2932 choice(choices : ' yes\n no' , description : ' Run unit tests and code style checks' , name : ' launchUnitTests' ),
3033 choice(choices : ' yes\n no' , description : ' Run integration tests' , name : ' launchIntegrationTests' ),
34+ choice(choices : ' no\n yes' , description : ' Enable Verbose mode' , name : ' verboseOutputs' ),
35+ string(defaultValue : ' 50' , description : ' Number of dots per line' , name : ' dotsperline' ),
3136 string(defaultValue : clients. join(' ,' ), description : ' Clients used to run integration tests (comma separated values)' , name : ' clients' ),
37+ choice(choices : ' no\n yes' , description : ' Enable Verbose mode' , name : ' verboseOutputs' ),
38+ string(defaultValue : ' 50' , description : ' Number of dots per line' , name : ' dotsperline' ),
3239 ])
3340
3441 pimVersions = userInput[' requiredPimVersions' ]. tokenize(' ,' )
3542 launchUnitTests = userInput[' launchUnitTests' ]
3643 launchIntegrationTests = userInput[' launchIntegrationTests' ]
3744 clients = userInput[' clients' ]. tokenize(' ,' )
45+ verboseOutputs = userInput[' verboseOutputs' ]
46+ dotsPerLine = userInput[' dotsperline' ]
3847 }
3948 milestone 2
4049
@@ -373,9 +382,10 @@ def runPim20IntegrationTest(String phpVersion, String client, String psrImplem)
373382 // Find and store PHP test integration files to launch them in parallels
374383 files + = sh (returnStdout : true , script : ' find /home/jenkins/php-api-client/tests/v2_0/Api -name "*Integration.php"' ). tokenize(' \n ' )
375384 files + = sh (returnStdout : true , script : ' find /home/jenkins/php-api-client/tests/Common/Api -name "*Integration.php"' ). tokenize(' \n ' )
385+ def messages = new net.sf.json.JSONArray ()
376386
377387 for (file in files) {
378- messages . add( [
388+ def commands = [
379389 // Export "php" container id into shared file (We use ''' has we don't want groovy interpolation for $)
380390 // And clean kubernetes' docker prefix "docker://<container-id>" (Take care, pubsub uses Busybox's sed != GNU sed)
381391 [container : " pubsub" , script : ''' sh -c "kubectl get pod \\ ${POD_NAME} -o jsonpath='{$.status.containerStatuses[?(@.name==\\ "php\\ ")].containerID}' | sed 's#docker://##g' > /home/jenkins/php-container-id" ''' ],
@@ -397,10 +407,14 @@ def runPim20IntegrationTest(String phpVersion, String client, String psrImplem)
397407 junit : [in : " /home/jenkins/php-api-client/" , name : " junit_output.xml" ],
398408 script : ' php -d error_reporting="E_ALL" ./bin/phpunit -c phpunit.xml.dist ' + file+ ' --log-junit junit_output.xml'
399409 ]
400- ])
410+ ]
411+ def message = new net.sf.json.JSONObject ()
412+ message. put(" name" ,file)
413+ message. put(" commands" ,commands)
414+ messages. add(message)
401415 }
402416 return messages
403- })
417+ }, verboseOutputs, dotsPerLine )
404418}
405419
406420/**
@@ -541,7 +555,10 @@ def withPhpApi(String phpApiImageName, String phpVersion, body) {
541555 * - (Init) php-api-client : Copy php-api-client sources to /home/jenkins/php-api-client (Used for K8s PIM's template)
542556 * - (Run) gcloud : Used to manage pubsub queues and to create PIM's Kubernetes pods (Based on template)
543557 */
544- def queue (String phpApiImageName , String pimImageName , String pimVersion , String phpVersion , body ) {
558+
559+ def queue (String phpApiImageName , String pimImageName , String pimVersion , String phpVersion , body , verboseOutputs , dotsPerLine ) {
560+ def verbosity = (verboseOutputs == " yes" ) ? " -v" : " "
561+ def linesize = (dotsPerLine. isNumber())? dotsPerLine : " 50"
545562 clearTemplateNames()
546563 def uuid = UUID . randomUUID(). toString()
547564 // Maximum pods in parallel. Default set to number of messages
@@ -562,7 +579,7 @@ def queue(String phpApiImageName, String pimImageName, String pimVersion, String
562579 }
563580
564581 podTemplate(name : " php-api-client-pubsub" , label : " pubsub-" + uuid, containers : [
565- containerTemplate(name : " gcloud" , ttyEnabled : true , command : ' cat' , image : " eu.gcr.io/akeneo-ci/gcloud:1.0.17 " , resourceRequestCpu : ' 100m' , resourceRequestMemory : ' 200Mi' , envVars : [envVar(key : " PUBSUB_PROJECT_ID" , value : " akeneo-ci" )])
582+ containerTemplate(name : " gcloud" , ttyEnabled : true , command : ' cat' , image : " eu.gcr.io/akeneo-ci/gcloud:1.0" , alwaysPullImage : true , resourceRequestCpu : ' 100m' , resourceRequestMemory : ' 200Mi' , envVars : [envVar(key : " PUBSUB_PROJECT_ID" , value : " akeneo-ci" )])
566583 ], annotations : [
567584 podAnnotation(key : " pod.beta.kubernetes.io/init-containers" , value :
568585 """
@@ -612,7 +629,7 @@ def queue(String phpApiImageName, String pimImageName, String pimVersion, String
612629 try {
613630 sh " cat /home/jenkins/php-api-client/.ci/k8s/${ k8s_template} "
614631 sh " kubectl apply -f /home/jenkins/php-api-client/.ci/k8s/${ k8s_template} "
615- sh " gcloud.phar job:wait ${ env.NODE_NAME} -results-subscription ${ size} ${ env.WORKSPACE} --ansi"
632+ sh " gcloud.phar ${ verbosity } job:wait --dotsperline ${ linesize } ${ env.NODE_NAME} -results-subscription ${ size} ${ env.WORKSPACE} --ansi"
616633 } finally {
617634 sh " kubectl delete job ${ env.NODE_NAME} "
618635 sh " gcloud.phar pubsub:topic:delete ${ env.NODE_NAME} "
0 commit comments