123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- /**
- * 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('App.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('Disable/enable components', function() {
- App.set('handleStackDependencyTest', true);
- modelSetup.setupStackVersion(this, 'HDP-2.1');
- var testableComponent = Em.Object.create({
- componentName: 'APP_TIMELINE_SERVER',
- serviceName: 'YARN'
- });
- var expectedInfo = {
- componentName: 'APP_TIMELINE_SERVER',
- properties: {
- global_properties: ['ats_host', 'apptimelineserver_heapsize'],
- site_properties: ['yarn.timeline-service.generic-application-history.store-class', 'yarn.timeline-service.store-class', 'yarn.timeline-service.leveldb-timeline-store.path']
- },
- reviewConfigs: {
- component_name: 'APP_TIMELINE_SERVER'
- },
- configCategory: {
- name: 'AppTimelineServer'
- }
- };
- var globalProperties = require('data/HDP2/global_properties');
- var siteProperties = require('data/HDP2/site_properties');
- var reviewConfigs = require('data/review_configs');
- var disableResult = App.disableComponent(testableComponent);
- describe('#disableComponent()', function() {
- // copy
- var _globalProperties = $.extend({}, globalProperties);
- var _siteProperties = $.extend({}, siteProperties);
- var _reviewConfigs = JSON.parse(JSON.stringify(reviewConfigs));
- describe('result validation', function() {
- it('component name should be "' + expectedInfo.componentName + '"', function() {
- expect(disableResult.get('componentName')).to.eql(expectedInfo.componentName);
- });
- it('config category name should be "' + expectedInfo.configCategory.name +'"', function() {
- expect(disableResult.get('configCategory.name')).to.eql(expectedInfo.configCategory.name);
- });
- for(var siteName in expectedInfo.properties) {
- (function(site) {
- expectedInfo.properties[site].forEach(function(property) {
- it(property + ' present in ' + site, function() {
- expect(disableResult.get('properties.' + site).mapProperty('name')).to.include(property);
- });
- }, this);
- })(siteName);
- }
- it('site and global properties should not be equal', function() {
- expect(disableResult.get('properties.global_properties')).to.not.include.members(disableResult.get('properties.site_properties'));
- });
- });
- describe('effect validation',function() {
- it('should remove global properties of component', function() {
- expect(_globalProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.global_properties);
- });
- it('should remove site properties of component', function() {
- expect(_siteProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.site_properties);
- });
- it('should remove review config for component', function() {
- var reviewConfig = _reviewConfigs.findProperty('config_name', 'services')
- .config_value.findProperty('service_name', testableComponent.get('serviceName'))
- .service_components.mapProperty('component_name');
- expect(reviewConfig).to.not.include(expectedInfo.reviewConfigs.component_name);
- });
- });
- });
- describe('#enableComponent', function() {
- App.enableComponent(disableResult);
- it('should add global properties of component', function() {
- expect(globalProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.global_properties);
- });
- it('should add site properties of component', function() {
- expect(siteProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.site_properties);
- });
- it('should add review config for component', function() {
- var reviewConfig = reviewConfigs.findProperty('config_name', 'services')
- .config_value.findProperty('service_name', testableComponent.get('serviceName'))
- .get('service_components').mapProperty('component_name');
- expect(reviewConfig).to.include(expectedInfo.reviewConfigs.component_name);
- });
- });
- modelSetup.restoreStackVersion(this);
- });
- 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/version/'
- },
- {
- title: 'if currentStackVersion is "HDP-1.3.1" then stackVersionURL should be "/stacks/HDP/version/1.3.1"',
- currentStackVersion: 'HDP-1.3.1',
- defaultStackVersion: '',
- result: '/stacks/HDP/version/1.3.1'
- },
- {
- title: 'if defaultStackVersion is "HDP-1.3.1" then stackVersionURL should be "/stacks/HDP/version/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDP-1.3.1',
- result: '/stacks/HDP/version/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/version/1.3.2'
- },
- {
- title: 'if defaultStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/version/1.3.1"',
- currentStackVersion: '',
- defaultStackVersion: 'HDPLocal-1.3.1',
- result: '/stacks/HDPLocal/version/1.3.1'
- },
- {
- title: 'if currentStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/version/1.3.1"',
- currentStackVersion: 'HDPLocal-1.3.1',
- defaultStackVersion: '',
- result: '/stacks/HDPLocal/version/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('#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('#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('#handleStackDependedComponents()', function () {
- beforeEach(function(){
- modelSetup.setupStackServiceComponent();
- });
- afterEach(function(){
- modelSetup.cleanStackServiceComponent();
- });
- it('if handleStackDependencyTest is true then stackDependedComponents should be unmodified', function () {
- App.set('testMode', false);
- App.set('handleStackDependencyTest', true);
- App.handleStackDependedComponents();
- expect(App.get('stackDependedComponents')).to.be.empty;
- });
- it('if testMode is true then stackDependedComponents should be unmodified', function () {
- App.set('handleStackDependencyTest', false);
- App.set('testMode', true);
- App.handleStackDependedComponents();
- expect(App.get('stackDependedComponents')).to.be.empty;
- });
- it('if stack contains all components then stackDependedComponents should be empty', function () {
- App.set('testMode', false);
- App.set('handleStackDependencyTest', false);
- App.handleStackDependedComponents();
- expect(App.get('stackDependedComponents')).to.be.empty;
- });
- it('if stack is missing component then push it to stackDependedComponents', function () {
- App.set('testMode', false);
- App.set('handleStackDependencyTest', false);
- var dtRecord = App.StackServiceComponent.find('DATANODE');
- dtRecord.deleteRecord();
- dtRecord.get('stateManager').transitionTo('loading');
- App.handleStackDependedComponents();
- expect(App.get('stackDependedComponents').mapProperty('componentName')).to.eql(["DATANODE"]);
- App.store.load(App.StackServiceComponent, {
- id: 'DATANODE',
- component_name: 'DATANODE',
- service_name: 'HDFS',
- component_category: 'SLAVE',
- is_master: false,
- is_client: false,
- stack_name: 'HDP',
- stack_version: '2.1'
- });
- });
- it('remove stack components from stackDependedComponents', function () {
- App.set('testMode', false);
- App.set('handleStackDependencyTest', false);
- App.set('stackDependedComponents', [
- Em.Object.create({
- componentName: "DATANODE",
- serviceName: "HDFS",
- properties: {},
- reviewConfigs: {},
- configCategory: {}
- }),
- Em.Object.create({
- componentName: "categoryComponent",
- serviceName: "",
- properties: {},
- reviewConfigs: {},
- configCategory: {}
- })
- ]);
- App.handleStackDependedComponents();
- expect(App.get('stackDependedComponents').mapProperty('componentName')).to.eql(["categoryComponent"]);
- });
- });
- });
|