Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 97735bb

Browse files
committed
Skipping stock deploy, adding new command.
1 parent 6862632 commit 97735bb

File tree

5 files changed

+89
-29
lines changed

5 files changed

+89
-29
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Magento\NewRelicReporting\Console\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Console\Input\InputArgument;
9+
10+
use Magento\NewRelicReporting\Model\Apm\DeploymentsFactory;
11+
use Magento\NewRelicReporting\Model\ServiceShellUser;
12+
13+
class DeployMarker extends Command
14+
{
15+
protected $deploymentsFactory;
16+
protected $serviceShellUser;
17+
18+
public function __construct(
19+
DeploymentsFactory $deploymentsFactory,
20+
ServiceShellUser $serviceShellUser,
21+
$name = null
22+
) {
23+
$this->deploymentsFactory = $deploymentsFactory;
24+
$this->serviceShellUser = $serviceShellUser;
25+
parent::__construct($name);
26+
}
27+
28+
protected function configure()
29+
{
30+
$this->setName("newrelic:create:deploy-marker");
31+
$this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
32+
->addArgument(
33+
'message',
34+
InputArgument::REQUIRED,
35+
'Deploy Message?'
36+
)
37+
->addArgument(
38+
'changelog',
39+
InputArgument::REQUIRED,
40+
'Change Log?'
41+
)
42+
->addArgument(
43+
'user',
44+
InputArgument::OPTIONAL,
45+
'Deployment User'
46+
);
47+
parent::configure();
48+
}
49+
50+
protected function execute(InputInterface $input, OutputInterface $output)
51+
{
52+
$this->deploymentsFactory->create()->setDeployment(
53+
$input->getArgument('message'),
54+
$input->getArgument('changelog'),
55+
$this->serviceShellUser->get($input->getArgument('user'))
56+
);
57+
$output->writeln('<info>NewRelic deployment information sent</info>');
58+
}
59+
}

app/code/Magento/NewRelicReporting/Model/Cron/ReportNewRelicCron.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ protected function reportCounts()
175175
public function report()
176176
{
177177
if ($this->config->isNewRelicEnabled()) {
178-
$this->reportModules();
179178
$this->reportCounts();
180179
}
181180

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Magento\NewRelicReporting\Model;
4+
5+
class ServiceShellUser
6+
{
7+
const DEFAULT_USER = 'cron';
8+
9+
public function get($userFromArgument = false)
10+
{
11+
if ($userFromArgument) {
12+
return $userFromArgument;
13+
}
14+
15+
$user = `echo \$USER`;
16+
if ($user) {
17+
return $user;
18+
}
19+
20+
return self::DEFAULT_USER;
21+
}
22+
}

app/code/Magento/NewRelicReporting/Test/Unit/Model/Cron/ReportNewRelicCronTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -144,24 +144,10 @@ public function testReportNewRelicCronModuleDisabledFromConfig()
144144
*/
145145
public function testReportNewRelicCron()
146146
{
147-
$testModuleData = [
148-
'changes' => [
149-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'enabled'],
150-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'disabled'],
151-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'installed'],
152-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'uninstalled'],
153-
],
154-
'enabled' => 1,
155-
'disabled' => 1,
156-
'installed' => 1,
157-
];
158147

159148
$this->config->expects($this->once())
160149
->method('isNewRelicEnabled')
161150
->willReturn(true);
162-
$this->collect->expects($this->once())
163-
->method('getModuleData')
164-
->willReturn($testModuleData);
165151
$this->counter->expects($this->once())
166152
->method('getAllProductsCount');
167153
$this->counter->expects($this->once())
@@ -198,24 +184,10 @@ public function testReportNewRelicCron()
198184
*/
199185
public function testReportNewRelicCronRequestFailed()
200186
{
201-
$testModuleData = [
202-
'changes' => [
203-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'enabled'],
204-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'disabled'],
205-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'installed'],
206-
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'uninstalled'],
207-
],
208-
'enabled' => 1,
209-
'disabled' => 1,
210-
'installed' => 1,
211-
];
212187

213188
$this->config->expects($this->once())
214189
->method('isNewRelicEnabled')
215190
->willReturn(true);
216-
$this->collect->expects($this->once())
217-
->method('getModuleData')
218-
->willReturn($testModuleData);
219191
$this->counter->expects($this->once())
220192
->method('getAllProductsCount');
221193
$this->counter->expects($this->once())

app/code/Magento/NewRelicReporting/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@
3030
<type name="Magento\Framework\App\Http">
3131
<plugin name="framework-http-newrelic" type="Magento\NewRelicReporting\Plugin\HttpPlugin"/>
3232
</type>
33+
<type name="Magento\Framework\Console\CommandList">
34+
<arguments>
35+
<argument name="commands" xsi:type="array">
36+
<item name="magento_new_relic_reporting_command_deploy_marker"
37+
xsi:type="object">Magento\NewRelicReporting\Console\Command\DeployMarker</item>
38+
</argument>
39+
</arguments>
40+
</type>
3341
</config>

0 commit comments

Comments
 (0)