You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/06/21 01:09:46 UTC

svn commit: r1495231 - in /incubator/ambari/trunk/ambari-web/test/controllers: installer_test.js main/admin/security/add/step2_test.js main/service/ main/service/reassign_controller_test.js wizard_test.js

Author: yusaku
Date: Thu Jun 20 23:09:46 2013
New Revision: 1495231

URL: http://svn.apache.org/r1495231
Log:
AMBARI-2445. Wizard and installers Unit tests. (Oleg Nechiporenko via yusaku)

Added:
    incubator/ambari/trunk/ambari-web/test/controllers/installer_test.js
    incubator/ambari/trunk/ambari-web/test/controllers/main/admin/security/add/step2_test.js
    incubator/ambari/trunk/ambari-web/test/controllers/main/service/
    incubator/ambari/trunk/ambari-web/test/controllers/main/service/reassign_controller_test.js
    incubator/ambari/trunk/ambari-web/test/controllers/wizard_test.js

Added: incubator/ambari/trunk/ambari-web/test/controllers/installer_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/controllers/installer_test.js?rev=1495231&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/controllers/installer_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/controllers/installer_test.js Thu Jun 20 23:09:46 2013
@@ -0,0 +1,80 @@
+/**
+ * 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('models/cluster');
+require('controllers/wizard');
+require('controllers/installer');
+
+describe('App.InstallerController', function () {
+
+  var installerController = App.InstallerController.create();
+
+  describe('#loadStacksVersionsSuccessCallback', function() {
+    var test_data = {
+      "items" : [
+        {
+          "href" : "http://ec2-54-224-185-227.compute-1.amazonaws.com:8080/api/v1/stacks2/HDP/versions/1.2.0",
+          "Versions" : {
+            "active" : false,
+            "min_upgrade_version" : null,
+            "stack_name" : "HDP",
+            "stack_version" : "1.2.0"
+          }
+        },
+        {
+          "href" : "http://ec2-54-224-185-227.compute-1.amazonaws.com:8080/api/v1/stacks2/HDP/versions/1.2.1",
+          "Versions" : {
+            "active" : true,
+            "min_upgrade_version" : null,
+            "stack_name" : "HDP",
+            "stack_version" : "1.2.1"
+          }
+        },
+        {
+          "href" : "http://ec2-54-224-185-227.compute-1.amazonaws.com:8080/api/v1/stacks2/HDP/versions/1.3.0",
+          "Versions" : {
+            "active" : true,
+            "min_upgrade_version" : "1.2.0",
+            "stack_name" : "HDP",
+            "stack_version" : "1.3.0"
+          }
+        },
+        {
+          "href" : "http://ec2-54-224-185-227.compute-1.amazonaws.com:8080/api/v1/stacks2/HDP/versions/2.0.1",
+          "Versions" : {
+            "active" : false,
+            "min_upgrade_version" : null,
+            "stack_name" : "HDP",
+            "stack_version" : "2.0.1"
+          }
+        }
+      ]
+    }
+    it ('Correct data', function() {
+      installerController.loadStacksVersionsSuccessCallback(test_data);
+      expect(installerController.get('stacks.length')).to.equal(2);
+      expect(installerController.get('stacks').everyProperty('isSelected')).to.equal(false);
+      expect(installerController.get('stacks').mapProperty('name')).to.eql(['HDP-1.3.0', 'HDP-1.2.1']);
+    });
+  });
+
+
+
+});

Added: incubator/ambari/trunk/ambari-web/test/controllers/main/admin/security/add/step2_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/controllers/main/admin/security/add/step2_test.js?rev=1495231&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/controllers/main/admin/security/add/step2_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/controllers/main/admin/security/add/step2_test.js Thu Jun 20 23:09:46 2013
@@ -0,0 +1,114 @@
+/**
+ * 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('controllers/main/admin/security/add/step2');
+require('utils/polling');
+require('models/cluster_states');
+
+describe('App.MainAdminSecurityAddStep2Controller', function () {
+
+  var mainAdminSecurityAddStep2Controller = App.MainAdminSecurityAddStep2Controller.create();
+
+  describe('#clearStep', function() {
+    mainAdminSecurityAddStep2Controller.set('stepConfigs',[1,2,3]);
+    it('clear', function() {
+      mainAdminSecurityAddStep2Controller.clearStep();
+      expect(mainAdminSecurityAddStep2Controller.get('stepConfigs.length')).to.equal(0);
+    });
+  });
+
+  describe('#isSubmitDisabled', function() {
+    var tests = [
+      {
+        config:[
+          {
+            showConfig: true,
+            errorCount: 0
+          }
+        ],
+        m: 'All show configs, nothing with errors',
+        e: false
+      },
+      {
+        config:[
+          {
+            showConfig: true,
+            errorCount: 0
+          },
+          {
+            showConfig: true,
+            errorCount: 1
+          }
+        ],
+        m: 'All show configs, 1 with errors',
+        e: true
+      },
+      {
+        config:[
+          {
+            showConfig: true,
+            errorCount: 0
+          },
+          {
+            showConfig: false,
+            errorCount: 1
+          }
+        ],
+        m: '1 has errors but not visible',
+        e: false
+      },
+      {
+        config:[
+          {
+            showConfig: false,
+            errorCount: 0
+          },
+          {
+            showConfig: false,
+            errorCount: 1
+          }
+        ],
+        m: '1 has errors, all not visible',
+        e: false
+      },
+      {
+        config:[
+          {
+            showConfig: true,
+            errorCount: 1
+          },
+          {
+            showConfig: true,
+            errorCount: 1
+          }
+        ],
+        m: 'All has errors, all not visible',
+        e: true
+      }
+    ];
+    tests.forEach(function(test) {
+      it(test.m, function() {
+        mainAdminSecurityAddStep2Controller.set('stepConfigs', test.config);
+        expect(mainAdminSecurityAddStep2Controller.get('isSubmitDisabled')).to.equal(test.e);
+      });
+    });
+  });
+
+});

Added: incubator/ambari/trunk/ambari-web/test/controllers/main/service/reassign_controller_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/controllers/main/service/reassign_controller_test.js?rev=1495231&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/controllers/main/service/reassign_controller_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/controllers/main/service/reassign_controller_test.js Thu Jun 20 23:09:46 2013
@@ -0,0 +1,47 @@
+/**
+ * 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('models/cluster');
+require('controllers/wizard');
+require('controllers/main/service/reassign_controller');
+
+describe('App.ReassignMasterController', function () {
+
+  var reassignMasterController = App.ReassignMasterController.create({});
+
+  describe('#totalSteps', function () {
+    it('check', function () {
+      expect(reassignMasterController.get('totalSteps')).to.equal(6);
+    });
+  });
+
+  reassignMasterController.set('content.reassign', {service_id:null});
+
+  describe('#skipStep3', function() {
+    it('should be TRUE for GANGLIA', function() {
+      reassignMasterController.set('content.reassign.service_id', 'GANGLIA');
+      expect(reassignMasterController.get('skipStep3')).to.equal(true);
+    });
+    it('should be FALSE for others', function() {
+      reassignMasterController.set('content.reassign.service_id', 'HDFS');
+      expect(reassignMasterController.get('skipStep3')).to.equal(false);
+    });
+  });
+
+});

Added: incubator/ambari/trunk/ambari-web/test/controllers/wizard_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/controllers/wizard_test.js?rev=1495231&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/controllers/wizard_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/controllers/wizard_test.js Thu Jun 20 23:09:46 2013
@@ -0,0 +1,97 @@
+/**
+ * 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('models/cluster');
+require('controllers/wizard');
+
+describe('App.WizardController', function () {
+
+  var wizardController = App.WizardController.create({});
+
+  var totalSteps = 11;
+  var ruller = [];
+  for(var i = 0; i < totalSteps; i++) {
+    ruller.push(i);
+  }
+
+  describe('#setLowerStepsDisable', function() {
+    for(var i = 1; i < totalSteps; i++) {
+      var indx = i;
+      var steps = [];
+      for(var j = 1; j <= indx; j++) {
+        steps.push(Em.Object.create({step:j,value:false}));
+      }
+      wizardController.set('isStepDisabled', steps);
+      for(j = 1; j <= indx; j++) {
+        it('Steps: ' + i + ' | Disabled: ' + (j-1), function() {
+          wizardController.setLowerStepsDisable(j);
+          expect(wizardController.get('isStepDisabled').filterProperty('value', true).length).to.equal(j-1);
+        });
+      }
+    }
+  });
+
+  // isStep0 ... isStep10 tests
+  App.WizardController1 = App.WizardController.extend({currentStep:''});
+  var tests = [];
+  for(var i = 0; i < totalSteps; i++) {
+    var n = ruller.slice(0);
+    n.splice(i,1);
+    tests.push({i:i,n:n});
+  }
+  tests.forEach(function(test) {
+    describe('isStep'+test.i, function() {
+      var w = App.WizardController1.create();
+      w.set('currentStep', test.i);
+      it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function() {
+        expect(w.get('isStep'+ test.i)).to.equal(true);
+      });
+      test.n.forEach(function(indx) {
+        it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function() {
+          expect(w.get('isStep'+ indx)).to.equal(false);
+        });
+      });
+    });
+  });
+  // isStep0 ... isStep10 tests end
+
+  describe('#gotoStep', function() {
+    var w = App.WizardController1.create();
+    var steps = [];
+    for(var j = 0; j < totalSteps; j++) {
+      steps.push(Em.Object.create({step:j,value:false}));
+    }
+    steps.forEach(function(step, index) {
+      step.set('value', true);
+      w.set('isStepDisabled', steps);
+      it('step ' + index + ' is disabled, so gotoStep('+index+') is not possible', function() {
+        expect(w.gotoStep(index)).to.equal(false);
+      });
+    });
+  });
+
+  describe('#launchBootstrapSuccessCallback', function() {
+    it('Save bootstrapRequestId', function() {
+      var data = {requestId:123};
+      wizardController.launchBootstrapSuccessCallback(data);
+      expect(wizardController.get('bootstrapRequestId')).to.equal(data.requestId);
+    });
+  });
+
+});