123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- /**
- * 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.
- */
- var App = require('app');
- require('views/common/quick_view_link_view');
- describe('App.QuickViewLinks', function () {
- var quickViewLinks = App.QuickViewLinks.create({});
- describe('#setProtocol', function() {
- var tests = [
- { serviceName: "GANGLIA", ambariProperties: { 'ganglia.https': true }, m: "https for ganglia", result: "https" },
- { serviceName: "GANGLIA", ambariProperties: { 'ganglia.https': false }, m: "http for ganglia 1", result: "http" },
- { serviceName: "GANGLIA", m: "http for ganglia 2", result: "http" },
- { serviceName: "YARN", configProperties: [
- { type: 'yarn-site', properties: { 'yarn.http.policy': 'HTTPS_ONLY' }}
- ], m: "https for yarn", result: "https" },
- { serviceName: "YARN", configProperties: [
- { type: 'yarn-site', properties: { 'yarn.http.policy': 'HTTP_ONLY' }}
- ], m: "http for yarn", result: "http" },
- { serviceName: "YARN", configProperties: [
- { type: 'yarn-site', properties: { 'yarn.http.policy': 'HTTP_ONLY' }}
- ], m: "http for yarn (overrides hadoop.ssl.enabled)", result: "http" },
- { serviceName: "YARN", configProperties: [
- { type: 'yarn-site', properties: { 'yarn.http.policy': 'HTTPS_ONLY' }}
- ], m: "https for yarn (overrides hadoop.ssl.enabled)", result: "https" },
- { serviceName: "MAPREDUCE2", configProperties: [
- { type: 'mapred-site', properties: { 'mapreduce.jobhistory.http.policy': 'HTTPS_ONLY' }}
- ], m: "https for mapreduce2", result: "https" },
- { serviceName: "MAPREDUCE2", configProperties: [
- { type: 'mapred-site', properties: { 'mapreduce.jobhistory.http.policy': 'HTTP_ONLY' }}
- ], m: "http for mapreduce2", result: "http" },
- { serviceName: "ANYSERVICE", configProperties: [
- { type: 'hdfs-site', properties: { 'dfs.http.policy': 'HTTPS_ONLY' }}
- ], m: "https for anyservice", servicesSupportsHttps: ["ANYSERVICE"], result: "https" }
- ];
- tests.forEach(function(t) {
- it(t.m, function() {
- quickViewLinks.set('servicesSupportsHttps', t.servicesSupportsHttps);
- expect(quickViewLinks.setProtocol(t.serviceName, t.configProperties, t.ambariProperties)).to.equal(t.result);
- });
- });
- });
- describe('#setPort', function () {
- var testData = [
- Em.Object.create({
- 'service_id': 'YARN',
- 'protocol': 'http',
- 'result': '8088',
- 'default_http_port': '8088',
- 'default_https_port': '8090',
- 'regex': '\\w*:(\\d+)'
- }),
- Em.Object.create({
- 'service_id': 'YARN',
- 'protocol': 'https',
- 'https_config': 'https_config',
- 'result': '8090',
- 'default_http_port': '8088',
- 'default_https_port': '8090',
- 'regex': '\\w*:(\\d+)'
- }),
- Em.Object.create({
- 'service_id': 'YARN',
- 'protocol': 'https',
- 'https_config': 'https_config',
- 'result': '8090',
- 'default_http_port': '8088',
- 'default_https_port': '8090',
- 'regex': '\\w*:(\\d+)'
- })
- ];
- testData.forEach(function(item) {
- it(item.service_id + ' ' + item.protocol, function () {
- expect(quickViewLinks.setPort(item, item.protocol, item.version)).to.equal(item.result);
- })
- },this);
- });
- describe('#setHost', function () {
- var quickViewLinks = App.QuickViewLinks.create({
- content: Em.Object.create()
- }),
- cases = [
- {
- singleNodeInstall: true,
- hosts: ['host0'],
- title: 'single node install'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'STORM_UI_SERVER'
- }
- }
- ],
- Hosts: {
- public_host_name: 'host3'
- }
- }
- ]
- },
- serviceName: 'STORM',
- hosts: ['host3']
- },
- {
- serviceName: 'PIG',
- hosts: [],
- title: 'client only service'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'ZOOKEEPER_SERVER'
- }
- }
- ],
- Hosts: {
- public_host_name: 'host4'
- }
- }
- ]
- },
- serviceName: 'ZOOKEEPER',
- hosts: ['host4'],
- setup: function () {
- quickViewLinks.set('content', {
- hostComponents: [
- Em.Object.create({
- componentName: 'ZOOKEEPER_SERVER',
- isMaster: true
- })
- ]
- });
- },
- title: 'service with master component, except HDFS, HBase, YARN and Storm'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'NAMENODE'
- }
- }
- ],
- Hosts: {
- public_host_name: 'host5'
- }
- }
- ]
- },
- serviceName: 'HDFS',
- hosts: ['host5'],
- setup: function () {
- quickViewLinks.set('content', {
- snameNode: true
- });
- },
- title: 'HDFS, HA disabled'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'NAMENODE'
- }
- }
- ],
- Hosts: {
- host_name: 'host6',
- public_host_name: 'host6'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'NAMENODE'
- }
- }
- ],
- Hosts: {
- host_name: 'host7',
- public_host_name: 'host7'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'NAMENODE'
- }
- }
- ],
- Hosts: {
- host_name: 'host8',
- public_host_name: 'host8'
- }
- }
- ]
- },
- serviceName: 'HDFS',
- multipleMasters: true,
- hosts: ['host6', 'host7', 'host8'],
- setup: function () {
- quickViewLinks.set('content', {
- hostComponents: [
- Em.Object.create({
- componentName: 'NAMENODE',
- hostName: 'host6'
- }),
- Em.Object.create({
- componentName: 'NAMENODE',
- hostName: 'host7'
- }),
- Em.Object.create({
- componentName: 'NAMENODE',
- hostName: 'host8'
- })
- ],
- activeNameNode: {
- hostName: 'host6'
- },
- standbyNameNode: {
- hostName: 'host7'
- },
- standbyNameNode2: {
- hostName: 'host8'
- }
- });
- },
- title: 'HDFS, HA enabled'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'RESOURCEMANAGER'
- }
- }
- ],
- Hosts: {
- public_host_name: 'host9'
- }
- }
- ]
- },
- serviceName: 'YARN',
- hosts: ['host9'],
- title: 'YARN, HA disabled'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'RESOURCEMANAGER'
- }
- }
- ],
- Hosts: {
- host_name: 'host10',
- public_host_name: 'host10'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'RESOURCEMANAGER'
- }
- }
- ],
- Hosts: {
- host_name: 'host11',
- public_host_name: 'host11'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'RESOURCEMANAGER'
- }
- }
- ],
- Hosts: {
- host_name: 'host12',
- public_host_name: 'host12'
- }
- }
- ]
- },
- serviceName: 'YARN',
- multipleMasters: true,
- hosts: ['host10', 'host11', 'host12'],
- setup: function () {
- quickViewLinks.set('content', {
- hostComponents: [
- Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host10'
- }),
- Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host11'
- }),
- Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host12'
- })
- ]
- });
- },
- title: 'YARN, HA enabled'
- },
- {
- response: {
- items: [
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- },
- metrics: {
- hbase: {
- master: {
- IsActiveMaster: true
- }
- }
- }
- }
- ],
- Hosts: {
- host_name: 'host13',
- public_host_name: 'host13'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- },
- metrics: {
- hbase: {
- master: {
- IsActiveMaster: false
- }
- }
- }
- }
- ],
- Hosts: {
- host_name: 'host14',
- public_host_name: 'host14'
- }
- },
- {
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- }
- }
- ],
- Hosts: {
- host_name: 'host15',
- public_host_name: 'host15'
- }
- }
- ]
- },
- serviceName: 'HBASE',
- multipleMasters: true,
- hosts: ['host13', 'host14', 'host15']
- }
- ];
- before(function () {
- sinon.stub(App.StackService, 'find', function () {
- return [
- Em.Object.create({
- serviceName: 'ZOOKEEPER',
- hasMaster: true
- }),
- Em.Object.create({
- serviceName: 'PIG',
- hasMaster: false
- })
- ];
- })
- });
- after(function () {
- App.StackService.find.restore();
- });
- afterEach(function () {
- App.get.restore();
- });
- cases.forEach(function (item) {
- it(item.title || item.serviceName, function () {
- if (item.setup) {
- item.setup();
- }
- sinon.stub(App, 'get').withArgs('singleNodeInstall').returns(item.singleNodeInstall).
- withArgs('singleNodeAlias').returns('host0').
- withArgs('isRMHaEnabled').returns(item.multipleMasters);
- if (item.multipleMasters) {
- expect(quickViewLinks.setHost(item.response, item.serviceName).mapProperty('publicHostName')).to.eql(item.hosts);
- } else {
- expect(quickViewLinks.setHost(item.response, item.serviceName)).to.eql(item.hosts);
- }
- });
- });
- });
- });
|