File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Process/Build/DeployStaticContent Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public function execute()
70
70
try {
71
71
$ locales = $ this ->buildOption ->getLocales ();
72
72
$ excludeThemes = $ this ->buildOption ->getExcludedThemes ();
73
- $ threadCount = $ this ->buildOption ->getThreadCount ();
73
+ $ threadCount = $ this ->buildOption ->getThreadCount ();
74
74
75
75
$ logMessage = 'Generating static content for locales: ' . implode (' ' , $ locales );
76
76
Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \MagentoCloud \StaticContent ;
7
7
8
+ use Psr \Log \LoggerInterface ;
9
+
8
10
class ThreadCountOptimizer
9
11
{
10
12
/**
@@ -19,6 +21,19 @@ class ThreadCountOptimizer
19
21
*/
20
22
const THREAD_COUNT_COMPACT_STRATEGY = 1 ;
21
23
24
+ /**
25
+ * @var LoggerInterface
26
+ */
27
+ private $ logger ;
28
+
29
+ /**
30
+ * @param LoggerInterface $logger
31
+ */
32
+ public function __construct (LoggerInterface $ logger )
33
+ {
34
+ $ this ->logger = $ logger ;
35
+ }
36
+
22
37
/**
23
38
* Defines best thread count value based on deploy strategy name
24
39
*
@@ -29,6 +44,12 @@ class ThreadCountOptimizer
29
44
public function optimize (int $ threads , string $ strategy ): int
30
45
{
31
46
if ($ strategy === self ::STRATEGY_COMPACT ) {
47
+ if ($ threads !== self ::THREAD_COUNT_COMPACT_STRATEGY ) {
48
+ $ this ->logger ->notice (
49
+ 'Threads count was forced to 1 as compact strategy can \'t be run with more than one job '
50
+ );
51
+ }
52
+
32
53
return self ::THREAD_COUNT_COMPACT_STRATEGY ;
33
54
}
34
55
Original file line number Diff line number Diff line change 7
7
8
8
use Magento \MagentoCloud \StaticContent \ThreadCountOptimizer ;
9
9
use PHPUnit \Framework \TestCase ;
10
+ use PHPUnit_Framework_MockObject_MockObject as Mock ;
11
+ use Psr \Log \LoggerInterface ;
10
12
11
13
class ThreadCountOptimizerTest extends TestCase
12
14
{
@@ -15,9 +17,16 @@ class ThreadCountOptimizerTest extends TestCase
15
17
*/
16
18
private $ optimizer ;
17
19
20
+ /**
21
+ * @var LoggerInterface|Mock
22
+ */
23
+ private $ loggerMock ;
24
+
18
25
protected function setUp ()
19
26
{
20
- $ this ->optimizer = new ThreadCountOptimizer ();
27
+ $ this ->loggerMock = $ this ->getMockForAbstractClass (LoggerInterface::class);
28
+
29
+ $ this ->optimizer = new ThreadCountOptimizer ($ this ->loggerMock );
21
30
}
22
31
23
32
/**
@@ -57,4 +66,16 @@ public function optimizeDataProvider(): array
57
66
]
58
67
];
59
68
}
69
+
70
+ public function testOptimizeWithNotice ()
71
+ {
72
+ $ this ->loggerMock ->expects ($ this ->once ())
73
+ ->method ('notice ' )
74
+ ->with ('Threads count was forced to 1 as compact strategy can \'t be run with more than one job ' );
75
+
76
+ $ this ->assertEquals (
77
+ 1 ,
78
+ $ this ->optimizer ->optimize (3 , ThreadCountOptimizer::STRATEGY_COMPACT )
79
+ );
80
+ }
60
81
}
You can’t perform that action at this time.
0 commit comments