Skip to content

Commit e017005

Browse files
mr-prudClementGautier
authored andcommitted
Cloud 437 (#102)
* CLOUD-437 * fix syntax * move userinput * fix * fix * Update Jenkinsfile (#107) * Update pim_17_ce.dev.yaml * Update Jenkinsfile * Update pim_17_ce.yaml * Update pim_20_ce.dev.yaml * Update pim_20_ce.yaml * fix conflic
1 parent 96d3386 commit e017005

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

.ci/Jenkinsfile

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ String launchUnitTests = "yes"
66
String launchIntegrationTests = "yes"
77
String[] pimVersions = ["1.7", "2.0"]
88
String[] supportedPhpVersions = ["5.6", "7.0", "7.1"]
9+
String verboseOutputs = "yes"
10+
String dotsPerLine = "50"
11+
912
def 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\nno', description: 'Run unit tests and code style checks', name: 'launchUnitTests'),
3033
choice(choices: 'yes\nno', description: 'Run integration tests', name: 'launchIntegrationTests'),
34+
choice(choices: 'no\nyes', 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\nyes', 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}"

.ci/k8s/pim_17_ce.dev.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ spec:
103103
resources:
104104
requests: {cpu: "300m", memory: "300Mi"}
105105
- name: pubsub
106-
image: eu.gcr.io/akeneo-ci/gcloud:1.0.17
106+
image: eu.gcr.io/akeneo-ci/gcloud:1.0
107+
imagePullPolicy: Always
107108
command: ["/bin/sh", "-c"]
108109
args:
109110
- |

.ci/k8s/pim_17_ce.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ spec:
8585
resources:
8686
requests: {cpu: "500m", memory: "750Mi"}
8787
- name: pubsub
88-
image: eu.gcr.io/akeneo-ci/gcloud:1.0.17
88+
image: eu.gcr.io/akeneo-ci/gcloud:1.0
89+
imagePullPolicy: Always
90+
8991
command: ["/bin/sh", "-c"]
9092
args:
9193
- |

.ci/k8s/pim_20_ce.dev.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ spec:
140140
timeoutSeconds: 1
141141
initialDelaySeconds: 5
142142
- name: pubsub
143-
image: eu.gcr.io/akeneo-ci/gcloud:1.0.17
143+
image: eu.gcr.io/akeneo-ci/gcloud:1.0
144+
imagePullPolicy: Always
145+
144146
command: ["/bin/sh", "-c"]
145147
args:
146148
- |

.ci/k8s/pim_20_ce.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ spec:
122122
timeoutSeconds: 1
123123
initialDelaySeconds: 5
124124
- name: pubsub
125-
image: eu.gcr.io/akeneo-ci/gcloud:1.0.17
125+
image: eu.gcr.io/akeneo-ci/gcloud:1.0
126+
imagePullPolicy: Always
126127
command: ["/bin/sh", "-c"]
127128
args:
128129
- |

0 commit comments

Comments
 (0)