* php cs fixes, testing ci build

This commit is contained in:
Dávid Danyi 2017-03-22 16:01:34 +01:00
parent 8d7f1b68c6
commit 951ca64943
7 changed files with 135 additions and 79 deletions

View File

@ -20,7 +20,12 @@ class CiConfig implements JsonSerializable
private $id;
/**
* @ORM\OneToMany(targetEntity="CiConfigItem", mappedBy="dailyConfig", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\OneToMany(
* targetEntity="CiConfigItem",
* mappedBy="dailyConfig",
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
* @var CiConfigItem[]
*/
private $configItems;
@ -75,7 +80,7 @@ class CiConfig implements JsonSerializable
*/
public function addConfigItem(CiConfigItem $item): CiConfig
{
if(!$this->configItems->contains($item)) {
if (!$this->configItems->contains($item)) {
$this->configItems->add($item);
$item->setDailyConfig($this);
}
@ -100,7 +105,7 @@ class CiConfig implements JsonSerializable
*/
public function removeConfigItem(CiConfigItem $item): CiConfig
{
if($this->configItems->contains($item)) {
if ($this->configItems->contains($item)) {
$this->configItems->removeElement($item);
}
return $this;

View File

@ -285,7 +285,7 @@ class CiConfigItem implements JsonSerializable
*/
public function removeNode(string $node): CiConfigItem
{
$this->nodes = array_filter($this->nodes, function($item) use ($node) {
$this->nodes = array_filter($this->nodes, function ($item) use ($node) {
return $item != $node;
});
return $this;

View File

@ -7,6 +7,18 @@ use Psr\Http\Message\ResponseInterface;
class PreFlightMiddleware
{
const ALLOW_HEADERS = [
'DNT',
'X-CustomHeader',
'Keep-Alive',
'User-Agent',
'X-Requested-With',
'If-Modified-Since',
'Cache-Control',
'Content-Type',
'Authorization',
];
public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next)
{
$requestMethod = strtoupper($request->getMethod());
@ -15,7 +27,7 @@ class PreFlightMiddleware
->withHeader('Accept', 'OPTIONS,GET,POST,PUT,PATCH,DELETE')
->withHeader('Access-Control-Allow-Origin', '*')
->withHeader('Access-Control-Allow-Methods', 'OPTIONS,GET,POST,PUT,PATCH,DELETE')
->withHeader('Access-Control-Allow-Headers', 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization');
->withHeader('Access-Control-Allow-Headers', implode(",", self::ALLOW_HEADERS));
}
return $next($request, $response);
}

View File

@ -6,14 +6,27 @@ use Zend\Diactoros\Response\JsonResponse;
class JsonCorsResponse extends JsonResponse
{
public function __construct($data,
const ALLOW_HEADERS = [
'DNT',
'X-CustomHeader',
'Keep-Alive',
'User-Agent',
'X-Requested-With',
'If-Modified-Since',
'Cache-Control',
'Content-Type',
'Authorization',
];
public function __construct(
$data,
$status = 200,
array $headers = [],
$encodingOptions = self::DEFAULT_JSON_FLAGS)
{
$encodingOptions = self::DEFAULT_JSON_FLAGS
) {
$headers['Access-Control-Allow-Origin'] = '*';
$headers['Access-Control-Allow-Methods'] = 'OPTIONS,GET,POST,PUT,PATCH,DELETE';
$headers['Access-Control-Allow-Headers'] = 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
$headers['Access-Control-Allow-Headers'] = implode(",", self::ALLOW_HEADERS);
parent::__construct($data, $status, $headers, $encodingOptions);
}
}

View File

@ -86,7 +86,7 @@ class CiConfigService
*/
public function update(int $id, array $data)
{
if(null === ($entity = $this->em->find(CiConfig::class, $id))) {
if (null === ($entity = $this->em->find(CiConfig::class, $id))) {
return false;
}
$this->hydrator->hydrate($data, $entity);

View File

@ -92,7 +92,7 @@ class CiExecutorService
$cache = $this->getCache(self::JCAT_CACHE_KEY);
$result = $cache->getItem(self::PACKAGE_CACHE_KEY, $success);
if(!$success) {
if (!$success) {
$config2Html = $this->getConfig2Html();
$staplerTokens = $this->getStaplerTokens($config2Html, "JCAT_TYPE");
$packages =$this->getJcatVersions($staplerTokens['url'], $staplerTokens['token']);
@ -117,7 +117,7 @@ class CiExecutorService
$cache = $this->getCache(self::STREAM_CACHE_KEY);
$result = $cache->getItem(self::STREAM_CACHE_KEY, $success);
if(!$success) {
if (!$success) {
$config2Html = $this->getConfig2Html();
$streams =$this->getStreams($config2Html);
$cache->setItem(self::STREAM_CACHE_KEY, serialize($streams));
@ -159,9 +159,10 @@ class CiExecutorService
// if(0 == count($availableNodes)) {
// return false;
// }
// @todo remove this part, and check for sub-job success that also needs to be saved, if any node fails, all nodes fail now
foreach($nodes as $node) {
if(!$this->isNodeOnline($node) || !$this->isNodeIdle($node)) {
// @todo remove this part, and check for sub-job success that also needs to be saved
// if any node fails, all nodes fail now
foreach ($nodes as $node) {
if (!$this->isNodeOnline($node) || !$this->isNodeIdle($node)) {
return false;
}
}
@ -170,7 +171,7 @@ class CiExecutorService
// @todo reorganize this into config1build?
$config1Status = $this->buildConfigOne($nodes);
$config1JobId = $this->getConfig1JobId();
while(!$this->isConfig1Built($config1JobId)) {
while (!$this->isConfig1Built($config1JobId)) {
sleep(2);
set_time_limit(30);
}
@ -179,7 +180,7 @@ class CiExecutorService
$config2Html = $this->getConfig2Html();
$streams = $this->getStreams($config2Html);
$staplerTokens = $this->getStaplerTokens($config2Html, "STREAM");
if(true === ($streamExists = in_array($configItem->getStream(), $streams))) {
if (true === ($streamExists = in_array($configItem->getStream(), $streams))) {
$package = $this->getPackage($configItem->getStream(), $staplerTokens['url'], $staplerTokens['token']);
} else {
$package = false;
@ -187,11 +188,11 @@ class CiExecutorService
$jcatVersions = $this->getJcatVersions($staplerTokens['url'], $staplerTokens['token']);
// Check if the desired JCAT version is available, try to create it if it's not
if(!in_array($configItem->getJcat(), $jcatVersions)) {
if (!in_array($configItem->getJcat(), $jcatVersions)) {
// wait for jcat package to become available
$this->addJcatPackageToJenkins($configItem->getJcat());
$jcatDeployJobId = $this->getJcatDeployJobId();
while(!$this->isJcatPackageDeployed($jcatDeployJobId)) {
while (!$this->isJcatPackageDeployed($jcatDeployJobId)) {
sleep(2);
set_time_limit(30);
}
@ -200,18 +201,24 @@ class CiExecutorService
$nodeBases = [];
$nodeTraffics = [];
foreach($nodes as $type => $typeNodes) {
foreach($typeNodes as $node => $backupPostfix) {
if(false === strpos($node, "-")) {
foreach ($nodes as $type => $typeNodes) {
foreach ($typeNodes as $node => $backupPostfix) {
if (false === strpos($node, "-")) {
$nodeBaseName = sprintf("%s_%s", $node, $backupPostfix);
$nodeBases[$node] = in_array($nodeBaseName, $this->getNodeBaseNames($config2Html, $node)) ? $nodeBaseName : false;
$nodeBases[$node] = in_array($nodeBaseName, $this->getNodeBaseNames($config2Html, $node))
? $nodeBaseName
: false;
$nodeTraffics[$node] = $this->getNodeTrafficConfigs($config2Html, $node);
} else {
list($zone1, $zone2) = explode("-", $node);
$zone1BaseName = sprintf("%s_%s", $zone1, $backupPostfix);
$zone2BaseName = sprintf("%s_%s", $zone2, $backupPostfix);
$nodeBases[$zone1] = in_array($zone1BaseName, $this->getNodeBaseNames($config2Html, $zone1)) ? $zone1BaseName : false;
$nodeBases[$zone2] = in_array($zone2BaseName, $this->getNodeBaseNames($config2Html, $zone2)) ? $zone2BaseName : false;
$nodeBases[$zone1] = in_array($zone1BaseName, $this->getNodeBaseNames($config2Html, $zone1))
? $zone1BaseName
: false;
$nodeBases[$zone2] = in_array($zone2BaseName, $this->getNodeBaseNames($config2Html, $zone2))
? $zone2BaseName
: false;
$nodeTraffics[$node] = $this->getNodeTrafficConfigs($config2Html, str_replace("-", "_", $node));
}
}
@ -250,7 +257,7 @@ class CiExecutorService
$response = $this->httpClient->send();
$body = $response->getBody();
$parsedResponse = Json::decode($body);
if($parsedResponse->building == true) {
if ($parsedResponse->building == true) {
return false;
}
@ -262,7 +269,7 @@ class CiExecutorService
$response = $this->httpClient->send();
$body = $response->getBody();
$parsedResponse = Json::decode($body);
if($parsedResponse->building == true) {
if ($parsedResponse->building == true) {
return false;
}
return true;
@ -276,12 +283,13 @@ class CiExecutorService
private function buildConfigOne($nodes): bool
{
$appendParams = [];
foreach($nodes as $type => $typeNodes) {
foreach($typeNodes as $node => $basePostfix) {
foreach ($nodes as $type => $typeNodes) {
foreach ($typeNodes as $node => $basePostfix) {
$appendParams[] = sprintf("%s=%s", $type, $node);
}
}
$this->httpClient->setUri($this->jenkinsBaseUrl . self::CONFIG_1_PATH . '/buildWithParameters?delay=0sec&' . implode("&", $appendParams));
$uri = $this->jenkinsBaseUrl . self::CONFIG_1_PATH . '/buildWithParameters?delay=0sec&';
$this->httpClient->setUri($uri . implode("&", $appendParams));
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('POST');
@ -321,7 +329,7 @@ class CiExecutorService
$response = $this->httpClient->send();
$body = $response->getBody();
$parsedResponse = Json::decode($body);
if($parsedResponse->building == false) {
if ($parsedResponse->building == false) {
if ($parsedResponse->result == 'SUCCESS') {
return true;
}
@ -342,7 +350,7 @@ class CiExecutorService
$request = $this->httpClient->getRequest();
$request->setMethod('GET');
$response = $this->httpClient->send();
if($response->getStatusCode() == 401) {
if ($response->getStatusCode() == 401) {
throw new \Exception("Not authenticated");
}
return $response->getBody();
@ -350,7 +358,8 @@ class CiExecutorService
private function getStaplerTokens($config2Body, $blockName = "STREAM")
{
if(0 === ($didMatch = preg_match(sprintf('#referencedParameters\.push\("%s"\);.*?makeStaplerProxy\(\'(.*?)\',\'(.*?)\'.*?// Create Jenkins proxy#msi', $blockName), $config2Body, $matches))) {
$pattern = '#referencedParameters\.push\("%s"\);.*?makeStaplerProxy\(\'(.*?)\',\'(.*?)\'.*?// Create#msi';
if (0 === ($didMatch = preg_match(sprintf($pattern, $blockName), $config2Body, $matches))) {
throw new \Exception("Couldn't match stapler tokens in response body");
}
return [
@ -370,11 +379,11 @@ class CiExecutorService
$xpath = new \DOMXPath($domDocument);
$element = $xpath->query($xpathQuery);
if($element->length == 0) {
if ($element->length == 0) {
throw new \Exception("Can't find STREAM");
}
if($element[0]->nextSibling->nodeName != "select") {
if ($element[0]->nextSibling->nodeName != "select") {
throw new \Exception("Can't find STREAM dropdown");
}
@ -384,7 +393,7 @@ class CiExecutorService
}
sort($streams, SORT_NATURAL);
return array_values(array_filter(array_unique($streams), function($item){
return array_values(array_filter(array_unique($streams), function ($item) {
return $item != "" && $item != "none";
}));
}
@ -400,18 +409,18 @@ class CiExecutorService
$request->setMethod('POST');
$request->setContent(sprintf('["STREAM=%s"]', $stream));
$updateResponse = $this->httpClient->send();
if(!$updateResponse->isSuccess()) {
if (!$updateResponse->isSuccess()) {
throw new \Exception("Stapler doUpdate error");
}
sleep(1);
$this->httpClient->setUri($this->jenkinsBaseUrl . $url . '/getChoicesForUI');
$request->setContent("[]");
$choicesResponse = $this->httpClient->send();
if(!$choicesResponse->isSuccess()) {
if (!$choicesResponse->isSuccess()) {
throw new \Exception("Stapler getChoicesForUI error");
}
$packages = Json::decode($choicesResponse->getBody());
if($packages[0][0] == "Script error") {
if ($packages[0][0] == "Script error") {
throw new \Exception("STREAM stapler script error");
}
return array_shift($packages[0]);
@ -461,19 +470,19 @@ class CiExecutorService
$request->setMethod('POST');
$request->setContent('["JCAT_TYPE=INSTALLED"]');
$updateResponse = $this->httpClient->send();
if(!$updateResponse->isSuccess()) {
if (!$updateResponse->isSuccess()) {
throw new \Exception("Stapler doUpdate error");
}
sleep(1);
$this->httpClient->setUri($this->jenkinsBaseUrl . $url . '/getChoicesForUI');
$request->setContent("[]");
$choicesResponse = $this->httpClient->send();
if(!$choicesResponse->isSuccess()) {
if (!$choicesResponse->isSuccess()) {
throw new \Exception("Stapler getChoicesForUI error");
}
$jcats = Json::decode($choicesResponse->getBody());
rsort($jcats[0]);
if($jcats[0][0] == "Script error") {
if ($jcats[0][0] == "Script error") {
throw new \Exception("JCAT stapler script error");
}
return $jcats[0];
@ -490,11 +499,11 @@ class CiExecutorService
$xpath = new \DOMXPath($domDocument);
$element = $xpath->query($xpathQuery);
if($element->length == 0) {
if ($element->length == 0) {
throw new \Exception(sprintf("Can't find %s_BASE_BACKUP", $nodeName));
}
if($element[0]->nextSibling->nodeName != "select") {
if ($element[0]->nextSibling->nodeName != "select") {
throw new \Exception(sprintf("Can't find %s_BASE_BACKUP dropdown", $nodeName));
}
@ -504,7 +513,9 @@ class CiExecutorService
}
rsort($baseNames, SORT_NATURAL);
return array_filter($baseNames, function($item){return $item != "";});
return array_filter($baseNames, function ($item) {
return $item != "";
});
}
private function getNodeTrafficConfigs($config2Body, $nodeName)
@ -518,11 +529,11 @@ class CiExecutorService
$xpath = new \DOMXPath($domDocument);
$element = $xpath->query($xpathQuery);
if($element->length == 0) {
if ($element->length == 0) {
throw new \Exception(sprintf("Can't find %s_TRAFFIC", $nodeName));
}
if($element[0]->nextSibling->nodeName != "select") {
if ($element[0]->nextSibling->nodeName != "select") {
throw new \Exception(sprintf("Can't find %s_TRAFFIC dropdown", $nodeName));
}
@ -532,7 +543,9 @@ class CiExecutorService
}
rsort($trafficConfigs, SORT_NATURAL);
return array_filter($trafficConfigs, function($item){return $item != "";});
return array_filter($trafficConfigs, function ($item) {
return $item != "";
});
}
@ -544,10 +557,15 @@ class CiExecutorService
* @param array $nodeTraffics
* @return bool
*/
private function buildConfigTwo(CiConfigItem $configItem, $package, array $nodes, array $nodeBases, array $nodeTraffics)
{
private function buildConfigTwo(
CiConfigItem $configItem,
$package,
array $nodes,
array $nodeBases,
array $nodeTraffics
) {
$params = [];
if(false === $package) {
if (false === $package) {
// stream doesn't exist, have to be created as new. enforces test to be nightly
$params[] = "MODE=nightly";
$params[] = "NEW_STREAM=" . $configItem->getStream();
@ -560,18 +578,18 @@ class CiExecutorService
$params[] = "JCAT_DIR__MAIN=" . $configItem->getJcat();
$params[] = "JCAT_DIR__UPGRADE=" . $configItem->getJcat();
foreach($nodes as $node) {
if(false === strpos($node, "-")) {
foreach ($nodes as $node) {
if (false === strpos($node, "-")) {
$params[] = sprintf("%s_BASE_BACKUP=%s_%s", $node, $node, $nodeBases[$node]);
} else {
list($zone1, $zone2) = explode("-", $node);
$params[] = sprintf("%s_BASE_BACKUP=%s_%s",$zone1, $zone1, $nodeBases[$zone1]);
$params[] = sprintf("%s_BASE_BACKUP=%s_%s",$zone2, $zone2, $nodeBases[$zone2]);
$params[] = sprintf("%s_BASE_BACKUP=%s_%s", $zone1, $zone1, $nodeBases[$zone1]);
$params[] = sprintf("%s_BASE_BACKUP=%s_%s", $zone2, $zone2, $nodeBases[$zone2]);
}
// todo create suites parameters
foreach ($this->testTypeMap as $callable => $paramName) {
if($configItem->$callable()) {
if ($configItem->$callable()) {
$params[] = sprintf("%s_SUITES=%s", $node, $paramName);
}
}
@ -579,7 +597,8 @@ class CiExecutorService
$params[] = sprintf("%s_TRAFFIC=%s", $node, $nodeTraffics[$node]);
}
$this->httpClient->setUri($this->jenkinsBaseUrl . self::CONFIG_2_PATH . '/buildWithParameters?delay=0sec&' . implode("&", $params));
$uri = $this->jenkinsBaseUrl . self::CONFIG_2_PATH . '/buildWithParameters?delay=0sec&';
$this->httpClient->setUri($uri . implode("&", $params));
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('POST');
@ -614,42 +633,44 @@ class CiExecutorService
preg_match('#TSP_JCAT-([0-9]{3,}\.[0-9]+)(.*)?#', $jcatVersion, $matches);
$version = $matches[1];
$deployType = trim($matches[2],"_");
$deployType = trim($matches[2], "_");
unset($matches);
// package has no type specified, or type is COMMON
if($deployType == "" || $deployType == "COMMON") {
if ($deployType == "" || $deployType == "COMMON") {
$uri = self::JCAT_DEPLOY_SOURCE_URL . sprintf("/JCAT-%s/TSP_JCAT-%s.tar.gz", $version, $version);
$this->httpClient->setUri($uri);
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('HEAD');
$response = $this->httpClient->send();
if($response->isOk()) {
if ($response->isOk()) {
return $uri;
}
return false;
}
// package type specified exists on jcat server
$uri = self::JCAT_DEPLOY_SOURCE_URL . sprintf("/JCAT-%s-%s/TSP_JCAT-%s-%s.tar.gz", $deployType, $version, $deployType, $version);
$filePattern = "/JCAT-%s-%s/TSP_JCAT-%s-%s.tar.gz";
$uri = self::JCAT_DEPLOY_SOURCE_URL . sprintf($filePattern, $deployType, $version, $deployType, $version);
$this->httpClient->setUri($uri);
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('HEAD');
$response = $this->httpClient->send();
if($response->isOk()) {
if ($response->isOk()) {
return $uri;
}
// package type specified exists with 'TSP' prefix on jcat server
$uri = self::JCAT_DEPLOY_SOURCE_URL . sprintf("/JCAT-TSP%s-%s/TSP_JCAT-TSP%s-%s.tar.gz", $deployType, $version, $deployType, $version);
$filePattern = "/JCAT-TSP%s-%s/TSP_JCAT-TSP%s-%s.tar.gz";
$uri = self::JCAT_DEPLOY_SOURCE_URL . sprintf($filePattern, $deployType, $version, $deployType, $version);
$this->httpClient->setUri($uri);
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('HEAD');
$response = $this->httpClient->send();
if($response->isOk()) {
if ($response->isOk()) {
return $uri;
}
return false;
@ -664,10 +685,11 @@ class CiExecutorService
"NEW_DEPLOY_URL=$jcatDeployUri",
"ACTION=add",
];
foreach($availableJcatTargetNodes as $node) {
foreach ($availableJcatTargetNodes as $node) {
$appendParams[] = "NODES=$node";
}
$this->httpClient->setUri($this->jenkinsBaseUrl . self::ADD_JCAT_PATH . '/buildWithParameters?delay=0sec&' . implode("&", $appendParams));
$uri = $this->jenkinsBaseUrl . self::ADD_JCAT_PATH . '/buildWithParameters?delay=0sec&';
$this->httpClient->setUri($uri . implode("&", $appendParams));
$this->httpClient->resetParameters(false, false);
$request = $this->httpClient->getRequest();
$request->setMethod('POST');
@ -700,7 +722,7 @@ class CiExecutorService
$response = $this->httpClient->send();
$body = $response->getBody();
$parsedResponse = Json::decode($body);
if($parsedResponse->inQueue == false) {
if ($parsedResponse->inQueue == false) {
if ($parsedResponse->lastBuild->number == $parsedResponse->lastSuccessfulBuild->number) {
return true;
}
@ -725,11 +747,11 @@ class CiExecutorService
$xpath = new \DOMXPath($domDocument);
$element = $xpath->query($xpathQuery);
if($element->length == 0) {
if ($element->length == 0) {
throw new \Exception("Can't find NODES");
}
if($element[0]->nextSibling->nodeName != "select") {
if ($element[0]->nextSibling->nodeName != "select") {
throw new \Exception("Can't find NODES dropdown");
}
@ -750,7 +772,7 @@ class CiExecutorService
$request = $this->httpClient->getRequest();
$request->setMethod('HEAD');
$response = $this->httpClient->send();
if($response->isRedirect()) {
if ($response->isRedirect()) {
$this->httpClient->setOptions(['maxredirects' => 5]);
return rtrim($response->getHeaders()->get("location")->getFieldValue(), "/");
}

View File

@ -8,7 +8,8 @@ class CiNodeService
private $nodes = [
[
"name" => 'esx4b', "type" => 'esx', "size" => 1, "team" => "detoqs",
"bases" => ["7101_base_Jenkins_CI_20161006"], "defaultBase" => "7101_base_Jenkins_CI_20161006", "canAutoStart" => true,
"bases" => ["7101_base_Jenkins_CI_20161006"], "defaultBase" => "7101_base_Jenkins_CI_20161006",
"canAutoStart" => true,
],
[
"name" => 'esx10a', "type" => 'esx', "size" => 1, "team" => "detoqs",
@ -32,7 +33,8 @@ class CiNodeService
],
[
"name" => 'takumi', "type" => 'esx', "size" => 1, "team" => "detoqs",
"bases" => ["7000_base_Jenkins_CI_20160701"], "defaultBase" => "7000_base_Jenkins_CI_20160701", "canAutoStart" => true,
"bases" => ["7000_base_Jenkins_CI_20160701"], "defaultBase" => "7000_base_Jenkins_CI_20160701",
"canAutoStart" => true,
],
[
"name" => 'cwsled', "type" => 'maia', "size" => 1, "team" => "taurus",
@ -84,11 +86,13 @@ class CiNodeService
],
[
"name" => 'natasha', "type" => 'nsp6.1', "size" => 2, "team" => "trex",
"bases" => ["7101_base_Jenkins_CI_20161217"], "defaultBase" => "7101_base_Jenkins_CI_20161217", "canAutoStart" => true,
"bases" => ["7101_base_Jenkins_CI_20161217"], "defaultBase" => "7101_base_Jenkins_CI_20161217",
"canAutoStart" => true,
],
[
"name" => 'mazsola-tade', "type" => 'nsp6.1', "size" => 1, "team" => "vikinx",
"bases" => ["7111_base_Jenkins_CI_20170130"], "defaultBase" => "7111_base_Jenkins_CI_20170130", "canAutoStart" => true,
"bases" => ["7111_base_Jenkins_CI_20170130"], "defaultBase" => "7111_base_Jenkins_CI_20170130",
"canAutoStart" => true,
],
[
"name" => 'pikkolo', "type" => 'nsp6.1', "size" => 1, "team" => "taurus",
@ -131,21 +135,21 @@ class CiNodeService
public function getNode($node): ?array
{
return array_pop(array_filter($this->nodes, function($item) use ($node) {
return array_pop(array_filter($this->nodes, function ($item) use ($node) {
return $item['name'] == $node;
}));
}
public function getTestNodeList(array $nodes): ?array
{
$filteredNodes = array_filter($this->nodes, function($item) use ($nodes) {
$filteredNodes = array_filter($this->nodes, function ($item) use ($nodes) {
return in_array($item['name'], $nodes);
});
$result = [];
foreach ($filteredNodes as $filteredNode) {
$type = strtoupper($filteredNode['type']);
if(!isset($result[$type])) {
if (!isset($result[$type])) {
$result[$type] = [];
}
$result[$type][$filteredNode['name']] = $filteredNode['defaultBase'];