123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985 |
- /**
- * 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');
- var testHelpers = require('test/helpers');
- describe('App.QuickViewLinks', function () {
- var quickViewLinks = App.QuickViewLinks.create({
- content: Em.Object.create()
- });
- describe("#linkTarget", function () {
- it("blank link", function () {
- quickViewLinks.set('content.serviceName', 'HDFS');
- quickViewLinks.propertyDidChange('linkTarget');
- expect(quickViewLinks.get('linkTarget')).to.equal('_blank');
- });
- it("non-blank link", function () {
- quickViewLinks.set('content.serviceName', 'S1');
- quickViewLinks.propertyDidChange('linkTarget');
- expect(quickViewLinks.get('linkTarget')).to.be.empty;
- });
- });
- describe("#ambariProperties", function () {
- beforeEach(function () {
- sinon.stub(App.router, 'get').returns({p: 1});
- });
- afterEach(function () {
- App.router.get.restore();
- });
- it("ambariProperties are updated", function () {
- expect(quickViewLinks.get('ambariProperties')).to.eql({p: 1});
- });
- });
- describe("#didInsertElement()", function () {
- beforeEach(function () {
- sinon.stub(App.router, 'get').returns({p: 1});
- sinon.stub(quickViewLinks, 'loadQuickLinksConfigurations');
- });
- afterEach(function () {
- App.router.get.restore();
- quickViewLinks.loadQuickLinksConfigurations.restore();
- });
- it("loadQuickLinksConfigurations is called once", function () {
- quickViewLinks.didInsertElement();
- expect(quickViewLinks.loadQuickLinksConfigurations.calledOnce).to.be.true;
- });
- });
- describe("#willDestroyElement()", function () {
- beforeEach(function () {
- quickViewLinks.setProperties({
- configProperties: [{}],
- actualTags: [""],
- quickLinks: [{}]
- });
- quickViewLinks.willDestroyElement();
- });
- it("configProperties empty", function () {
- expect(quickViewLinks.get('configProperties')).to.be.empty;
- });
- it("actualTags empty", function () {
- expect(quickViewLinks.get('actualTags')).to.be.empty;
- });
- it("quickLinks empty", function () {
- expect(quickViewLinks.get('quickLinks')).to.be.empty;
- });
- });
- describe("#setQuickLinks()", function () {
- beforeEach(function () {
- this.mock = sinon.stub(App, 'get');
- sinon.stub(quickViewLinks, 'loadTags', Em.K);
- });
- afterEach(function () {
- this.mock.restore();
- quickViewLinks.loadTags.restore();
- });
- it("data loaded", function () {
- this.mock.returns(true);
- quickViewLinks.setQuickLinks();
- expect(quickViewLinks.loadTags.calledOnce).to.be.true;
- });
- it("data not loaded", function () {
- this.mock.returns(false);
- quickViewLinks.setQuickLinks();
- expect(quickViewLinks.loadTags.called).to.be.false;
- });
- });
- describe("#loadTags()", function () {
- it("call $.ajax", function () {
- quickViewLinks.loadTags();
- var args = testHelpers.findAjaxRequest('name', 'config.tags');
- expect(args[0]).exists;
- expect(args[0].sender).to.be.eql(quickViewLinks);
- });
- });
- describe("#loadTagsSuccess()", function () {
- beforeEach(function () {
- sinon.stub(quickViewLinks, 'setConfigProperties', function () {
- return {
- done: Em.clb
- }
- });
- sinon.stub(quickViewLinks, 'getQuickLinksHosts');
- var data = {
- Clusters: {
- desired_configs: {
- site1: {
- tag: 'tag1'
- }
- }
- }
- };
- quickViewLinks.loadTagsSuccess(data);
- });
- afterEach(function () {
- quickViewLinks.setConfigProperties.restore();
- quickViewLinks.getQuickLinksHosts.restore();
- });
- it("actualTags is valid", function () {
- expect(quickViewLinks.get('actualTags')[0]).to.eql(Em.Object.create({
- siteName: 'site1',
- tagName: 'tag1'
- }));
- });
- it("setConfigProperties is called once", function () {
- expect(quickViewLinks.setConfigProperties.calledOnce).to.be.true;
- });
- it("getQuickLinksHosts is called once", function () {
- expect(quickViewLinks.getQuickLinksHosts.calledOnce).to.be.true;
- });
- });
- describe("#loadTagsError()", function () {
- beforeEach(function () {
- sinon.stub(quickViewLinks, 'getQuickLinksHosts');
- });
- afterEach(function () {
- quickViewLinks.getQuickLinksHosts.restore();
- });
- it("call loadQuickLinksConfigurations", function () {
- quickViewLinks.loadTagsError();
- expect(quickViewLinks.getQuickLinksHosts.calledOnce).to.be.true;
- });
- });
- describe("#loadQuickLinksConfigSuccessCallback()", function () {
- var mock;
- beforeEach(function () {
- sinon.stub(App.store, 'commit', Em.K);
- mock = sinon.stub(quickViewLinks, 'getQuickLinksConfiguration');
- });
- afterEach(function () {
- App.store.commit.restore();
- mock.restore();
- });
- it("requiredSites consistent", function () {
- var quickLinksConfigHBASE = {
- protocol: {
- type: "http"
- },
- links: [
- {
- port: {
- site: "hbase-site"
- }
- }
- ]
- };
- var quickLinksConfigYARN = {
- protocol: {
- checks: [
- {
- site: "yarn-site"
- }
- ],
- type: "https"
- },
- links: [
- {
- port: {
- site: "yarn-site"
- }
- }
- ]
- };
- quickViewLinks.set('content.serviceName', 'HBASE');
- mock.returns(quickLinksConfigHBASE);
- quickViewLinks.loadQuickLinksConfigSuccessCallback({items: []});
- quickViewLinks.set('content.serviceName', 'YARN');
- mock.returns(quickLinksConfigYARN);
- quickViewLinks.loadQuickLinksConfigSuccessCallback({items: []});
- expect(quickViewLinks.get('requiredSiteNames')).to.be.eql(["core-site", "hdfs-site", "hbase-site", "yarn-site"]);
- });
- });
- describe("#getQuickLinksHosts()", function () {
- beforeEach(function () {
- sinon.stub(App.HostComponent, 'find').returns([
- Em.Object.create({
- isMaster: true,
- hostName: 'host1'
- })
- ]);
- });
- afterEach(function () {
- App.HostComponent.find.restore();
- });
- it("call $.ajax", function () {
- quickViewLinks.getQuickLinksHosts();
- var args = testHelpers.findAjaxRequest('name', 'hosts.for_quick_links');
- expect(args[0]).exists;
- expect(args[0].sender).to.be.eql(quickViewLinks);
- expect(args[0].data).to.be.eql({
- clusterName: App.get('clusterName'),
- masterHosts: 'host1',
- urlParams: ''
- });
- });
- it("call $.ajax, HBASE service", function () {
- quickViewLinks.set('content.serviceName', 'HBASE');
- quickViewLinks.getQuickLinksHosts();
- var args = testHelpers.findAjaxRequest('name', 'hosts.for_quick_links');
- expect(args[0]).exists;
- expect(args[0].sender).to.be.eql(quickViewLinks);
- expect(args[0].data).to.be.eql({
- clusterName: App.get('clusterName'),
- masterHosts: 'host1',
- urlParams: ',host_components/metrics/hbase/master/IsActiveMaster'
- });
- });
- });
- describe("#setQuickLinksSuccessCallback()", function () {
- beforeEach(function () {
- this.mock = sinon.stub(quickViewLinks, 'getHosts');
- sinon.stub(quickViewLinks, 'setEmptyLinks');
- sinon.stub(quickViewLinks, 'setSingleHostLinks');
- sinon.stub(quickViewLinks, 'setMultipleHostLinks');
- quickViewLinks.set('content.quickLinks', []);
- });
- afterEach(function () {
- this.mock.restore();
- quickViewLinks.setEmptyLinks.restore();
- quickViewLinks.setSingleHostLinks.restore();
- quickViewLinks.setMultipleHostLinks.restore();
- });
- it("no hosts", function () {
- this.mock.returns([]);
- quickViewLinks.setQuickLinksSuccessCallback();
- expect(quickViewLinks.setEmptyLinks.calledOnce).to.be.true;
- });
- it("quickLinks is not configured", function () {
- this.mock.returns([{}]);
- quickViewLinks.setQuickLinksSuccessCallback();
- expect(quickViewLinks.setEmptyLinks.calledOnce).to.be.false;
- });
- it("single host", function () {
- this.mock.returns([{hostName: 'host1'}]);
- quickViewLinks.setQuickLinksSuccessCallback();
- expect(quickViewLinks.setSingleHostLinks.calledWith([{hostName: 'host1'}])).to.be.true;
- });
- it("multiple hosts", function () {
- this.mock.returns([{hostName: 'host1'}, {hostName: 'host2'}]);
- quickViewLinks.setQuickLinksSuccessCallback();
- expect(quickViewLinks.setMultipleHostLinks.calledWith(
- [{hostName: 'host1'}, {hostName: 'host2'}]
- )).to.be.true;
- });
- });
- describe("#getPublicHostName()", function () {
- it("host present", function () {
- var hosts = [{
- Hosts: {
- host_name: 'host1',
- public_host_name: 'public_name'
- }
- }];
- expect(quickViewLinks.getPublicHostName(hosts, 'host1')).to.equal('public_name');
- });
- it("host absent", function () {
- expect(quickViewLinks.getPublicHostName([], 'host1')).to.be.null;
- });
- });
- describe("#setConfigProperties()", function () {
- var mock = {getConfigsByTags: Em.K};
- beforeEach(function () {
- sinon.stub(App.router, 'get').returns(mock);
- sinon.spy(mock, 'getConfigsByTags');
- });
- afterEach(function () {
- mock.getConfigsByTags.restore();
- App.router.get.restore();
- });
- it("getConfigsByTags called with correct data", function () {
- quickViewLinks.set('actualTags', [{siteName: 'hdfs-site'}]);
- quickViewLinks.set('requiredSiteNames', ['hdfs-site']);
- quickViewLinks.setConfigProperties();
- expect(mock.getConfigsByTags.calledWith([{siteName: 'hdfs-site'}])).to.be.true;
- });
- });
- describe("#setEmptyLinks()", function () {
- it("empty links are set", function () {
- quickViewLinks.setEmptyLinks();
- expect(quickViewLinks.get('quickLinks')).to.eql([{
- label: quickViewLinks.get('quickLinksErrorMessage'),
- }]);
- expect(quickViewLinks.get('isLoaded')).to.be.true;
- });
- });
- describe("#processOozieHosts()", function () {
- it("host status is valid", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'OOZIE_SERVER',
- workStatus: 'STARTED',
- hostName: 'host1'
- })]);
- var host = {hostName: 'host1'};
- quickViewLinks.processOozieHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.active'));
- });
- it("host status is invalid", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'OOZIE_SERVER',
- workStatus: 'INSTALLED',
- hostName: 'host1'
- })]);
- var host = {hostName: 'host1'};
- quickViewLinks.processOozieHosts([host]);
- expect(quickViewLinks.get('quickLinksErrorMessage')).to.equal(Em.I18n.t('quick.links.error.oozie.label'));
- });
- });
- describe("#processHdfsHosts()", function () {
- beforeEach(function () {
- quickViewLinks.set('content.activeNameNode', null);
- quickViewLinks.set('content.standbyNameNode', null);
- quickViewLinks.set('content.standbyNameNode2', null);
- });
- it("active namenode host", function () {
- quickViewLinks.set('content.activeNameNode', Em.Object.create({hostName: 'host1'}));
- var host = {hostName: 'host1'};
- quickViewLinks.processHdfsHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.active'));
- });
- it("standby namenode host", function () {
- quickViewLinks.set('content.standbyNameNode', Em.Object.create({hostName: 'host1'}));
- var host = {hostName: 'host1'};
- quickViewLinks.processHdfsHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.standby'));
- });
- it("second standby namenode host", function () {
- quickViewLinks.set('content.standbyNameNode2', Em.Object.create({hostName: 'host1'}));
- var host = {hostName: 'host1'};
- quickViewLinks.processHdfsHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.standby'));
- });
- });
- describe("#processHbaseHosts()", function () {
- it("isActiveMaster is true", function () {
- var response = {
- items: [
- {
- Hosts: {
- host_name: 'host1'
- },
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- },
- metrics: {
- hbase: {
- master: {
- IsActiveMaster: 'true'
- }
- }
- }
- }
- ]
- }
- ]
- };
- var host = {hostName: 'host1'};
- quickViewLinks.processHbaseHosts([host], response);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.active'));
- });
- it("isActiveMaster is false", function () {
- var response = {
- items: [
- {
- Hosts: {
- host_name: 'host1'
- },
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- },
- metrics: {
- hbase: {
- master: {
- IsActiveMaster: 'false'
- }
- }
- }
- }
- ]
- }
- ]
- };
- var host = {hostName: 'host1'};
- quickViewLinks.processHbaseHosts([host], response);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.standby'));
- });
- it("isActiveMaster is undefined", function () {
- var response = {
- items: [
- {
- Hosts: {
- host_name: 'host1'
- },
- host_components: [
- {
- HostRoles: {
- component_name: 'HBASE_MASTER'
- }
- }
- ]
- }
- ]
- };
- var host = {hostName: 'host1'};
- quickViewLinks.processHbaseHosts([host], response);
- expect(host.status).to.be.undefined;
- });
- });
- describe("#processYarnHosts()", function () {
- it("haStatus is ACTIVE", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host1',
- haStatus: 'ACTIVE'
- })]);
- var host = {hostName: 'host1'};
- quickViewLinks.processYarnHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.active'));
- });
- it("haStatus is STANDBY", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host1',
- haStatus: 'STANDBY'
- })]);
- var host = {hostName: 'host1'};
- quickViewLinks.processYarnHosts([host]);
- expect(host.status).to.equal(Em.I18n.t('quick.links.label.standby'));
- });
- it("haStatus is undefined", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'RESOURCEMANAGER',
- hostName: 'host1'
- })]);
- var host = {hostName: 'host1'};
- quickViewLinks.processYarnHosts([host]);
- expect(host.status).to.be.undefined;
- });
- });
- describe("#findHosts()", function () {
- beforeEach(function () {
- sinon.stub(quickViewLinks, 'getPublicHostName').returns('public_name');
- });
- afterEach(function () {
- quickViewLinks.getPublicHostName.restore();
- });
- it("public_name from getPublicHostName", function () {
- quickViewLinks.set('content.hostComponents', [Em.Object.create({
- componentName: 'C1',
- hostName: 'host1'
- })]);
- expect(quickViewLinks.findHosts('C1', {})).to.eql([{
- hostName: 'host1',
- publicHostName: 'public_name'
- }]);
- });
- });
- describe('#setProtocol', function () {
- var tests = [
- //Yarn
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTPS_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "https for yarn (checks for https passed)",
- result: "https"
- },
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTP_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"http",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTP_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "http for yarn (checks for http passed)",
- result: "http"
- },
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTP_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "http for yarn (checks for https did not pass)",
- result: "http"
- },
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTPS_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"http",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTP_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "https for yarn (checks for http did not pass)",
- result: "https"
- },
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTP_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"HTTP_ONLY",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "http for yarn (override checks with specific protocol type)",
- result: "http"
- },
- {
- serviceName: "YARN",
- configProperties: [
- {type: 'yarn-site', properties: {'yarn.http.policy': 'HTTPS_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"HTTPS_ONLY",
- checks:[
- {property:"yarn.http.policy",
- desired:"HTTPS_ONLY",
- site:"yarn-site"}
- ]
- }
- },
- m: "https for yarn (override checks with specific protocol type)",
- result: "https"
- },
- //Any service - override hadoop.ssl.enabled
- {
- serviceName: "MyService",
- configProperties: [
- {type: 'myservice-site', properties: {'myservice.http.policy': 'HTTPS_ONLY'}},
- {type: 'hdfs-site', properties: {'dfs.http.policy':'HTTP_ONLY'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:[
- {property:"myservice.http.policy",
- desired:"HTTPS_ONLY",
- site:"myservice-site"}
- ]
- }
- },
- m: "https for MyService (checks for https passed, override hadoop.ssl.enabled)",
- result: "https"
- },
- //Oozie
- {
- serviceName: "OOZIE",
- configProperties: [
- {type: 'oozie-site', properties: {'oozie.https.port': '12345', 'oozie.https.keystore.file':'/tmp/oozie.jks', 'oozie.https.keystore.pass':'mypass'}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"oozie.https.port",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.file",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.pass",
- "desired":"EXIST",
- "site":"oozie-site"
- }
- ]
- }
- },
- m: "https for oozie (checks for https passed)",
- result: "https"
- },
- {
- serviceName: "OOZIE",
- configProperties: [
- {type: 'oozie-site', properties: {"oozie.base.url":"http://c6401.ambari.apache.org:11000/oozie"}}
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"oozie.https.port",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.file",
- "desired":"EXIST",
- "site":"oozie-site"
- },
- {
- "property":"oozie.https.keystore.pass",
- "desired":"EXIST",
- "site":"oozie-site"
- }
- ]
- }
- },
- m: "http for oozie (checks for https did not pass)",
- result: "http"
- },
- //Ranger: HDP 2.2
- {
- serviceName: "RANGER",
- configProperties: [{type: 'ranger-site', properties: {'http.enabled': 'false'}}],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"http.enabled",
- "desired":"false",
- "site":"ranger-site"
- }
- ]
- }
- },
- m: "https for ranger (HDP2.2, checks passed)",
- result: "https"
- },
- {
- serviceName: "RANGER",
- configProperties: [{type: 'ranger-site', properties: {'http.enabled': 'true'}}],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"http.enabled",
- "desired":"false",
- "site":"ranger-site"
- }
- ]
- }
- },
- m: "http for ranger (HDP2.2, checks for https did not pass)",
- result: "http"
- },
- //Ranger: HDP 2.3
- {
- serviceName: "RANGER",
- configProperties:
- [
- {
- type: 'ranger-admin-site',
- properties: {'ranger.service.http.enabled': 'false', 'ranger.service.https.attrib.ssl.enabled': 'true'}
- },
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"ranger.service.http.enabled",
- "desired":"false",
- "site":"ranger-admin-site"
- },
- {
- "property":"ranger.service.https.attrib.ssl.enabled",
- "desired":"true",
- "site":"ranger-admin-site"
- }
- ]
- }
- },
- m: "https for ranger (HDP2.3, checks passed)",
- result: "https"
- },
- {
- serviceName: "RANGER",
- configProperties:
- [
- {
- type: 'ranger-admin-site',
- properties: {'ranger.service.http.enabled': 'true', 'ranger.service.https.attrib.ssl.enabled': 'false'}
- },
- ],
- quickLinksConfig: {
- protocol:{
- type:"https",
- checks:
- [
- {
- "property":"ranger.service.http.enabled",
- "desired":"false",
- "site":"ranger-admin-site"
- },
- {
- "property":"ranger.service.https.attrib.ssl.enabled",
- "desired":"true",
- "site":"ranger-admin-site"
- }
- ]
- }
- },
- m: "http for ranger (HDP2.3, checks for https did not pass)",
- result: "http"
- }
- ];
- tests.forEach(function (t) {
- it(t.m, function () {
- quickViewLinks.set('servicesSupportsHttps', t.servicesSupportsHttps);
- expect(quickViewLinks.setProtocol(t.configProperties, t.quickLinksConfig)).to.equal(t.result);
- });
- });
- });
- describe('#setPort', function () {
- var testData = [
- Em.Object.create({
- 'protocol': 'http',
- 'port':{
- 'http_property':'yarn.timeline-service.webapp.address',
- 'http_default_port':'8188',
- 'https_property':'yarn.timeline-service.webapp.https.address',
- 'https_default_port':'8090',
- 'regex': '\\w*:(\\d+)',
- 'site':'yarn-site'
- },
- 'configProperties':
- [
- {
- 'type': 'yarn-site',
- 'properties': {'yarn.timeline-service.webapp.address': 'c6401.ambari.apache.org:8188'}
- },
- ],
- 'result': '8188'
- }),
- Em.Object.create({
- 'protocol': 'https',
- 'port':{
- 'http_property':'yarn.timeline-service.webapp.address',
- 'http_default_port':'8188',
- 'https_property':'yarn.timeline-service.webapp.https.address',
- 'https_default_port':'8090',
- 'regex': '\\w*:(\\d+)',
- 'site':'yarn-site'
- },
- 'configProperties':
- [
- {
- 'type': 'yarn-site',
- 'properties': {'yarn.timeline-service.webapp.https.address': 'c6401.ambari.apache.org:8090'}
- }
- ],
- 'result': '8090'
- })
- ];
- after(function () {
- quickViewLinks.set('configProperties', []);
- });
- testData.forEach(function (item) {
- it(item.service_id + ' ' + item.protocol, function () {
- quickViewLinks.set('configProperties', item.configProperties || []);
- expect(quickViewLinks.setPort(item.port, item.protocol, item.configProperties)).to.equal(item.result);
- })
- }, this);
- });
- describe("#getHosts()", function() {
- beforeEach(function() {
- sinon.stub(quickViewLinks, 'processOozieHosts').returns(['oozieHost']);
- sinon.stub(quickViewLinks, 'processHdfsHosts').returns(['hdfsHost']);
- sinon.stub(quickViewLinks, 'processHbaseHosts').returns(['hbaseHost']);
- sinon.stub(quickViewLinks, 'processYarnHosts').returns(['yarnHost']);
- sinon.stub(quickViewLinks, 'findHosts').returns(['host1']);
- App.set('singleNodeInstall', false);
- quickViewLinks.set('content', Em.Object.create({
- hostComponents: []
- }));
- });
- afterEach(function() {
- quickViewLinks.processOozieHosts.restore();
- quickViewLinks.processHdfsHosts.restore();
- quickViewLinks.processHbaseHosts.restore();
- quickViewLinks.findHosts.restore();
- quickViewLinks.processYarnHosts.restore();
- });
- it("singleNodeInstall is true", function() {
- App.set('singleNodeInstall', true);
- App.set('singleNodeAlias', 'host1');
- expect(quickViewLinks.getHosts({}, 'S1')).to.eql([{
- hostName: 'host1',
- publicHostName: 'host1'
- }])
- });
- it("content is null", function() {
- quickViewLinks.set('content', null);
- expect(quickViewLinks.getHosts({}, 'S1')).to.be.empty;
- });
- it("OOZIE service", function() {
- expect(quickViewLinks.getHosts({}, 'OOZIE')).to.eql(['oozieHost']);
- expect(quickViewLinks.findHosts.calledWith('OOZIE_SERVER', {})).to.be.true;
- expect(quickViewLinks.processOozieHosts.calledOnce).to.be.true;
- });
- it("HDFS service", function() {
- expect(quickViewLinks.getHosts({}, 'HDFS')).to.eql(['hdfsHost']);
- expect(quickViewLinks.findHosts.calledWith('NAMENODE', {})).to.be.true;
- expect(quickViewLinks.processHdfsHosts.calledOnce).to.be.true;
- });
- it("HBASE service", function() {
- expect(quickViewLinks.getHosts({}, 'HBASE')).to.eql(['hbaseHost']);
- expect(quickViewLinks.findHosts.calledWith('HBASE_MASTER', {})).to.be.true;
- expect(quickViewLinks.processHbaseHosts.calledOnce).to.be.true;
- });
- it("YARN service", function() {
- expect(quickViewLinks.getHosts({}, 'YARN')).to.eql(['yarnHost']);
- expect(quickViewLinks.findHosts.calledWith('RESOURCEMANAGER', {})).to.be.true;
- expect(quickViewLinks.processYarnHosts.calledOnce).to.be.true;
- });
- it("STORM service", function() {
- expect(quickViewLinks.getHosts({}, 'STORM')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('STORM_UI_SERVER', {})).to.be.true;
- });
- it("ACCUMULO service", function() {
- expect(quickViewLinks.getHosts({}, 'ACCUMULO')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('ACCUMULO_MONITOR', {})).to.be.true;
- });
- it("ATLAS service", function() {
- expect(quickViewLinks.getHosts({}, 'ATLAS')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('ATLAS_SERVER', {})).to.be.true;
- });
- it("MAPREDUCE2 service", function() {
- expect(quickViewLinks.getHosts({}, 'MAPREDUCE2')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('HISTORYSERVER', {})).to.be.true;
- });
- it("AMBARI_METRICS service", function() {
- expect(quickViewLinks.getHosts({}, 'AMBARI_METRICS')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('METRICS_GRAFANA', {})).to.be.true;
- });
- it("custom service without master", function() {
- expect(quickViewLinks.getHosts({}, 'S1')).to.be.empty;
- });
- it("custom service with master", function() {
- quickViewLinks.set('content', Em.Object.create({
- hostComponents: [
- Em.Object.create({
- isMaster: true,
- componentName: 'C1'
- })
- ]
- }));
- expect(quickViewLinks.getHosts({}, 'S1')).to.eql(['host1']);
- expect(quickViewLinks.findHosts.calledWith('C1', {})).to.be.true;
- });
- });
- });
|