瀏覽代碼

AMBARI-947. Make it easier to test Deploy (Install, Start + Test) step of the wizard. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1406448 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父節點
當前提交
677a6773bf

+ 3 - 0
AMBARI-666-CHANGES.txt

@@ -365,6 +365,9 @@ AMBARI-666 branch (unreleased changes)
 
 
   IMPROVEMENTS
   IMPROVEMENTS
 
 
+  AMBARI-947. Make it easier to test Deploy (Install, Start + Test) step
+  of the wizard. (yusaku)
+
   AMBARI-978. Refactor App Browser code. (yusaku)
   AMBARI-978. Refactor App Browser code. (yusaku)
 
 
   AMBARI-977. Refactor Wizard and Cluster Management code. (yusaku)
   AMBARI-977. Refactor Wizard and Cluster Management code. (yusaku)

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_1.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "PENDING",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "PENDING",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_2.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_3.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_4.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_5.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 41 - 0
ambari-web/app/assets/data/wizard/deploy/poll_5_failed.json

@@ -0,0 +1,41 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/1",
+  "Requests" : {
+    "id" : 1
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "FAILED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1",
+        "sf" : "100"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_6.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/2",
+  "Requests" : {
+    "id" : 2
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_7.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/2",
+  "Requests" : {
+    "id" : 2
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_8.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/2",
+  "Requests" : {
+    "id" : 2
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 40 - 0
ambari-web/app/assets/data/wizard/deploy/poll_9.json

@@ -0,0 +1,40 @@
+{
+  "href" : "http://localhost:8080/api/clusters/mycluster/requests/2",
+  "Requests" : {
+    "id" : 2
+  },
+  "tasks" : [
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/1",
+      "Tasks" : {
+        "id" : "1",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "DATANODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/2/tasks/2",
+      "Tasks" : {
+        "id" : "2",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "START",
+        "start_time" : "-1",
+        "role" : "NAMENODE",
+        "stderr" : "",
+        "host_name" : "localhost.localdomain",
+        "stage_id" : "1"
+      }
+    }
+  ]
+}

+ 3 - 10
ambari-web/app/controllers/installer.js

@@ -200,14 +200,6 @@ App.InstallerController = Em.Controller.extend({
     }
     }
   },
   },
 
 
-  /**
-   *
-   * @param cluster ClusterModel
-   */
-  createCluster: function (cluster) {
-    alert('created cluster ' + cluster.name);
-  },
-
   content: Em.Object.create({
   content: Em.Object.create({
     cluster: null,
     cluster: null,
     hosts: null,
     hosts: null,
@@ -713,10 +705,11 @@ App.InstallerController = Em.Controller.extend({
   installServices: function () {
   installServices: function () {
     var self = this;
     var self = this;
     var clusterName = this.get('content.cluster.name');
     var clusterName = this.get('content.cluster.name');
-    var url = '/api/clusters/' + clusterName + '/services?state=INIT';
+    var url = (App.testMode) ? '/data/wizard/deploy/poll_1.json' : '/api/clusters/' + clusterName + '/services?state=INIT';
+    var method = (App.testMode) ? 'GET' : 'PUT';
     var data = '{"ServiceInfo": {"state": "INSTALLED"}}';
     var data = '{"ServiceInfo": {"state": "INSTALLED"}}';
     $.ajax({
     $.ajax({
-      type: 'PUT',
+      type: method,
       url: url,
       url: url,
       data: data,
       data: data,
       async: false,
       async: false,

+ 1 - 1
ambari-web/app/controllers/main/host/add_controller.js

@@ -278,7 +278,7 @@ App.AddHostController = Em.Controller.extend({
       hostsInfo.localRepoPath = '';
       hostsInfo.localRepoPath = '';
     }
     }
 
 
-    hostsInfo.sshKey = 'random';
+    hostsInfo.sshKey = '';
     hostsInfo.passphrase = '';
     hostsInfo.passphrase = '';
     hostsInfo.confirmPassphrase = '';
     hostsInfo.confirmPassphrase = '';
 
 

+ 7 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -421,6 +421,12 @@ App.WizardStep8Controller = Em.Controller.extend({
    * Onclick handler for <code>next</code> button
    * Onclick handler for <code>next</code> button
    */
    */
   submit: function () {
   submit: function () {
+
+    if (App.testMode) {
+      App.router.send('next');
+      return;
+    }
+
     this.createCluster();
     this.createCluster();
     this.createSelectedServices();
     this.createSelectedServices();
     this.createConfigurations();
     this.createConfigurations();
@@ -428,6 +434,7 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.createComponents();
     this.createComponents();
     this.registerHostsToCluster();
     this.registerHostsToCluster();
     this.createHostComponents();
     this.createHostComponents();
+
     App.router.send('next');
     App.router.send('next');
   },
   },
 
 

+ 33 - 6
ambari-web/app/controllers/wizard/step9_controller.js

@@ -55,7 +55,7 @@ App.WizardStep9Controller = Em.Controller.extend({
       } else if (App.db.getClusterStatus().isStartError === true) {
       } else if (App.db.getClusterStatus().isStartError === true) {
         this.launchStartServices();
         this.launchStartServices();
       } else {
       } else {
-        this.startPolling(); //TODO: uncomment for the actual hookup
+        this.startPolling();
       }
       }
     } else {
     } else {
       this.set('isStepCompleted', true);
       this.set('isStepCompleted', true);
@@ -203,8 +203,17 @@ App.WizardStep9Controller = Em.Controller.extend({
     var clusterName = this.get('content.cluster.name');
     var clusterName = this.get('content.cluster.name');
     var url = '/api/clusters/' + clusterName + '/services?state=INSTALLED';
     var url = '/api/clusters/' + clusterName + '/services?state=INSTALLED';
     var data = '{"ServiceInfo": {"state": "STARTED"}}';
     var data = '{"ServiceInfo": {"state": "STARTED"}}';
+    var method = 'PUT';
+
+    if (App.testMode) {
+      debugger;
+      url = '/data/wizard/deploy/poll_6.json';
+      method = 'GET';
+      this.numPolls = 6;
+    }
+
     $.ajax({
     $.ajax({
-      type: 'PUT',
+      type: method,
       url: url,
       url: url,
       async: false,
       async: false,
       data: data,
       data: data,
@@ -224,7 +233,7 @@ App.WizardStep9Controller = Em.Controller.extend({
           isCompleted: false
           isCompleted: false
         };
         };
         App.router.get('installerController').saveClusterStatus(clusterStatus);
         App.router.get('installerController').saveClusterStatus(clusterStatus);
-        this.startPolling();
+        self.startPolling();
       },
       },
 
 
       error: function () {
       error: function () {
@@ -342,8 +351,7 @@ App.WizardStep9Controller = Em.Controller.extend({
     }, this);
     }, this);
   },
   },
 
 
-// polling from ui stops only when no action has 'pending', 'queued' or 'inprogress' status
-
+  // polling from ui stops only when no action has 'PENDING', 'QUEUED' or 'IN_PROGRESS' status
   finishState: function (polledData) {
   finishState: function (polledData) {
     var clusterStatus = {};
     var clusterStatus = {};
     var retVal = false;
     var retVal = false;
@@ -459,6 +467,8 @@ App.WizardStep9Controller = Em.Controller.extend({
     this.doPolling();
     this.doPolling();
   },
   },
 
 
+  numPolls: 0,
+
   getUrl: function () {
   getUrl: function () {
     var clusterName = this.get('content.cluster.name');
     var clusterName = this.get('content.cluster.name');
     var requestId = App.db.getClusterStatus().requestId;
     var requestId = App.db.getClusterStatus().requestId;
@@ -467,9 +477,24 @@ App.WizardStep9Controller = Em.Controller.extend({
     return url;
     return url;
   },
   },
 
 
+  POLL_INTERVAL: 4000,
+
   doPolling: function () {
   doPolling: function () {
     var self = this;
     var self = this;
     var url = this.getUrl();
     var url = this.getUrl();
+
+    if (App.testMode) {
+      this.POLL_INTERVAL = 1;
+      this.numPolls++;
+      if (this.numPolls == 5) {
+        // url = 'data/wizard/deploy/poll_5.json';
+        url = 'data/wizard/deploy/poll_5_failed.json';
+      } else {
+        url = 'data/wizard/deploy/poll_' + this.numPolls + '.json';
+      }
+      debugger;
+    }
+
     $.ajax({
     $.ajax({
       type: 'GET',
       type: 'GET',
       url: url,
       url: url,
@@ -483,7 +508,7 @@ App.WizardStep9Controller = Em.Controller.extend({
         if (result !== true) {
         if (result !== true) {
           window.setTimeout(function () {
           window.setTimeout(function () {
             self.doPolling();
             self.doPolling();
-          }, 4000);
+          }, self.POLL_INTERVAL);
         } else {
         } else {
           self.stopPolling();
           self.stopPolling();
         }
         }
@@ -527,6 +552,7 @@ App.WizardStep9Controller = Em.Controller.extend({
     this.renderHosts(hostInfo);
     this.renderHosts(hostInfo);
 
 
   },
   },
+
   pollBtn: function () {
   pollBtn: function () {
     this.set('isSubmitDisabled', false);
     this.set('isSubmitDisabled', false);
     var data1 = require('data/mock/step9PolledData/pollData_1');
     var data1 = require('data/mock/step9PolledData/pollData_1');
@@ -574,4 +600,5 @@ App.WizardStep9Controller = Em.Controller.extend({
         break;
         break;
     }
     }
   }
   }
+
 });
 });

+ 3 - 0
ambari-web/app/initialize.js

@@ -19,6 +19,9 @@
 
 
 window.App = require('app');
 window.App = require('app');
 
 
+//App.testMode = true;
+App.testMode = false;
+
 require('messages');
 require('messages');
 require('utils/data_table');
 require('utils/data_table');
 require('utils/db');
 require('utils/db');

+ 1 - 0
ambari-web/app/routes/installer.js

@@ -21,6 +21,7 @@ var App = require('app');
 module.exports = Em.Route.extend({
 module.exports = Em.Route.extend({
   route: '/installer',
   route: '/installer',
   App: require('app'),
   App: require('app'),
+
   enter: function (router) {
   enter: function (router) {
     console.log('in /installer:enter');
     console.log('in /installer:enter');
 
 

+ 1 - 3
ambari-web/app/routes/main.js

@@ -23,11 +23,9 @@ module.exports = Em.Route.extend({
     if (router.getAuthenticated()) {
     if (router.getAuthenticated()) {
       router.get('mainController').startLoadOperationsPeriodically();
       router.get('mainController').startLoadOperationsPeriodically();
       // TODO: redirect to last known state
       // TODO: redirect to last known state
-      /*
        Ember.run.next(function () {
        Ember.run.next(function () {
-       router.transitionTo('step' + router.getInstallerCurrentStep());
+         router.transitionTo('dashboard');
        });
        });
-       */
     } else {
     } else {
       Ember.run.next(function () {
       Ember.run.next(function () {
         router.transitionTo('login');
         router.transitionTo('login');