http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/error.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/error.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/error.hbs new file mode 100644 index 0000000..c546bf7 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/error.hbs @@ -0,0 +1,19 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<h3 align = "center">Sorry, Error Occured.</h3>
http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/notfound.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/notfound.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/notfound.hbs new file mode 100644 index 0000000..588ea44 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/notfound.hbs @@ -0,0 +1,20 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<h2 align = "center">404, Not Found</h2> +<h4 align = "center">Please Check your URL</h4> http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-apps.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-apps.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-apps.hbs index e58d6bd..3a79080 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-apps.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-apps.hbs @@ -1,3 +1,3 @@ {{app-table table-id="apps-table" arr=model}} -{{simple-table table-id="apps-table" bFilter=true colTypes="elapsed-time" colTargets="7"}} -{{outlet}} \ No newline at end of file +{{simple-table table-id="apps-table" bFilter=true colsOrder="0,desc" colTypes="natural elapsed-time" colTargets="0 7"}} +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-container-log.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-container-log.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-container-log.hbs new file mode 100644 index 0000000..9cc3b0f --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-container-log.hbs @@ -0,0 +1,36 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + {{node-menu path="yarnContainerLog" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + <div class="col-md-10"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h5 align="center"><b>{{model.containerLog.logFileName}} for {{model.containerLog.containerID}}</b></h5> + </div> + <div class="panel-body"> + {{#if model.containerLog.logs}} + <pre>{{model.containerLog.logs}}</pre> + {{else}} + <p>No logs were written in {{model.containerLog.logFileName}}.</p> + {{/if}} + </div> + </div> + </div> +</div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-app.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-app.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-app.hbs new file mode 100644 index 0000000..4da64b8 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-app.hbs @@ -0,0 +1,60 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + <div class="row"> + {{node-menu path="yarnNodeApp" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + <div class="col-md-10 container-fluid"> + <div class="panel panel-default"> + <div class="panel-heading"><b>Application Information</b></div> + <table class="table"> + <tbody> + <tr> + <td>Application ID</td> + <td>{{model.nodeApp.appId}}</td> + </tr> + <tr> + <td>Application State</td> + <td>{{model.nodeApp.state}}</td> + </tr> + <tr> + <td>User</td> + <td>{{model.nodeApp.user}}</td> + </tr> + </tbody> + </table> + </div> + <table id="node-app-table" class="display table table-striped table-bordered" cellspacing="0"> + <thead> + <tr> + <th>Containers for {{model.nodeApp.appId}}</th> + </tr> + </thead> + <tbody> + {{#each model.nodeApp.containers as |container|}} + <tr> + <td><a href="yarnNodeContainer/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{container}}">{{container}}</a></td> + </tr> + {{/each}} + </tbody> + </table> + {{simple-table table-id="node-app-table" bFilter=true colsOrder="0,desc" colTypes="natural" colTargets="0"}} + </div> + </div> + </div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-apps.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-apps.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-apps.hbs new file mode 100644 index 0000000..c195397 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-apps.hbs @@ -0,0 +1,51 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + <div class="row"> + {{node-menu path="yarnNodeApps" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + <div class="col-md-10 container-fluid"> + <table id="node-apps-table" class="display table table-striped table-bordered" cellspacing="0" width="100%"> + <thead> + <tr> + <th>Application ID</th> + <th>State</th> + <th>User</th> + </tr> + </thead> + <tbody> + {{#if model.apps}} + {{#each model.apps as |app|}} + {{#if app.isDummyApp}} + <tr><td colspan="3" align="center">No apps found on this node</td></tr> + {{else}} + <tr> + <td><a href="yarnNodeApp/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{app.appId}}">{{app.appId}}</a></td> + <td><span class={{app.appStateStyle}}>{{app.state}}</span></td> + <td>{{app.user}}</td> + </tr> + {{/if}} + {{/each}} + {{/if}} + </tbody> + </table> + {{simple-table table-id="node-apps-table" bFilter=true colsOrder="0,desc" colTypes="natural" colTargets="0"}} + </div> + </div> +</div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-container.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-container.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-container.hbs new file mode 100644 index 0000000..fbbb2fc --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-container.hbs @@ -0,0 +1,70 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + <div class="row"> + {{node-menu path="yarnNodeContainer" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + <div class="col-md-10 container-fluid"> + <div class="panel panel-default"> + <div class="panel-heading"><b>Container Information</b></div> + <table class="table"> + <tbody> + <tr> + <td>Container ID</td> + <td>{{model.nodeContainer.containerId}}</td> + </tr> + <tr> + <td>Container State</td> + <td>{{model.nodeContainer.state}}</td> + </tr> + <tr> + <td>Exit Code</td> + <td>{{model.nodeContainer.exitCode}}</td> + </tr> + <tr> + <td>Diagnostics</td> + <td>{{model.nodeContainer.diagnostics}}</td> + </tr> + <tr> + <td>User</td> + <td>{{model.nodeContainer.user}}</td> + </tr> + <tr> + <td>Total Memory Needed</td> + <td>{{model.nodeContainer.totalMemoryNeeded}} MB</td> + </tr> + <tr> + <td>Total VCores Needed</td> + <td>{{model.nodeContainer.totalVCoresNeeded}}</td> + </tr> + <tr> + <td>Link to Logs</td> + <td> + {{log-files-comma nodeId=model.nodeInfo.id + nodeAddr=model.nodeInfo.addr + containerId=model.nodeContainer.containerId + logFiles=model.nodeContainer.containerLogFiles}} + </td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + </div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-containers.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-containers.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-containers.hbs new file mode 100644 index 0000000..ca80ccd --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node-containers.hbs @@ -0,0 +1,58 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + <div class="row"> + {{node-menu path="yarnNodeContainers" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + <div class="col-md-10 container-fluid"> + <table id="node-containers-table" class="display table table-striped table-bordered" cellspacing="0" width="100%"> + <thead> + <tr> + <th>Container ID</th> + <th>Container State</th> + <th>User</th> + <th>Logs</th> + </tr> + </thead> + <tbody> + {{#if model.containers}} + {{#each model.containers as |container|}} + {{#if container.isDummyContainer}} + <tr><td colspan="4" align="center">No containers found on this node</td></tr> + {{else}} + <tr> + <td><a href="yarnNodeContainer/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{container.containerId}}">{{container.containerId}}</a></td> + <td><span class={{container.containerStateStyle}}>{{container.state}}</span></td> + <td>{{container.user}}</td> + <td> + {{log-files-comma nodeId=model.nodeInfo.id + nodeAddr=model.nodeInfo.addr + containerId=container.containerId + logFiles=container.containerLogFiles}} + </td> + </tr> + {{/if}} + {{/each}} + {{/if}} + </tbody> + </table> + {{simple-table table-id="node-containers-table" bFilter=true colsOrder="0,desc" colTypes="natural" colTargets="0"}} + </div> + </div> +</div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node.hbs new file mode 100644 index 0000000..a036076 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-node.hbs @@ -0,0 +1,94 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<div class="col-md-12 container-fluid"> + <div class="row"> + {{node-menu path="yarnNode" nodeId=model.rmNode.id nodeAddr=model.node.id}} + <div class="col-md-10 container-fluid"> + <div class="panel panel-default"> + <div class="panel-heading">Node Information</div> + <table class="table"> + <tbody> + <tr> + <td>Total Vmem allocated for Containers</td> + <td>{{divide num=model.node.totalVmemAllocatedContainersMB den=1024}} GB</td> + </tr> + <tr> + <td>Vmem enforcement enabled</td> + <td>{{model.node.vmemCheckEnabled}}</td> + </tr> + <tr> + <td>Total Pmem allocated for Containers</td> + <td>{{divide num=model.node.totalPmemAllocatedContainersMB den=1024}} GB</td> + </tr> + <tr> + <td>Pmem enforcement enabled</td> + <td>{{model.node.pmemCheckEnabled}}</td> + </tr> + <tr> + <td>Total VCores allocated for Containers</td> + <td>{{model.node.totalVCoresAllocatedContainers}}</td> + </tr> + <tr> + <td>Node Healthy Status</td> + <td>{{model.node.nodeHealthy}}</td> + </tr> + <tr> + <td>Last Node Health Report Time</td> + <td>{{model.node.lastNodeUpdateTime}}</td> + </tr> + <tr> + <td>Node Health Report</td> + <td>{{model.node.healthReport}}</td> + </tr> + <tr> + <td>Node Manager Start Time</td> + <td>{{model.node.nmStartupTime}}</td> + </tr> + <tr> + <td>Node Manager Version</td> + <td>{{model.node.nodeManagerBuildVersion}}</td> + </tr> + <tr> + <td>Hadoop Version</td> + <td>{{model.node.hadoopBuildVersion}}</td> + </tr> + </tbody> + </table> + </div> + <div class="col-lg-4 container-fluid" id="mem-donut-chart"> + {{donut-chart data=model.rmNode.getMemoryDataForDonutChart + title="Resource - Memory (in MB)" + showLabels=true + parentId="mem-donut-chart" + ratio=0.55 + maxHeight=350}} + </div> + + <div class="col-lg-4 container-fluid" id="vcore-donut-chart"> + {{donut-chart data=model.rmNode.getVCoreDataForDonutChart + title="Resource - VCores" + showLabels=true + parentId="vcore-donut-chart" + ratio=0.55 + maxHeight=350}} + </div> + </div> + </div> +</div> +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-nodes.hbs ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-nodes.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-nodes.hbs new file mode 100644 index 0000000..bf2a098 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/templates/yarn-nodes.hbs @@ -0,0 +1,65 @@ +{{!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--}} + +<table id="nodes-table" class="display table table-striped table-bordered" cellspacing="0" width="100%"> + <thead> + <tr> + <th>Node Labels</th> + <th>Rack</th> + <th>Node State</th> + <th>Node Address</th> + <th>Node HTTP Address</th> + <th>Last Health Update</th> + <th>Health-Report</th> + <th>Containers</th> + <th>Mem Used</th> + <th>Mem Avail</th> + <th>VCores Used</th> + <th>VCores Avail</th> + <th>Version</th> + </tr> + </thead> + <tbody> + {{#if model}} + {{#each model as |node|}} + {{#if node.isDummyNode}} + <tr><td colspan="13" align="center">No nodes found on this cluster</td></tr> + {{else}} + <tr> + <td>{{node.nodeLabelsAsString}}</td> + <td>{{node.rack}}</td> + <td><span class={{node.nodeStateStyle}}>{{node.state}}</span></td> + <td>{{node.id}}</td> + {{node-link nodeId=node.id nodeHTTPAddress=node.nodeHTTPAddress nodeState=node.state}} + <td>{{node.lastHealthUpdate}}</td> + <td>{{node.healthReport}}</td> + <td>{{node.numContainers}}</td> + <td>{{divide num=node.usedMemoryMB den=1024}} GB</td> + <td>{{divide num=node.availMemoryMB den=1024}} GB</td> + <td>{{node.usedVirtualCores}}</td> + <td>{{node.availableVirtualCores}}</td> + <td>{{node.version}}</td> + </tr> + {{/if}} + {{/each}} + {{/if}} + </tbody> +</table> + +{{simple-table table-id="nodes-table" bFilter=true}} +{{outlet}} http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/converter.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/converter.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/converter.js index 41e6c9c..0f49a58 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/converter.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/converter.js @@ -1,3 +1,5 @@ +import Constants from 'yarn-ui/constants'; + export default { containerIdToAttemptId: function(containerId) { if (containerId) { @@ -70,5 +72,20 @@ export default { var ts = moment(date, "YYYY/MM/DD HH:mm:ss").valueOf(); return ts; } - } -} + }, + splitForContainerLogs: function(id) { + if (id) { + var splits = id.split(Constants.PARAM_SEPARATOR); + var splitLen = splits.length; + if (splitLen < 3) { + return null; + } + var fileName = splits[2]; + var index; + for (index = 3; index < splitLen; index++) { + fileName = fileName + Constants.PARAM_SEPARATOR + splits[index]; + } + return [splits[0], splits[1], fileName]; + } + }, +}; http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/sorter.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/sorter.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/sorter.js index 981429b..a9a5f7f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/sorter.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/app/utils/sorter.js @@ -1,15 +1,55 @@ import Converter from 'yarn-ui/utils/converter'; +import Ember from 'ember'; export default { _initElapsedTimeSorter: function() { - jQuery.extend(jQuery.fn.dataTableExt.oSort, { + Ember.$.extend(Ember.$.fn.dataTableExt.oSort, { "elapsed-time-pre": function (a) { return Converter.padding(Converter.elapsedTimeToMs(a), 20); }, }); }, + _initNaturalSorter: function() { + Ember.$.extend(Ember.$.fn.dataTableExt.oSort, { + "natural-asc": function (a, b) { + return naturalSort(a,b); + }, + "natural-desc": function (a, b) { + return naturalSort(a,b) * -1; + }, + }); + }, + initDataTableSorter: function() { this._initElapsedTimeSorter(); + this._initNaturalSorter(); }, +}; + +/** + * Natural sort implementation. + * Typically used to sort application Ids'. + */ +function naturalSort(a, b) { + var diff = a.length - b.length; + if (diff != 0) { + var splitA = a.split("_"); + var splitB = b.split("_"); + if (splitA.length != splitB.length) { + return a.localeCompare(b); + } + for (var i = 1; i < splitA.length; i++) { + var splitdiff = splitA[i].length - splitB[i].length; + if (splitdiff != 0) { + return splitdiff; + } + var splitCompare = splitA[i].localeCompare(splitB[i]); + if (splitCompare != 0) { + return splitCompare; + } + } + return diff; + } + return a.localeCompare(b); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/bower.json ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/bower.json b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/bower.json index ec587bb..de66650 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/bower.json +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/bower.json @@ -9,7 +9,7 @@ "ember-qunit": "0.4.9", "ember-qunit-notifications": "0.0.7", "ember-resolver": "~0.1.18", - "jquery": "^1.11.3", + "jquery": "1.11.3", "loader.js": "ember-cli/loader.js#3.2.1", "qunit": "~1.18.0", "bootstrap": "~3.3.2", http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/config/environment.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/config/environment.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/config/environment.js index b898e0d..bb4f8d2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/config/environment.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/config/environment.js @@ -12,7 +12,6 @@ module.exports = function(environment) { // e.g. 'with-controller': true } }, - APP: { // Here you can pass flags/options to your application instance // when it is created http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-container-log-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-container-log-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-container-log-test.js new file mode 100644 index 0000000..e6e7b43 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-container-log-test.js @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; +import Constants from 'yarn-ui/constants'; + +moduleFor('adapter:yarn-container-log', 'Unit | Adapter | ContainerLog', { +}); + +test('Basic creation', function(assert) { + let adapter = this.subject(); + + assert.ok(adapter); + assert.ok(adapter.urlForFindRecord); + assert.ok(adapter.ajax); + assert.ok(adapter.headers); + assert.ok(adapter.host); + assert.ok(adapter.namespace); + assert.equal(adapter.headers.Accept, "text/plain"); + assert.equal(adapter.namespace, "ws/v1/node"); +}); + +test('urlForFindRecord test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(adapter.urlForFindRecord("localhost:8042" + + Constants.PARAM_SEPARATOR + "container_e27_11111111111_0001_01_000001" + + Constants.PARAM_SEPARATOR + "syslog"), + host + "localhost:8042/ws/v1/node/containerlogs/" + + "container_e27_11111111111_0001_01_000001/syslog"); +}); + +test('ajaxOptions test', function(assert) { + let adapter = this.subject(); + var hash = adapter.ajaxOptions('/containerlogs', 'type', {}); + assert.equal(hash.dataType, 'text'); +}); + +test('findRecord test', function(assert) { + let adapter = this.subject(), + testModel = { modelName: "testModel" }, + testStore = {}, + testSnapshot = {}; + let host = adapter.host; + let testId = "localhost:8042" + Constants.PARAM_SEPARATOR + + "container_e27_11111111111_0001_01_000001" + Constants.PARAM_SEPARATOR + + "syslog"; + assert.expect(2); + + adapter.ajax = function (url, method) { + assert.equal(url, host + "localhost:8042/ws/v1/node/containerlogs/" + + "container_e27_11111111111_0001_01_000001/syslog"); + assert.equal(method, 'GET'); + }; + + adapter.findRecord(testStore, testModel, testId, testSnapshot); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-app-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-app-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-app-test.js new file mode 100644 index 0000000..3a25996 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-app-test.js @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:yarn-node-app', 'Unit | Adapter | NodeApp', { +}); + +test('Basic creation', function(assert) { + let adapter = this.subject(); + assert.expect(11); + assert.ok(adapter); + assert.ok(adapter.urlForQueryRecord); + assert.ok(adapter.queryRecord); + assert.ok(adapter.urlForQuery); + assert.ok(adapter.query); + assert.ok(adapter.ajax); + assert.ok(adapter.headers); + assert.ok(adapter.host); + assert.ok(adapter.namespace); + assert.equal("application/json", adapter.headers.Accept); + assert.equal("ws/v1/node", adapter.namespace); +}); + +test('urlForQueryRecord test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal( + host + "localhost:8042/ws/v1/node/apps/application_1111111111_1111", + adapter.urlForQueryRecord( + {nodeAddr: "localhost:8042", appId: "application_1111111111_1111"})); +}); + +test('urlForQuery test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(host + "localhost:8042/ws/v1/node/apps", + adapter.urlForQuery({nodeAddr: "localhost:8042"})); +}); + +test('query test', function(assert) { + let adapter = this.subject(), + testModel = { modelName: "testModel" }, + testStore = {}, + testQuery = {nodeAddr: "localhost:8042"}; + let host = adapter.host; + assert.expect(3); + + adapter.ajax = function (url, method, hash) { + assert.equal(host + "localhost:8042/ws/v1/node/apps", url); + assert.equal('GET', method); + assert.equal(null, hash.data); + }; + + adapter.query(testStore, testModel, testQuery); +}); + +test('queryRecord test', function(assert) { + let adapter = this.subject(), + testModel = { modelName: "testModel" }, + testStore = {}, + testQuery = { + nodeAddr: "localhost:8042", + appId: "application_1111111111_1111" + }; + let host = adapter.host; + assert.expect(3); + + adapter.ajax = function (url, method, hash) { + assert.equal( + host + "localhost:8042/ws/v1/node/apps/application_1111111111_1111", + url); + assert.equal('GET', method); + assert.equal(null, hash.data); + }; + + adapter.queryRecord(testStore, testModel, testQuery); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-container-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-container-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-container-test.js new file mode 100644 index 0000000..7d2bb2d --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-container-test.js @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:yarn-node-container', 'Unit | Adapter | NodeContainer', { +}); + +test('Basic creation', function(assert) { + let adapter = this.subject(); + assert.expect(11); + assert.ok(adapter); + assert.ok(adapter.urlForQueryRecord); + assert.ok(adapter.queryRecord); + assert.ok(adapter.urlForQuery); + assert.ok(adapter.query); + assert.ok(adapter.ajax); + assert.ok(adapter.headers); + assert.ok(adapter.host); + assert.ok(adapter.namespace); + assert.equal("application/json", adapter.headers.Accept); + assert.equal("ws/v1/node", adapter.namespace); +}); + +test('urlForQueryRecord test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(host + "localhost:8042/ws/v1/node/containers/" + + "container_e27_11111111111_0001_01_000001", + adapter.urlForQueryRecord( + {nodeHttpAddr: "localhost:8042", + containerId: "container_e27_11111111111_0001_01_000001"})); +}); + +test('urlForQuery test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(host + "localhost:8042/ws/v1/node/containers", + adapter.urlForQuery({nodeHttpAddr: "localhost:8042"})); +}); + +test('query test', function(assert) { + let adapter = this.subject(), + testModel = { modelName: "testModel" }, + testStore = {}, + testQuery = {nodeHttpAddr: "localhost:8042"}; + let host = adapter.host; + assert.expect(3); + + adapter.ajax = function (url, method, hash) { + assert.equal(host + "localhost:8042/ws/v1/node/containers", url); + assert.equal('GET', method); + assert.equal(null, hash.data); + }; + + adapter.query(testStore, testModel, testQuery); +}); + +test('queryRecord test', function(assert) { + let adapter = this.subject(), + testModel = { modelName: "testModel" }, + testStore = {}, + testQuery = { + nodeHttpAddr: "localhost:8042", + containerId: "container_e27_11111111111_0001_01_000001" + }; + let host = adapter.host; + assert.expect(3); + + adapter.ajax = function (url, method, hash) { + assert.equal(host + "localhost:8042/ws/v1/node/containers/" + + "container_e27_11111111111_0001_01_000001", url); + assert.equal('GET', method); + assert.equal(null, hash.data); + }; + + adapter.queryRecord(testStore, testModel, testQuery); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-test.js new file mode 100644 index 0000000..15aefef --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-node-test.js @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:yarn-node', 'Unit | Adapter | Node', { +}); + +test('Basic creation', function(assert) { + let adapter = this.subject(); + + assert.ok(adapter); + assert.ok(adapter.urlForFindRecord); + assert.ok(adapter.ajax); + assert.ok(adapter.headers); + assert.ok(adapter.host); + assert.ok(adapter.namespace); + assert.equal(adapter.headers.Accept, "application/json"); + assert.equal(adapter.namespace, "ws/v1/node"); +}); + +test('urlForFindRecord test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(adapter.urlForFindRecord("localhost:8042"), + host + "localhost:8042/ws/v1/node"); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-rm-node-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-rm-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-rm-node-test.js new file mode 100644 index 0000000..bf009d4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/adapters/yarn-rm-node-test.js @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('adapter:yarn-rm-node', 'Unit | Adapter | RMNode', { + // Specify the other units that are required for this test. + // needs: ['serializer:foo'] +}); + +test('Basic creation', function(assert) { + let adapter = this.subject(); + + assert.ok(adapter); + assert.ok(adapter.urlForFindRecord); + assert.ok(adapter.ajax); + assert.ok(adapter.headers); + assert.ok(adapter.host); + assert.ok(adapter.namespace); + assert.equal(adapter.headers.Accept, "application/json"); + assert.equal(adapter.namespace, "ws/v1/cluster"); +}); + +test('urlForFindRecord test', function(assert) { + let adapter = this.subject(); + let host = adapter.host; + assert.equal(adapter.urlForFindRecord("localhost:8042"), + host + "/ws/v1/cluster/nodes/localhost:8042"); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-container-log-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-container-log-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-container-log-test.js new file mode 100644 index 0000000..45808a5 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-container-log-test.js @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('yarn-container-log', 'Unit | Model | ContainerLog', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('Basic creation test', function(assert) { + let model = this.subject(); + assert.ok(model); + assert.ok(model._notifyProperties); + assert.ok(model.didLoad); + assert.ok(model.logs); + assert.ok(model.containerID); + assert.ok(model.logFileName); +}); + +test('test fields', function(assert) { + let model = this.subject(); + + Ember.run(function () { + model.set("logs", "This is syslog"); + model.set("containerID", "container_e32_1456000363780_0002_01_000001"); + model.set("logFileName", "syslog"); + assert.equal(model.get("logs"), "This is syslog"); + assert.equal(model.get("containerID"), "container_e32_1456000363780_0002_01_000001"); + assert.equal(model.get("logFileName"), "syslog"); + }); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-app-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-app-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-app-test.js new file mode 100644 index 0000000..7e2e62f --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-app-test.js @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('yarn-node-app', 'Unit | Model | NodeApp', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('Basic creation test', function(assert) { + let model = this.subject(); + + assert.ok(model); + assert.ok(model._notifyProperties); + assert.ok(model.didLoad); + assert.ok(model.appId); + assert.ok(model.state); + assert.ok(model.user); + assert.ok(model.containers); +}); + +test('test fields', function(assert) { + let model = this.subject(); + + assert.expect(9); + Ember.run(function () { + model.set("appId", "application_1456251210105_0002"); + model.set("id", "application_1456251210105_0002"); + model.set("state", "RUNNING"); + model.set("user", "hadoop"); + model.set("containers", ["container_e38_1456251210105_0002_01_000001", + "container_e38_1456251210105_0002_01_000002"]); + assert.equal(model.get("appId"), "application_1456251210105_0002"); + assert.equal(model.get("state"), "RUNNING"); + assert.equal(model.get("user"), "hadoop"); + assert.deepEqual(model.get("containers"), + ["container_e38_1456251210105_0002_01_000001", + "container_e38_1456251210105_0002_01_000002"]); + assert.equal(model.get("appStateStyle"), "label label-primary"); + assert.equal(model.get("isDummyApp"), false); + model.set("id", "dummy"); + assert.equal(model.get("isDummyApp"), true); + model.set("state", "FINISHED"); + assert.equal(model.get("appStateStyle"), "label label-success"); + model.set("state", "NEW"); + assert.equal(model.get("appStateStyle"), "label label-default"); + }); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-container-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-container-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-container-test.js new file mode 100644 index 0000000..88bf233 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-container-test.js @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('yarn-node-container', 'Unit | Model | NodeContainer', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('Basic creation test', function(assert) { + let model = this.subject(); + + assert.ok(model); + assert.ok(model._notifyProperties); + assert.ok(model.didLoad); + assert.ok(model.containerId); + assert.ok(model.state); + assert.ok(model.user); + assert.ok(model.exitCode); + assert.ok(model.totalMemoryNeeded); + assert.ok(model.totalVCoresNeeded); + assert.ok(model.containerLogFiles); + assert.ok(model.isDummyContainer); + assert.ok(model.containerStateStyle); +}); + +test('test fields', function(assert) { + let model = this.subject(); + + Ember.run(function () { + model.set("containerId", "container_e32_1456000363780_0002_01_000003"); + model.set("state", "RUNNING"); + model.set("exitCode", "-1000"); + model.set("user", "hadoop"); + model.set("id", "container_e32_1456000363780_0002_01_000003"); + model.set("totalMemoryNeeded", 1024); + model.set("totalVCoresNeeded", 1); + model.set("containerLogFiles", ["syslog", "stderr", "stdout"]); + assert.equal(model.get("containerId"), "container_e32_1456000363780_0002_01_000003"); + assert.equal(model.get("id"), "container_e32_1456000363780_0002_01_000003"); + assert.equal(model.get("totalMemoryNeeded"), 1024); + assert.equal(model.get("totalVCoresNeeded"), 1); + assert.equal(model.get("user"), "hadoop"); + assert.equal(model.get("exitCode"), "-1000"); + assert.equal(model.get("containerLogFiles").length, 3); + assert.deepEqual(model.get("containerLogFiles"), ["syslog", "stderr", "stdout"]); + assert.equal(model.get("isDummyContainer"), false); + assert.equal(model.get("containerStateStyle"), "label label-primary"); + model.set("id", "dummy"); + assert.equal(model.get("isDummyContainer"), true); + model.set("state", "EXITED_WITH_SUCCESS"); + assert.equal(model.get("containerStateStyle"), "label label-success"); + model.set("state", "EXITED_WITH_FAILURE"); + assert.equal(model.get("containerStateStyle"), "label label-danger"); + model.set("state", "DONE"); + model.set("exitCode", "0"); + assert.equal(model.get("containerStateStyle"), "label label-success"); + model.set("exitCode", "-105"); + assert.equal(model.get("containerStateStyle"), "label label-danger"); + }); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js new file mode 100644 index 0000000..5877589 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('yarn-node', 'Unit | Model | Node', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('Basic creation test', function(assert) { + let model = this.subject(); + + assert.ok(model); + assert.ok(model._notifyProperties); + assert.ok(model.didLoad); + assert.ok(model.totalVmemAllocatedContainersMB); + assert.ok(model.vmemCheckEnabled); + assert.ok(model.pmemCheckEnabled); + assert.ok(model.nodeHealthy); + assert.ok(model.lastNodeUpdateTime); + assert.ok(model.healthReport); + assert.ok(model.nmStartupTime); + assert.ok(model.nodeManagerBuildVersion); + assert.ok(model.hadoopBuildVersion); +}); + +test('test fields', function(assert) { + let model = this.subject(); + + assert.expect(4); + Ember.run(function () { + model.set("totalVmemAllocatedContainersMB", 4096); + model.set("totalPmemAllocatedContainersMB", 2048); + model.set("totalVCoresAllocatedContainers", 4); + model.set("hadoopBuildVersion", "3.0.0-SNAPSHOT"); + assert.equal(model.get("totalVmemAllocatedContainersMB"), 4096); + assert.equal(model.get("totalPmemAllocatedContainersMB"), 2048); + assert.equal(model.get("totalVCoresAllocatedContainers"), 4); + assert.equal(model.get("hadoopBuildVersion"), "3.0.0-SNAPSHOT"); + }); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js new file mode 100644 index 0000000..4fd2517 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js @@ -0,0 +1,95 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('yarn-rm-node', 'Unit | Model | RMNode', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('Basic creation test', function(assert) { + let model = this.subject(); + + assert.ok(model); + assert.ok(model._notifyProperties); + assert.ok(model.didLoad); + assert.ok(model.rack); + assert.ok(model.state); + assert.ok(model.nodeHostName); + assert.ok(model.nodeHTTPAddress); + assert.ok(model.lastHealthUpdate); + assert.ok(model.healthReport); + assert.ok(model.numContainers); + assert.ok(model.usedMemoryMB); + assert.ok(model.availMemoryMB); + assert.ok(model.usedVirtualCores); + assert.ok(model.availableVirtualCores); + assert.ok(model.version); + assert.ok(model.nodeLabels); + assert.ok(model.nodeLabelsAsString); + assert.ok(model.nodeStateStyle); + assert.ok(model.isDummyNode); + assert.ok(model.getMemoryDataForDonutChart); + assert.ok(model.getVCoreDataForDonutChart); +}); + +test('test fields', function(assert) { + let model = this.subject(); + + Ember.run(function () { + model.set("rack", "/default-rack"); + model.set("state", "RUNNING"); + model.set("nodeHostName", "localhost"); + model.set("id", "localhost:64318"); + model.set("nodeHTTPAddress", "localhost:8042"); + model.set("usedMemoryMB", 1024); + model.set("availMemoryMB", 7168); + model.set("usedVirtualCores", 1); + model.set("availableVirtualCores", 7); + model.set("nodeLabels", ["x"]); + assert.equal(model.get("rack"), "/default-rack"); + assert.equal(model.get("state"), "RUNNING"); + assert.equal(model.get("nodeHostName"), "localhost"); + assert.equal(model.get("id"), "localhost:64318"); + assert.equal(model.get("nodeHTTPAddress"), "localhost:8042"); + assert.equal(model.get("usedMemoryMB"), 1024); + assert.equal(model.get("availMemoryMB"), 7168); + assert.equal(model.get("usedVirtualCores"), 1); + assert.equal(model.get("availableVirtualCores"), 7); + assert.equal(model.get("isDummyNode"), false); + assert.deepEqual(model.get("nodeLabels"), ["x"]); + assert.equal(model.get("nodeLabelsAsString"), "x"); + assert.deepEqual(model.get("nodeStateStyle"), "label label-success"); + assert.deepEqual(model.get("getMemoryDataForDonutChart"), + [{label: "Used", value: 1024}, {label: "Available", value: 7168}]); + assert.deepEqual(model.get("getVCoreDataForDonutChart"), + [{label: "Used", value: 1}, {label: "Available", value: 7}]); + model.set("state", "SHUTDOWN"); + assert.deepEqual(model.get("nodeStateStyle"), "label label-danger"); + model.set("state", "REBOOTED"); + assert.deepEqual(model.get("nodeStateStyle"), "label label-warning"); + model.set("state", "NEW"); + assert.deepEqual(model.get("nodeStateStyle"), "label label-default"); + model.set("nodeLabels", ["x","y"]); + assert.equal(model.get("nodeLabelsAsString"), "x"); + model.set("nodeLabels", undefined); + assert.equal(model.get("nodeLabelsAsString"), ""); + }); +}); + http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-container-log-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-container-log-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-container-log-test.js new file mode 100644 index 0000000..4e68da0 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-container-log-test.js @@ -0,0 +1,120 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; +import Constants from 'yarn-ui/constants'; + +moduleFor('route:yarn-container-log', 'Unit | Route | ContainerLog', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting container log', function(assert) { + var response = { + logs: "This is syslog", + containerID: "container_e32_1456000363780_0002_01_000001", + logFileName: "syslog"}; + var store = { + findRecord: function(type) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response); + } + )} + }; + assert.expect(6); + var route = this.subject(); + route.set('store', store); + var model = route.model({node_id: "localhost:64318", + node_addr: "localhost:8042", + container_id: "container_e32_1456000363780_0002_01_000001", + filename: "syslog"}); + model.then(function(value) { + assert.ok(value); + assert.ok(value.containerLog); + assert.deepEqual(value.containerLog, response); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + }); +}); + +/** + * This can happen when an empty response is sent from server + */ +test('Test non HTTP error while getting container log', function(assert) { + var error = {}; + var response = { + logs: "", + containerID: "container_e32_1456000363780_0002_01_000001", + logFileName: "syslog"}; + var store = { + findRecord: function(type) { + return new Ember.RSVP.Promise(function(resolve, reject) { + reject(error); + } + )} + }; + assert.expect(6); + var route = this.subject(); + route.set('store', store); + var model = route.model({node_id: "localhost:64318", + node_addr: "localhost:8042", + container_id: "container_e32_1456000363780_0002_01_000001", + filename: "syslog"}); + model.then(function(value) { + assert.ok(value); + assert.ok(value.containerLog); + assert.deepEqual(value.containerLog, response); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + }); +}); + +test('Test HTTP error while getting container log', function(assert) { + var error = {errors: [{status: 404, responseText: 'Not Found'}]}; + var response = { + logs: "", + containerID: "container_e32_1456000363780_0002_01_000001", + logFileName: "syslog"}; + var store = { + findRecord: function(type) { + return new Ember.RSVP.Promise(function(resolve, reject) { + reject(error); + } + )} + }; + assert.expect(5); + var route = this.subject(); + route.set('store', store); + var model = route.model({node_id: "localhost:64318", + node_addr: "localhost:8042", + container_id: "container_e32_1456000363780_0002_01_000001", + filename: "syslog"}); + model.then(function(value) { + assert.ok(value); + assert.ok(value.errors); + assert.equal(value.errors.length, 1); + assert.equal(value.errors[0].status, 404); + assert.equal(value.errors[0].responseText, 'Not Found'); + }); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-app-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-app-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-app-test.js new file mode 100644 index 0000000..8e5acf9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-app-test.js @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:yarn-node-app', 'Unit | Route | NodeApp', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting specific app on a node', function(assert) { + var response = + {id:"application_1456251210105_0001", state:"FINISHED", user:"root"}; + var store = { + queryRecord: function(type, query) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response); + }); + } + }; + assert.expect(6); + var route = this.subject(); + route.set('store', store); + var model = + route.model({node_id:"localhost:64318", node_addr:"localhost:8042", + app_id:"application_1456251210105_0001"}). + then( + function(value){ + assert.ok(value); + assert.ok(value.nodeApp); + assert.deepEqual(value.nodeApp, response); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + } + ); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-apps-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-apps-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-apps-test.js new file mode 100644 index 0000000..44d9995 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-apps-test.js @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:yarn-node-apps', 'Unit | Route | NodeApps', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting apps on a node', function(assert) { + var response = [ + {id:"application_1456251210105_0001", state:"FINISHED", user:"root"}, + {id:"application_1456251210105_0002", state:"RUNNING",user:"root", + containerids:["container_e38_1456251210105_0002_01_000001", + "container_e38_1456251210105_0002_01_000002"]}]; + var store = { + query: function(type, query) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response.slice()); + }); + } + }; + assert.expect(8); + var route = this.subject(); + route.set('store', store); + var model = + route.model({node_id:"localhost:64318", node_addr:"localhost:8042"}). + then( + function(value){ + assert.ok(value); + assert.ok(value.apps); + assert.equal(value.apps.length, 2); + assert.deepEqual(response[0], value.apps[0]); + assert.deepEqual(response[1], value.apps[1]); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + } + ); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-container-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-container-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-container-test.js new file mode 100644 index 0000000..f0b68fc --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-container-test.js @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:yarn-node-container', 'Unit | Route | NodeContainer', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting specific container on a node', function(assert) { + var response = + {id: "container_e32_1456000363780_0002_01_000001", state: "RUNNING", + exitCode:-1000,diagnostics:"",user:"root",totalMemoryNeededMB:2048, + totalVCoresNeeded:1,containerLogsLink: "http://localhost:8042/node/" + + "containerlogs/container_e32_1456000363780_0002_01_000001/root", + nodeId: "localhost:64318", containerLogFiles:["syslog","stderr", + "stdout"]}; + var store = { + queryRecord: function(type, query) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response); + }); + } + }; + assert.expect(6); + var route = this.subject(); + route.set('store', store); + var model = + route.model({node_id:"localhost:64318", node_addr:"localhost:8042", + container_id:"container_e32_1456000363780_0002_01_000001"}). + then( + function(value){ + assert.ok(value); + assert.ok(value.nodeContainer); + assert.deepEqual(value.nodeContainer, response); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + } + ); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-containers-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-containers-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-containers-test.js new file mode 100644 index 0000000..8359713 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-containers-test.js @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:yarn-node-containers', 'Unit | Route | NodeContainers', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting apps on a node', function(assert) { + var response = + [{id: "container_e32_1456000363780_0002_01_000001", state: "RUNNING", + exitCode:-1000,diagnostics:"",user:"root",totalMemoryNeededMB:2048, + totalVCoresNeeded:1,containerLogsLink: "http://localhost:8042/node/" + + "containerlogs/container_e32_1456000363780_0002_01_000001/root", + nodeId: "localhost:64318", containerLogFiles:["syslog","stderr", + "stdout"]}, + {id:"container_e32_1456000363780_0002_01_000003", state:"RUNNING", + exitCode:-1000, diagnostics:"", user:"root", totalMemoryNeededMB:1024, + totalVCoresNeeded:1,containerLogsLink:"http://localhost:8042/node" + + "/containerlogs/container_e32_1456000363780_0002_01_000003/root", + nodeId:"localhost:64318",containerLogFiles:["syslog","stderr", + "syslog.shuffle","stdout"]}]; + var store = { + query: function(type, query) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response.slice()); + }); + } + }; + assert.expect(8); + var route = this.subject(); + route.set('store', store); + var model = + route.model({node_id:"localhost:64318", node_addr:"localhost:8042"}). + then( + function(value){ + assert.ok(value); + assert.ok(value.containers); + assert.equal(value.containers.length, 2); + assert.deepEqual(value.containers[0], response[0]); + assert.deepEqual(value.containers[1], response[1]); + assert.ok(value.nodeInfo); + assert.equal(value.nodeInfo.addr, 'localhost:8042'); + assert.equal(value.nodeInfo.id, 'localhost:64318'); + } + ); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-test.js new file mode 100644 index 0000000..4e82f1b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-node-test.js @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; +import Ember from 'ember'; + +moduleFor('route:yarn-node', 'Unit | Route | Node', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting a node', function(assert) { + var nodeResponse = + {healthReport: "Healthy", totalVmemAllocatedContainersMB: 344064, + totalPmemAllocatedContainersMB: 163840, + totalVCoresAllocatedContainers: 160, + vmemCheckEnabled: true, pmemCheckEnabled: true, + lastNodeUpdateTime: 1456250210310, nodeHealthy: true, + nodeManagerVersion: "3.0.0-SNAPSHOT", + nodeManagerBuildVersion: "3.0.0-SNAPSHOT", + nodeManagerVersionBuiltOn: "2000-01-01T00:00Z", + hadoopVersion: "3.0.0-SNAPSHOT", + hadoopBuildVersion: "3.0.0-SNAPSHOT", + hadoopVersionBuiltOn: "2000-01-01T00:00Z", + id: "localhost:64318", nodeHostName: "192.168.0.102", + nmStartupTime: 1456250208231}; + var rmNodeResponse = + {rack: "/default-rack", state: "RUNNING", id: "localhost:64318", + nodeHostName: "localhost", nodeHTTPAddress: "localhost:8042", + lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT", + healthReport: "", numContainers: 0, usedMemoryMB: 0, + availMemoryMB: 163840, usedVirtualCores: 0, + availableVirtualCores: 160, + resourceUtilization: { + nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549, + nodeCPUUsage: 0.14995001256465912, + aggregatedContainersPhysicalMemoryMB: 0, + aggregatedContainersVirtualMemoryMB: 0, + containersCPUUsage: 0 + }}; + + // Create store which returns appropriate responses. + var store = { + findRecord: function(type) { + if (type == 'yarnNode') { + return new Ember.RSVP.Promise(function(resolve) { + resolve(nodeResponse); + }); + } else if (type == 'yarnRmNode') { + return new Ember.RSVP.Promise(function(resolve) { + resolve(rmNodeResponse); + }); + } + } + }; + var route = this.subject(); + assert.expect(4); + route.set('store', store); + var model = route.model( + {node_addr:"localhost:8042", node_id:"localhost:64318"})._result; + assert.ok(model.node); + assert.deepEqual(model.node, nodeResponse); + assert.ok(model.rmNode); + assert.deepEqual(model.rmNode, rmNodeResponse); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-nodes-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-nodes-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-nodes-test.js new file mode 100644 index 0000000..baa5bd6 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/routes/yarn-nodes-test.js @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; +import Ember from 'ember'; + +moduleFor('route:yarn-nodes', 'Unit | Route | Nodes', { +}); + +test('Basic creation test', function(assert) { + let route = this.subject(); + assert.ok(route); + assert.ok(route.model); +}); + +test('Test getting nodes', function(assert) { + var response = [{ + rack: "/default-rack", state: "RUNNING", id: "192.168.1.1:64318", + nodeHostName: "192.168.1.1", nodeHTTPAddress: "192.168.1.1:8042", + lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT", + healthReport: "", numContainers: 0, usedMemoryMB: 0, + availMemoryMB: 163840, usedVirtualCores: 0, + availableVirtualCores: 160, + resourceUtilization: { + nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549, + nodeCPUUsage: 0.14995001256465912, + aggregatedContainersPhysicalMemoryMB: 0, + aggregatedContainersVirtualMemoryMB: 0, + containersCPUUsage: 0 + }}, + {rack: "/default-rack", state: "RUNNING", id: "192.168.1.2:64318", + nodeHostName: "192.168.1.2", nodeHTTPAddress: "192.168.1.2:8042", + lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT", + healthReport: "", numContainers: 0, usedMemoryMB: 0, + availMemoryMB: 163840, usedVirtualCores: 0, + availableVirtualCores: 160, + resourceUtilization: { + nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549, + nodeCPUUsage: 0.14995001256465912, + aggregatedContainersPhysicalMemoryMB: 0, + aggregatedContainersVirtualMemoryMB: 0, + containersCPUUsage: 0 + }}]; + var store = { + findAll: function(type) { + return new Ember.RSVP.Promise(function(resolve) { + resolve(response); + }); + } + }; + var route = this.subject(); + route.set('store', store); + var model = route.model()._result; + assert.expect(4); + assert.ok(model); + assert.equal(model.length, 2); + assert.deepEqual(response[0], model[0]); + assert.deepEqual(response[1], model[1]); +}); http://git-wip-us.apache.org/repos/asf/hadoop/blob/33b21c27/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/serializers/yarn-container-log-test.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/serializers/yarn-container-log-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/serializers/yarn-container-log-test.js new file mode 100644 index 0000000..2349dc2 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/serializers/yarn-container-log-test.js @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('serializer:yarn-container-log', 'Unit | Serializer | ContainerLog', { +}); + +test('Basic creation test', function(assert) { + let serializer = this.subject(); + + assert.ok(serializer); + assert.ok(serializer.normalizeSingleResponse); +}); + +test('normalizeSingleResponse test', function(assert) { + let serializer = this.subject(), + modelClass = { + modelName: "yarn-container-log" + }, + payload = "This is syslog"; + var id = "localhost:64318!container_e32_1456000363780_0002_01_000001!syslog"; + assert.expect(6); + var response = + serializer.normalizeSingleResponse({}, modelClass, payload, id, null); + assert.ok(response.data); + assert.equal(response.data.id, id); + assert.equal(response.data.type, modelClass.modelName); + assert.equal(response.data.attributes.logs, payload); + assert.equal(response.data.attributes.containerID, + "container_e32_1456000363780_0002_01_000001"); + assert.equal(response.data.attributes.logFileName, "syslog"); +}); + --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org