couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [1/3] git commit: updated refs/heads/master to 9710834
Date Wed, 16 Oct 2013 08:25:13 GMT
Updated Branches:
  refs/heads/master 1cf46213e -> 971083419


Fauxton: Add Verify Install module
Resolves #COUCHDB-1813


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/97108341
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/97108341
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/97108341

Branch: refs/heads/master
Commit: 9710834196c59f02ee5fb4df27df4a587cf6c1f1
Parents: bcb4fba
Author: Garren Smith <garren.smith@gmail.com>
Authored: Tue Oct 15 12:23:00 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Wed Oct 16 10:24:52 2013 +0200

----------------------------------------------------------------------
 .gitignore                                      |   1 +
 .../assets/less/verifyinstall.less              |   4 +
 src/fauxton/app/addons/verifyinstall/base.js    |  31 ++++
 .../app/addons/verifyinstall/resources.js       | 174 +++++++++++++++++++
 src/fauxton/app/addons/verifyinstall/routes.js  |  37 ++++
 .../addons/verifyinstall/templates/main.html    |  50 ++++++
 src/fauxton/app/addons/verifyinstall/views.js   | 126 ++++++++++++++
 src/fauxton/app/modules/documents/resources.js  |   1 -
 src/fauxton/settings.json.default               |   3 +-
 9 files changed, 425 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index cc2398b..95cf2f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -100,6 +100,7 @@ src/fauxton/app/addons/*
 !src/fauxton/app/addons/auth
 !src/fauxton/app/addons/exampleAuth
 !src/fauxton/app/addons/permissions
+!src/fauxton/app/addons/verifyinstall
 src/fauxton/settings.json*
 !src/fauxton/settings.json.default
 src/ibrowse/ibrowse.app

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less b/src/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
new file mode 100644
index 0000000..508994b
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
@@ -0,0 +1,4 @@
+#start {
+  margin-bottom: 20px;
+}
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/base.js b/src/fauxton/app/addons/verifyinstall/base.js
new file mode 100644
index 0000000..d17c353
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/base.js
@@ -0,0 +1,31 @@
+// Licensed 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.
+
+define([
+  "app",
+  "api",
+  "addons/verifyinstall/routes"
+],
+
+function(app, FauxtonAPI, VerifyInstall) {
+  VerifyInstall.initialize = function () {
+    FauxtonAPI.addHeaderLink({
+        title: "Verify", 
+        href: "#verifyinstall",
+        icon: "fonticon-circle-check",
+        bottomNav: true,
+      });
+  };
+
+
+  return VerifyInstall;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/resources.js b/src/fauxton/app/addons/verifyinstall/resources.js
new file mode 100644
index 0000000..f42c020
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/resources.js
@@ -0,0 +1,174 @@
+// Licensed 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.
+
+define([
+  "app",
+  "api",
+  "modules/databases/resources",
+  "modules/documents/resources"
+],
+
+function (app, FauxtonAPI, Databases, Documents) {
+  var Verifyinstall = FauxtonAPI.addon();
+
+  var db = new Databases.Model({
+    id: 'verifytestdb',
+    name: 'verifytestdb'
+  });
+
+  var dbReplicate = new Databases.Model({
+    id: 'verifytestdb_replicate',
+    name: 'verifytestdb_replicate'
+  });
+
+  var doc, viewDoc;
+
+  Verifyinstall.testProcess = {
+
+    saveDoc: function () {
+      doc = new Documents.Doc({_id: 'test_doc_1', a: 1}, {
+        database: db
+      });
+
+      return doc.save();
+    },
+
+    destroyDoc: function () {
+     return doc.destroy();
+    },
+
+    updateDoc: function () {
+      doc.set({b: "hello"});
+      return doc.save(); 
+    },
+
+    saveDB: function () {
+      return db.save();
+    },
+
+    setupDB: function (db) {
+      var deferred = FauxtonAPI.Deferred();
+      db.fetch()
+      .then(function () {
+        return db.destroy();
+      }, function (xhr) {
+        deferred.resolve();
+      })
+      .then(function () {
+        deferred.resolve();
+      }, function (xhr, error, reason) {
+        if (reason === "Unauthorized") {
+          deferred.reject(xhr, error, reason);
+        }
+      });
+
+      return deferred;
+    },
+
+    setup: function () {
+      return FauxtonAPI.when([
+        this.setupDB(db), 
+        this.setupDB(dbReplicate)
+      ]);
+    },
+
+    testView: function () {
+      var deferred = FauxtonAPI.Deferred();
+      var promise = $.get(viewDoc.url() + '/_view/testview');
+
+      promise.then(function (resp) { 
+        var row = JSON.parse(resp).rows[0];
+        if (row.value === 6) {
+          return deferred.resolve();
+        }
+        var reason = {
+            reason: 'Values expect 6, got ' + row.value
+          };
+
+        deferred.reject({responseText: JSON.stringify(reason)});
+      }, deferred.reject);
+
+      return deferred;
+    },
+
+    setupView: function () {
+      var doc1 = new Documents.Doc({_id: 'test_doc10', a: 1}, {
+        database: db
+      });
+
+      var doc2 = new Documents.Doc({_id: 'test_doc_20', a: 2}, {
+        database: db
+      });
+
+      var doc3 = new Documents.Doc({_id: 'test_doc_30', a: 3}, {
+        database: db
+      });
+
+      viewDoc = new Documents.Doc({
+        _id: '_design/view_check',
+        views: {
+          'testview': { 
+            map:'function (doc) { emit(doc._id, doc.a); }',
+            reduce: '_sum'
+          }
+        } 
+      },{
+        database: db,
+      });
+
+      return FauxtonAPI.when([doc1.save(),doc2.save(), doc3.save(), viewDoc.save()]);
+    },
+
+    setupReplicate: function () {
+      return $.ajax({
+        url: '/_replicate',
+        contentType: 'application/json',
+        type: 'POST',
+        dataType: 'json',
+        processData: false,
+        data: JSON.stringify({
+          create_target: true,
+          source: 'verifytestdb',
+          target: 'verifytestdb_replicate'
+        }),
+      });
+    },
+
+    testReplicate: function () {
+      var deferred = FauxtonAPI.Deferred();
+      /*var dbReplicate = new Databases.Model({
+          id: 'verifytestdb_replicate',
+          name: 'verifytestdb_replicate'
+        });*/
+
+      var promise = dbReplicate.fetch();
+
+      promise.then(function () {
+        var docCount = dbReplicate.get('doc_count');
+        if ( docCount === 4) {
+          deferred.resolve();
+          return;
+        }
+
+        var reason = {
+          reason: 'Replication Failed, expected 4 docs got ' + docCount
+        };
+
+        deferred.reject({responseText: JSON.stringify(reason)});
+      }, deferred.reject);
+
+      return deferred;
+    }
+  };
+
+  return Verifyinstall;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/routes.js b/src/fauxton/app/addons/verifyinstall/routes.js
new file mode 100644
index 0000000..e5024ba
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/routes.js
@@ -0,0 +1,37 @@
+// Licensed 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.
+
+define([
+  "app",
+  "api",
+  "addons/verifyinstall/views"
+],
+function(app, FauxtonAPI, VerifyInstall) {
+
+  var VerifyRouteObject = FauxtonAPI.RouteObject.extend({
+    layout: 'one_pane',
+
+    routes: {
+      'verifyinstall': "verifyInstall"
+    },
+    selectedHeader: "Verify",
+
+    verifyInstall: function () {
+      this.setView('#dashboard-content', new VerifyInstall.Main({}));
+    },
+
+    crumbs: [{name: 'Verify Couchdb Installation', link: '#'}]
+  });
+
+  VerifyInstall.RouteObjects = [VerifyRouteObject];
+  return VerifyInstall;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/templates/main.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/templates/main.html b/src/fauxton/app/addons/verifyinstall/templates/main.html
new file mode 100644
index 0000000..fa41907
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/templates/main.html
@@ -0,0 +1,50 @@
+<!--
+Licensed 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.
+-->
+<button id="start" class="btn btn-large btn-success"> Verify Installation </button>
+<div id="error"> </div>
+
+<table id="test-score" class="table table-striped table-bordered" >
+  <thead>
+    <tr>
+      <th> Test </th>
+      <th> Status </th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr>
+      <td> Create Database </td>
+      <td id="create-database" class="status">  </td>
+    </tr>
+    <tr>
+      <td> Create Document </td>
+      <td id="create-document" class="status">  </td>
+    </tr>
+    <tr>
+      <td> Update Document </td>
+      <td id="update-document" class="status">  </td>
+    </tr>
+    <tr>
+      <td> Delete Document </td>
+      <td id="delete-document" class="status">  </td>
+    </tr>
+    <tr>
+      <td> Create View </td>
+      <td id="create-view" class="status">  </td>
+    </tr>
+    <tr>
+      <td> Replication </td>
+      <td id="replicate" class="status">  </td>
+    </tr>
+  </tbody>
+</table>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/addons/verifyinstall/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/verifyinstall/views.js b/src/fauxton/app/addons/verifyinstall/views.js
new file mode 100644
index 0000000..3ad3364
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/views.js
@@ -0,0 +1,126 @@
+// Licensed 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.
+
+define([
+  "app",
+  "api",
+  "addons/verifyinstall/resources",
+],
+function(app, FauxtonAPI, VerifyInstall) {
+
+  VerifyInstall.Main = FauxtonAPI.View.extend({
+    template: 'addons/verifyinstall/templates/main',
+
+    events: {
+      "click #start": "startTest"
+    },
+
+    initialize: function (options) {
+      _.bindAll(this);
+    },
+
+    setPass: function (id) {
+      this.$('#' + id).html('&#10003;');
+    },
+
+    setError: function (id, msg) {
+      this.$('#' + id).html('&#x2717;');
+      FauxtonAPI.addNotification({
+        msg: 'Error: ' + msg,
+        type: 'error',
+        selector: '#error'
+      });
+    },
+
+    complete: function () {
+      FauxtonAPI.addNotification({
+        msg: 'Success! You Couchdb install is working. Time to Relax',
+        type: 'success',
+        selector: '#error'
+      });
+    },
+
+    enableButton: function () {
+      this.$('#start').removeAttr('disabled').text('Verify Installation');
+    },
+
+    disableButton: function () {
+      this.$('#start').attr('disabled','disabled').text('Verifying');
+    },
+
+    formatError: function (id) {
+      var enableButton = this.enableButton,
+          setError = this.setError;
+
+      return function (xhr, error, reason) {
+        enableButton();
+
+        if (!xhr) { return; }
+
+        setError(id, JSON.parse(xhr.responseText).reason);
+      };
+    },
+
+    
+    startTest: function () {
+      this.disableButton();
+      this.$('.status').text('');
+
+      var testProcess = VerifyInstall.testProcess,
+          setPass = this.setPass,
+          complete = this.complete,
+          setError = this.setError,
+          formatError = this.formatError;
+
+      testProcess.setup()
+      .then(function () {
+        return testProcess.saveDB();
+      }, formatError('create-database'))
+      .then(function () {
+        setPass('create-database');
+        return testProcess.saveDoc();
+      }, formatError('create-document'))
+      .then(function () {
+        setPass('create-document');
+        return testProcess.updateDoc();
+      }, formatError('update-document'))
+      .then(function () {
+        setPass('update-document');
+        return testProcess.destroyDoc();
+      }, formatError('delete-document'))
+      .then(function () {
+        setPass('delete-document');
+        return testProcess.setupView();
+      }, formatError('create-view'))
+      .then(function () {
+        return testProcess.testView();
+      }, formatError('create-view'))
+      .then(function () {
+        setPass('create-view');
+        return testProcess.setupReplicate();
+      }, formatError('create-view'))
+      .then(function () {
+        return testProcess.testReplicate();
+      }, formatError('replicate'))
+      .then(function () {
+          setPass('replicate');
+          complete();
+      }, formatError('replicate'));
+
+      this.enableButton();
+    }
+  });
+
+
+  return VerifyInstall;
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index bad8b77..8df2e6f 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -12,7 +12,6 @@
 
 define([
   "app",
-
   "api"
 ],
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/97108341/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index 4964135..ce45e26 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -8,7 +8,8 @@
   { "name": "plugins" },
   { "name": "contribute" },
   { "name": "permissions" },
-  { "name": "auth" }
+  { "name": "auth" },
+  { "name": "verifyinstall" }
   ],
     "template": {
       "development": {


Mime
View raw message