Skip to content

Commit 47c3c7b

Browse files
keithbentrupshiftedreality
authored andcommitted
MAGECLOUD-3940: Use more OS agnostic form to find number of processors (#569)
1 parent 9dca4e9 commit 47c3c7b

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ matrix:
5050
env: TEST_SUITE=functional
5151

5252
install:
53-
- composer config http-basic.repo.magento.com ${REPO_USERNAME} ${REPO_PASSWORD}
53+
- if [ $TRAVIS_SECURE_ENV_VARS != "true" ]; then composer remove magento/magento-cloud-components --no-update; fi;
54+
- if [ $TRAVIS_SECURE_ENV_VARS != "true" ]; then composer config --unset repositories.repo.magento.com; fi;
55+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then composer config http-basic.repo.magento.com ${REPO_USERNAME} ${REPO_PASSWORD}; fi;
5456
- composer update -n --no-suggest
5557

5658
before_script:
@@ -62,7 +64,7 @@ before_script:
6264

6365
script:
6466
- if [ $TEST_SUITE == "static-unit" ]; then ./tests/travis/static-unit.sh; fi
65-
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "integration" ]; then ./tests/travis/integration.sh; fi
66-
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi
67+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "integration" ]; then ./tests/travis/integration.sh; fi;
68+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi;
6769

6870
after_failure: docker ps -s

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"type": "magento2-component",
55
"version": "2002.0.20",
66
"license": "OSL-3.0",
7-
"repositories": [
8-
{
7+
"repositories": {
8+
"repo.magento.com": {
99
"type": "composer",
1010
"url": "https://repo.magento.com/"
1111
}
12-
],
12+
},
1313
"require": {
1414
"php": "^7.0",
1515
"ext-PDO": "*",

src/Test/Unit/Util/CpuTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testGetTreadsCount()
5151
->willReturn('8');
5252
$this->shellMock->expects($this->once())
5353
->method('execute')
54-
->with('grep -c processor /proc/cpuinfo')
54+
->with('nproc')
5555
->willReturn($processMock);
5656

5757
$this->assertEquals(8, $this->cpu->getThreadsCount());

src/Util/Cpu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(ShellInterface $shell, LoggerInterface $logger)
4545
public function getThreadsCount(): int
4646
{
4747
try {
48-
$result = $this->shell->execute('grep -c processor /proc/cpuinfo');
48+
$result = $this->shell->execute('nproc');
4949
$threadCount = (int)$result->getOutput() ?? 1;
5050
} catch (ShellException $e) {
5151
$this->logger->error('Can\'t get system processor count: ' . $e->getMessage());

0 commit comments

Comments
 (0)