Limit CPU threads usage for docker container in SaltModelTesting
add a new argument for setupAndTestNode(): int/float dockerMaxCpus
Change-Id: If905398149fe0dae6a98d3fe9cdaf6896dbc1b4d
diff --git a/src/com/mirantis/mk/SaltModelTesting.groovy b/src/com/mirantis/mk/SaltModelTesting.groovy
index 9c41af1..5434fff 100644
--- a/src/com/mirantis/mk/SaltModelTesting.groovy
+++ b/src/com/mirantis/mk/SaltModelTesting.groovy
@@ -11,7 +11,7 @@
* @param formulasRevision APT revision for formulas (optional default stable)
*/
-def setupAndTestNode(masterName, extraFormulas, testDir, formulasSource = 'pkg', formulasRevision = 'stable') {
+def setupAndTestNode(masterName, extraFormulas, testDir, formulasSource = 'pkg', formulasRevision = 'stable', dockerMaxCpus = 0) {
def saltOpts = "--retcode-passthrough --force-color"
def common = new com.mirantis.mk.Common()
def workspace = common.getWorkspace()
@@ -29,7 +29,12 @@
extraFormulas = "linux"
}
- img.inside("-u root:root --hostname=${masterName}") {
+ def dockerMaxCpusOption = ""
+ if (dockerMaxCpus > 0) {
+ dockerMaxCpusOption = "--cpus=${dockerMaxCpus}"
+ }
+
+ img.inside("-u root:root --hostname=${masterName} ${dockerMaxCpusOption}") {
def is_mk_ci
try {