123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 |
- /**
- * 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');
- require('models/host_component');
- require('models/stack_service_component');
- var modelSetup = require('test/init_model_test');
- describe('App', function () {
- describe('#stackVersionURL', function () {
- App.QuickViewLinks.reopen({
- loadTags: function () {
- }
- });
- var testCases = [
- {
- title: 'if currentStackVersion and defaultStackVersion are empty then stackVersionURL should contain prefix',
- currentStackVersion: '',
- defaultStackVersion: '',
- result: '/stacks/HDP/versions/'
- },
- {
- title: 'if currentStackVersion is "HDP-1.3.1" then stackVersionURL should be "/stacks/HDP/versions/1.3.1"',
- currentStackVersion: 'HDP-1.3.1',
- defaultStackVersion: '',
- result: '/stacks/HDP/versions/1.3.1'
- },
- {
- title: 'if defaultStackVersion is "HDP-1.3.1" then stackVersionURL should be "/stacks/HDP/versions/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDP-1.3.1',
- result: '/stacks/HDP/versions/1.3.1'
- },
- {
- title: 'if defaultStackVersion and currentStackVersion are different then stackVersionURL should have currentStackVersion value',
- currentStackVersion: 'HDP-1.3.2',
- defaultStackVersion: 'HDP-1.3.1',
- result: '/stacks/HDP/versions/1.3.2'
- },
- {
- title: 'if defaultStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/versions/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDPLocal-1.3.1',
- result: '/stacks/HDPLocal/versions/1.3.1'
- },
- {
- title: 'if currentStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/versions/1.3.1"',
- currentStackVersion: 'HDPLocal-1.3.1',
- defaultStackVersion: '',
- result: '/stacks/HDPLocal/versions/1.3.1'
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- App.set('currentStackVersion', test.currentStackVersion);
- App.set('defaultStackVersion', test.defaultStackVersion);
- expect(App.get('stackVersionURL')).to.equal(test.result);
- App.set('currentStackVersion', "HDP-1.2.2");
- App.set('defaultStackVersion', "HDP-1.2.2");
- });
- });
- });
- describe('#stack2VersionURL', function () {
- var testCases = [
- {
- title: 'if currentStackVersion and defaultStackVersion are empty then stack2VersionURL should contain prefix',
- currentStackVersion: '',
- defaultStackVersion: '',
- result: '/stacks2/HDP/versions/'
- },
- {
- title: 'if currentStackVersion is "HDP-1.3.1" then stack2VersionURL should be "/stacks2/HDP/versions/1.3.1"',
- currentStackVersion: 'HDP-1.3.1',
- defaultStackVersion: '',
- result: '/stacks2/HDP/versions/1.3.1'
- },
- {
- title: 'if defaultStackVersion is "HDP-1.3.1" then stack2VersionURL should be "/stacks/HDP/versions/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDP-1.3.1',
- result: '/stacks2/HDP/versions/1.3.1'
- },
- {
- title: 'if defaultStackVersion and currentStackVersion are different then stack2VersionURL should have currentStackVersion value',
- currentStackVersion: 'HDP-1.3.2',
- defaultStackVersion: 'HDP-1.3.1',
- result: '/stacks2/HDP/versions/1.3.2'
- },
- {
- title: 'if defaultStackVersion is "HDPLocal-1.3.1" then stack2VersionURL should be "/stacks2/HDPLocal/versions/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDPLocal-1.3.1',
- result: '/stacks2/HDPLocal/versions/1.3.1'
- },
- {
- title: 'if currentStackVersion is "HDPLocal-1.3.1" then stack2VersionURL should be "/stacks2/HDPLocal/versions/1.3.1"',
- currentStackVersion: 'HDPLocal-1.3.1',
- defaultStackVersion: '',
- result: '/stacks2/HDPLocal/versions/1.3.1'
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- App.set('currentStackVersion', test.currentStackVersion);
- App.set('defaultStackVersion', test.defaultStackVersion);
- expect(App.get('stack2VersionURL')).to.equal(test.result);
- App.set('currentStackVersion', "HDP-1.2.2");
- App.set('defaultStackVersion', "HDP-1.2.2");
- });
- });
- });
- describe('#falconServerURL', function () {
- var testCases = [
- {
- title: 'No services installed, url should be empty',
- service: Em.A([]),
- result: ''
- },
- {
- title: 'FALCON is not installed, url should be empty',
- service: Em.A([
- {
- serviceName: 'HDFS'
- }
- ]),
- result: ''
- },
- {
- title: 'FALCON is installed, url should be "host1"',
- service: Em.A([
- Em.Object.create({
- serviceName: 'FALCON',
- hostComponents: [
- Em.Object.create({
- componentName: 'FALCON_SERVER',
- hostName: 'host1'
- })
- ]
- })
- ]),
- result: 'host1'
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- sinon.stub(App.Service, 'find', function () {
- return test.service;
- });
- expect(App.get('falconServerURL')).to.equal(test.result);
- App.Service.find.restore();
- });
- });
- });
- describe('#currentStackVersionNumber', function () {
- var testCases = [
- {
- title: 'if currentStackVersion is empty then currentStackVersionNumber should be empty',
- currentStackVersion: '',
- result: ''
- },
- {
- title: 'if currentStackVersion is "HDP-1.3.1" then currentStackVersionNumber should be "1.3.1',
- currentStackVersion: 'HDP-1.3.1',
- result: '1.3.1'
- },
- {
- title: 'if currentStackVersion is "HDPLocal-1.3.1" then currentStackVersionNumber should be "1.3.1',
- currentStackVersion: 'HDPLocal-1.3.1',
- result: '1.3.1'
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- App.set('currentStackVersion', test.currentStackVersion);
- expect(App.get('currentStackVersionNumber')).to.equal(test.result);
- App.set('currentStackVersion', "HDP-1.2.2");
- });
- });
- });
- describe('#isHadoop2Stack', function () {
- var testCases = [
- {
- title: 'if currentStackVersion is empty then isHadoop2Stack should be false',
- currentStackVersion: '',
- result: false
- },
- {
- title: 'if currentStackVersion is "HDP-1.9.9" then isHadoop2Stack should be false',
- currentStackVersion: 'HDP-1.9.9',
- result: false
- },
- {
- title: 'if currentStackVersion is "HDP-2.0.0" then isHadoop2Stack should be true',
- currentStackVersion: 'HDP-2.0.0',
- result: true
- },
- {
- title: 'if currentStackVersion is "HDP-2.0.1" then isHadoop2Stack should be true',
- currentStackVersion: 'HDP-2.0.1',
- result: true
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- App.set('currentStackVersion', test.currentStackVersion);
- expect(App.get('isHadoop2Stack')).to.equal(test.result);
- App.set('currentStackVersion', "HDP-1.2.2");
- });
- });
- });
- describe('#isHadoop21Stack', function () {
- var tests = [
- {
- v: '',
- e: false
- },
- {
- v: 'HDP',
- e: false
- },
- {
- v: 'HDP1',
- e: false
- },
- {
- v: 'HDP-1',
- e: false
- },
- {
- v: 'HDP-2.0',
- e: false
- },
- {
- v: 'HDP-2.0.1000',
- e: false
- },
- {
- v: 'HDP-2.1',
- e: true
- },
- {
- v: 'HDP-2.1.3434',
- e: true
- },
- {
- v: 'HDP-2.2',
- e: true
- },
- {
- v: 'HDP-2.2.1212',
- e: true
- }
- ];
- tests.forEach(function (test) {
- it(test.v, function () {
- App.QuickViewLinks.prototype.setQuickLinks = function () {
- };
- App.set('currentStackVersion', test.v);
- var calculated = App.get('isHadoop21Stack');
- var expected = test.e;
- expect(calculated).to.equal(expected);
- });
- });
- });
- describe('#isHaEnabled', function () {
- it('if hadoop stack version less than 2 then isHaEnabled should be false', function () {
- App.set('currentStackVersion', 'HDP-1.3.1');
- expect(App.get('isHaEnabled')).to.equal(false);
- App.set('currentStackVersion', "HDP-1.2.2");
- });
- it('if hadoop stack version higher than 2 then isHaEnabled should be true', function () {
- App.set('currentStackVersion', 'HDP-2.0.1');
- expect(App.get('isHaEnabled')).to.equal(true);
- App.set('currentStackVersion', "HDP-1.2.2");
- });
- it('if cluster has SECONDARY_NAMENODE then isHaEnabled should be false', function () {
- App.store.load(App.HostComponent, {
- id: 'SECONDARY_NAMENODE',
- component_name: 'SECONDARY_NAMENODE'
- });
- App.set('currentStackVersion', 'HDP-2.0.1');
- expect(App.get('isHaEnabled')).to.equal(false);
- App.set('currentStackVersion', "HDP-1.2.2");
- });
- });
- describe('#services', function () {
- var stackServices = [
- Em.Object.create({
- serviceName: 'S1',
- isClientOnlyService: true
- }),
- Em.Object.create({
- serviceName: 'S2',
- hasClient: true
- }),
- Em.Object.create({
- serviceName: 'S3',
- hasMaster: true
- }),
- Em.Object.create({
- serviceName: 'S4',
- hasSlave: true
- }),
- Em.Object.create({
- serviceName: 'S5',
- isNoConfigTypes: true
- }),
- Em.Object.create({
- serviceName: 'S6',
- isMonitoringService: true
- }),
- Em.Object.create({
- serviceName: 'S7'
- })
- ];
- it('distribute services by categories', function () {
- sinon.stub(App.StackService, 'find', function () {
- return stackServices;
- });
- expect(App.get('services.all')).to.eql(['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7']);
- expect(App.get('services.clientOnly')).to.eql(['S1']);
- expect(App.get('services.hasClient')).to.eql(['S2']);
- expect(App.get('services.hasMaster')).to.eql(['S3']);
- expect(App.get('services.hasSlave')).to.eql(['S4']);
- expect(App.get('services.noConfigTypes')).to.eql(['S5']);
- expect(App.get('services.monitoring')).to.eql(['S6']);
- App.StackService.find.restore();
- });
- });
- describe('#components', function () {
- var testCases = [
- {
- key: 'allComponents',
- data: [
- Em.Object.create({
- componentName: 'C1'
- })
- ],
- result: ['C1']
- },
- {
- key: 'reassignable',
- data: [
- Em.Object.create({
- componentName: 'C2',
- isReassignable: true
- })
- ],
- result: ['C2']
- },
- {
- key: 'restartable',
- data: [
- Em.Object.create({
- componentName: 'C3',
- isRestartable: true
- })
- ],
- result: ['C3']
- },
- {
- key: 'deletable',
- data: [
- Em.Object.create({
- componentName: 'C4',
- isDeletable: true
- })
- ],
- result: ['C4']
- },
- {
- key: 'rollinRestartAllowed',
- data: [
- Em.Object.create({
- componentName: 'C5',
- isRollinRestartAllowed: true
- })
- ],
- result: ['C5']
- },
- {
- key: 'decommissionAllowed',
- data: [
- Em.Object.create({
- componentName: 'C6',
- isDecommissionAllowed: true
- })
- ],
- result: ['C6']
- },
- {
- key: 'refreshConfigsAllowed',
- data: [
- Em.Object.create({
- componentName: 'C7',
- isRefreshConfigsAllowed: true
- })
- ],
- result: ['C7']
- },
- {
- key: 'addableToHost',
- data: [
- Em.Object.create({
- componentName: 'C8',
- isAddableToHost: true
- })
- ],
- result: ['C8']
- },
- {
- key: 'addableMasterInstallerWizard',
- data: [
- Em.Object.create({
- componentName: 'C9',
- isMasterAddableInstallerWizard: true
- })
- ],
- result: ['C9']
- },
- {
- key: 'multipleMasters',
- data: [
- Em.Object.create({
- componentName: 'C10',
- isMasterWithMultipleInstances: true
- })
- ],
- result: ['C10']
- },
- {
- key: 'slaves',
- data: [
- Em.Object.create({
- componentName: 'C11',
- isSlave: true
- })
- ],
- result: ['C11']
- },
- {
- key: 'masters',
- data: [
- Em.Object.create({
- componentName: 'C12',
- isMaster: true
- })
- ],
- result: ['C12']
- },
- {
- key: 'clients',
- data: [
- Em.Object.create({
- componentName: 'C13',
- isClient: true
- })
- ],
- result: ['C13']
- }
- ];
- testCases.forEach(function (test) {
- it(test.key + ' should contain ' + test.result, function () {
- sinon.stub(App.StackServiceComponent, 'find', function () {
- return test.data;
- });
- expect(App.get('components.' + test.key)).to.eql(test.result);
- App.StackServiceComponent.find.restore();
- })
- })
- });
- });
|