You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/15 14:17:36 UTC
git commit: updated refs/heads/1813-verify-install to 9380c03
Updated Branches:
refs/heads/1813-verify-install 5513e8c8e -> 9380c0363 (forced update)
working first version
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9380c036
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9380c036
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9380c036
Branch: refs/heads/1813-verify-install
Commit: 9380c0363a699b44144b7a4b01b9b33128f07c50
Parents: 1944276
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Oct 15 12:23:00 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Oct 15 14:16:59 2013 +0200
----------------------------------------------------------------------
.gitignore | 1 +
.../assets/less/verifyinstall.less | 4 +
src/fauxton/app/addons/verifyinstall/base.js | 31 +++
.../app/addons/verifyinstall/resources.js | 21 ++
src/fauxton/app/addons/verifyinstall/routes.js | 36 ++++
.../addons/verifyinstall/templates/main.html | 50 +++++
src/fauxton/app/addons/verifyinstall/views.js | 204 +++++++++++++++++++
src/fauxton/app/modules/documents/resources.js | 1 -
src/fauxton/settings.json.default | 3 +-
9 files changed, 349 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9380c036/.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/9380c036/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/9380c036/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/9380c036/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..b0b591c
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/resources.js
@@ -0,0 +1,21 @@
+// 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"
+],
+
+function (app, FauxtonAPI) {
+ var verifyinstall = FauxtonAPI.addon();
+ return verifyinstall;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9380c036/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..8a104db
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/routes.js
@@ -0,0 +1,36 @@
+// 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"
+ },
+
+ 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/9380c036/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..5e897cc
--- /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"> </td>
+ </tr>
+ <tr>
+ <td> Create Document </td>
+ <td id="create-document"> </td>
+ </tr>
+ <tr>
+ <td> Update Document </td>
+ <td id="update-document"> </td>
+ </tr>
+ <tr>
+ <td> Delete Document </td>
+ <td id="delete-document"> </td>
+ </tr>
+ <tr>
+ <td> Create View </td>
+ <td id="create-view"> </td>
+ </tr>
+ <tr>
+ <td> Replication </td>
+ <td id="replicate"> </td>
+ </tr>
+ </tbody>
+</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9380c036/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..297c2cf
--- /dev/null
+++ b/src/fauxton/app/addons/verifyinstall/views.js
@@ -0,0 +1,204 @@
+// 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",
+ "modules/databases/resources",
+ "modules/documents/resources"
+],
+function(app, FauxtonAPI, VerifyInstall, Databases, Documents) {
+
+ // x - ✗
+ // correct - ✓
+
+ 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('✓');
+ },
+
+ setError: function (id, msg) {
+ this.$('#' + id).html('✗');
+ 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();
+
+ var doc, viewDoc, dbReplicate,
+ setPass = this.setPass,
+ complete = this.complete,
+ setError = this.setError,
+ formatError = this.formatError;
+
+ var db = new Databases.Model({
+ id: 'garren_testdb',
+ name: 'garren_testdb'
+ });
+
+ db.destroy()
+ .then(function () {
+ return db.save();
+ }, formatError('create-database'))
+ .then(function () {
+ setPass('create-database');
+ doc = new Documents.Doc({_id: 'test_doc_1', a: 1}, {
+ database: db
+ });
+ return doc.save();
+ }, formatError('create-document'))
+ .then(function () {
+ setPass('create-document');
+ doc.set({b: "hello"});
+ return doc.save();
+ }, formatError('update-document'))
+ .then(function () {
+ setPass('update-document');
+ return doc.destroy();
+ }, formatError('delete-document'))
+ .then(function () {
+ setPass('delete-document');
+ })
+ .then(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()]);
+
+ }, formatError('create-view'))
+ .then(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;
+ }, formatError('create-view'))
+ .then(function () {
+ setPass('create-view');
+
+ return $.ajax({
+ url: '/_replicate',
+ contentType: 'application/json',
+ type: 'POST',
+ dataType: 'json',
+ processData: false,
+ data: JSON.stringify({
+ create_target: true,
+ source: 'garren_testdb',
+ target: 'test_replicate'
+ }),
+
+ });
+ }, formatError('create-view'))
+ .then(function () {
+ dbReplicate = new Databases.Model({
+ id: 'test_replicate',
+ name: 'test_replicate'
+ });
+
+ return dbReplicate.fetch();
+ }, formatError('replicate'))
+ .then(function () {
+ var docCount = dbReplicate.get('doc_count');
+ if ( docCount === 4) {
+ setPass('replicate');
+ complete();
+ return;
+ }
+ setError('replicate', 'Replication Failed, expected 4 docs got ' + docCount);
+ }, formatError('replicate'));
+
+ this.enableButton();
+ //*** SET HEADERS
+ }
+ });
+
+
+ return VerifyInstall;
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9380c036/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 901ba83..dca9b20 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/9380c036/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": {