123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- /**
- * 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 Ember = require('ember');
- var App = require('app');
- require('utils/http_client');
- require('models/host');
- require('controllers/wizard/step3_controller');
- describe('App.WizardStep3Controller', function () {
- describe('#getAllRegisteredHostsCallback', function () {
- it('One host is already in the cluster, one host is registered', function() {
- var controller = App.WizardStep3Controller.create({
- hostsInCluster: [{
- hostName: 'wst3_host1'
- }],
- bootHosts: [
- {name:'wst3_host1'},
- {name:'wst3_host2'}
- ]
- });
- var test_data = {
- items: [
- {
- Hosts: {
- host_name: 'wst3_host1'
- }
- },
- {
- Hosts: {
- host_name: 'wst3_host2'
- }
- },
- {
- Hosts: {
- host_name: 'wst3_host3'
- }
- }
- ]
- };
- controller.getAllRegisteredHostsCallback(test_data);
- expect(controller.get('hasMoreRegisteredHosts')).to.equal(true);
- expect(controller.get('registeredHosts').length).to.equal(1);
- });
- it('All hosts are new', function() {
- var controller = App.WizardStep3Controller.create({
- hostsInCluster: [{
- hostName: 'wst3_host1'
- }],
- bootHosts: [
- {name:'wst3_host3'},
- {name:'wst3_host4'}
- ]
- });
- var test_data = {
- items: [
- {
- Hosts: {
- host_name: 'wst3_host3'
- }
- },
- {
- Hosts: {
- host_name: 'wst3_host4'
- }
- }
- ]
- };
- controller.getAllRegisteredHostsCallback(test_data);
- expect(controller.get('hasMoreRegisteredHosts')).to.equal(false);
- expect(controller.get('registeredHosts')).to.equal('');
- });
- it('No new hosts', function() {
- var controller = App.WizardStep3Controller.create({
- hostsInCluster: [{
- hostName: 'wst3_host1'
- }],
- bootHosts: [
- {name:'wst3_host1'}
- ]
- });
- var test_data = {
- items: [
- {
- Hosts: {
- host_name: 'wst3_host1'
- }
- }
- ]
- };
- controller.getAllRegisteredHostsCallback(test_data);
- expect(controller.get('hasMoreRegisteredHosts')).to.equal(false);
- expect(controller.get('registeredHosts')).to.equal('');
- });
- });
- var tests = [
- {
- bootHosts: [
- Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED', isChecked: false}),
- Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
- ],
- m: 'One registered, one registering',
- visibleHosts: {
- RUNNING: {
- e: 0
- },
- REGISTERING: {
- e: 1
- },
- REGISTERED: {
- e: 1
- },
- FAILED: {
- e: 0
- }
- },
- onAllChecked: {
- e: [true, true]
- }
- },
- {
- bootHosts: [
- Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERED', isChecked: false}),
- Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
- ],
- m: 'Two registered',
- visibleHosts: {
- RUNNING: {
- e: 0
- },
- REGISTERING: {
- e: 0
- },
- REGISTERED: {
- e: 2
- },
- FAILED: {
- e: 0
- }
- },
- onAllChecked: {
- e: [true, true]
- }
- },
- {
- bootHosts: [
- Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED', isChecked: false}),
- Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERED', isChecked: false})
- ],
- m: 'One registered, one failed',
- visibleHosts: {
- RUNNING: {
- e: 0
- },
- REGISTERING: {
- e: 0
- },
- REGISTERED: {
- e: 1
- },
- FAILED: {
- e: 1
- }
- },
- onAllChecked: {
- e: [true, true]
- }
- },
- {
- bootHosts: [
- Em.Object.create({name:'wst3_host1', bootStatus: 'FAILED', isChecked: false}),
- Em.Object.create({name:'wst3_host2', bootStatus: 'FAILED', isChecked: false})
- ],
- m: 'Two failed',
- visibleHosts: {
- RUNNING: {
- e: 0
- },
- REGISTERING: {
- e: 0
- },
- REGISTERED: {
- e: 0
- },
- FAILED: {
- e: 2
- }
- },
- onAllChecked: {
- e: [true, true]
- }
- },
- {
- bootHosts: [
- Em.Object.create({name:'wst3_host1', bootStatus: 'REGISTERING', isChecked: false}),
- Em.Object.create({name:'wst3_host2', bootStatus: 'REGISTERING', isChecked: false})
- ],
- m: 'Two registering',
- visibleHosts: {
- RUNNING: {
- e: 0
- },
- REGISTERING: {
- e: 2
- },
- REGISTERED: {
- e: 0
- },
- FAILED: {
- e: 0
- }
- },
- onAllChecked: {
- e: [true, true]
- }
- }
- ];
- describe('#registrationTimeoutSecs', function() {
- it('Manual install', function() {
- var controller = App.WizardStep3Controller.create({
- content: {
- installOptions: {
- manualInstall: true
- }
- }
- });
- expect(controller.get('registrationTimeoutSecs')).to.equal(15);
- });
- it('Not manual install', function() {
- var controller = App.WizardStep3Controller.create({
- content: {
- installOptions: {
- manualInstall: false
- }
- }
- });
- expect(controller.get('registrationTimeoutSecs')).to.equal(120);
- });
- });
- describe('#isHostHaveWarnings', function() {
- var tests = [
- {
- warnings: [{},{}],
- m: 'Warnings exist',
- e: true
- },
- {
- warnings: [],
- m: 'Warnings don\'t exist',
- e: false
- }
- ];
- tests.forEach(function(test) {
- var controller = App.WizardStep3Controller.create();
- controller.set('warnings', test.warnings);
- it(test.m, function() {
- expect(controller.get('isHostHaveWarnings')).to.equal(test.e);
- });
- });
- });
- describe('#noHostsSelected', function() {
- tests.forEach(function(test) {
- it(test.m + ' - nothing checked', function() {
- var controller = App.WizardStep3Controller.create({
- hosts: test.bootHosts
- });
- controller.get('hosts').setEach('isChecked', false);
- console.log(controller.hosts);
- expect(controller.get('noHostsSelected')).to.equal(true);
- });
- it(test.m + ' - one checked', function() {
- var controller = App.WizardStep3Controller.create({
- hosts: test.bootHosts
- });
- controller.get('hosts').setEach('isChecked', true);
- expect(controller.get('noHostsSelected')).to.equal(false);
- });
- });
- });
- });
|