Merge lp:~adiroiban/couchdb-glib/couchdb-test-setup into lp:couchdb-glib

Proposed by Adi Roiban
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 180
Merge reported by: Rodrigo Moya
Merged at revision: not available
Proposed branch: lp:~adiroiban/couchdb-glib/couchdb-test-setup
Merge into: lp:couchdb-glib
Diff against target: 95 lines (+64/-2)
3 files modified
tests/Makefile.am (+31/-2)
tests/config/couchdb-auth.ini (+29/-0)
tests/test-couchdb-glib.c (+4/-0)
To merge this branch: bzr merge lp:~adiroiban/couchdb-glib/couchdb-test-setup
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Review via email: mp+22886@code.launchpad.net

Commit message

Add setUp and tearDown of CouchDB server for couchdb-glib tests.

Description of the change

= Bug 556671 =

When running the couchdb-glib tests, the testsuite should setUp and tearDown the an empty
couchdb server

== Proposed fix ==

Before running the couchdb-glib test, the Makefile should first setup and empty CouchDB used just for testing and when the test are done to tear down the server.

== Implementation details ==

The new server is using the configuration from tests/config/couchdb-auth.ini with data stored in tests/var.

It is using a predefined username/password and hostname/port_nr.

I have also fixed the name used for creating a new database since UUID can start with a number, while couchdb db names not.

Maybe we should change the port_nr used for testing to not be the default port.

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

hmm, doesn't seem to work for me:

$ cd tests
$ make test
Setting up the couchdb server...
Apache CouchDB needs write permission on the STDOUT file: ../tests/var/couchdb.stdout
make: *** [test] Error 1

Also, I think we should do the cleanup after running the tests, that is, what there is in stop-couchdb rule should go after running test-desktopcouch-glib

Anyway, this is a very needed branch, so thanks!

review: Needs Fixing
Revision history for this message
Adi Roiban (adiroiban) wrote :

Hi,

Sorry for pushing this bad branch.
In my initial test it looks like couchdb can create the var folder if it not there. This is true, but it does not create the parent.

This is fixed.

Maybe we can move the functionality of starting and stoping a testing couchdb server in a different script.
What do you say?

I was thinking of adding extra configuration for also testing basic http and oauth authentication.

I'm stoppping the couchdb server before desktopcouch-glib, since desktopcouch will use the user server anyway.
For starting a testing desktopcouch server, we need to shut down the current one and change the dbus config to start our server.

180. By Adi Roiban

Delete pid file. Create an empty var folder before starting the couchdb server.

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Works great now! But I think that, given that we are starting a new couchdb instance, shouldn't we use a different port than 5984, which is the one used by the system wide couchdb instance?

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Ok, approving it

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2010-01-08 15:47:33 +0000
+++ tests/Makefile.am 2010-04-09 12:13:26 +0000
@@ -1,3 +1,7 @@
1NULL =
2SUBDIRS = \
3 $(NULL)
4
1INCLUDES = \5INCLUDES = \
2 $(COUCHDB_GLIB_CFLAGS) \6 $(COUCHDB_GLIB_CFLAGS) \
3 $(DESKTOPCOUCH_GLIB_CFLAGS) \7 $(DESKTOPCOUCH_GLIB_CFLAGS) \
@@ -44,6 +48,31 @@
4448
45check_PROGRAMS = test-couchdb-glib49check_PROGRAMS = test-couchdb-glib
4650
51
52COUCHDB_VAR = $(top_srcdir)/tests/var
53COUCHDB_PID = $(top_srcdir)/tests/config/couchdb.pid
54COUCHDB_STDOUT = $(top_srcdir)/tests/var/couchdb.stdout
55COUCHDB_STDERR = $(top_srcdir)/tests/var/couchdb.stderr
56COUCHDB_CONFIG_NOAUTH = $(top_srcdir)/tests/config/couchdb-noauth.ini
57COUCHDB_CONFIG_AUTH = $(top_srcdir)/tests/config/couchdb-auth.ini
58
59
60stop-couchdb:
61 @/usr/bin/couchdb -p $(COUCHDB_PID) -d
62 @/bin/rm -f $(COUCHDB_PID)
63
47test: $(check_PROGRAMS)64test: $(check_PROGRAMS)
48 $(top_srcdir)/tests/test-couchdb-glib65 @echo "Setting up the couchdb server..."
49 $(top_srcdir)/tests/test-desktopcouch-glib66 @/bin/rm -rf $(COUCHDB_VAR)
67 @/bin/mkdir -p $(COUCHDB_VAR)
68 @/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
69 @/usr/bin/couchdb -n -a /etc/couchdb/default.ini \
70 -o $(COUCHDB_STDOUT) -e $(COUCHDB_STDERR) \
71 -a $(COUCHDB_CONFIG_AUTH) -p $(COUCHDB_PID) -b > /dev/null
72 @/bin/sleep 1
73 @$(top_srcdir)/tests/test-couchdb-glib "http://test:test@127.0.0.1:5984"
74 @echo "Tearing down up the couchdb server..."
75 @/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
76 @/bin/rm -f $(COUCHDB_PID)
77 @/bin/rm -rf $(COUCHDB_VAR)
78 @$(top_srcdir)/tests/test-desktopcouch-glib
5079
=== added directory 'tests/config'
=== added file 'tests/config/couchdb-auth.ini'
--- tests/config/couchdb-auth.ini 1970-01-01 00:00:00 +0000
+++ tests/config/couchdb-auth.ini 2010-04-09 12:13:26 +0000
@@ -0,0 +1,29 @@
1[couch_httpd_auth]
2require_valid_user = true
3
4[oauth_consumer_secrets]
5tLsCckqFPV = ntRaiJiuBX
6
7[oauth_token_users]
8tqSUhjJRMs = tpxQsaDSWd
9
10[oauth_token_secrets]
11tqSUhjJRMs = sHdBksSvmL
12
13[httpd]
14bind_address = 127.0.0.1
15port = 5984
16
17[couchdb]
18view_index_dir = var/couchdb_auth
19database_dir = var/couchdb_auth
20
21[log]
22file = var/couchdb-auth.log
23level = info
24
25; username = test
26; password = test
27[admins]
28test = -hashed-d175a4432182ff1abd6841c58fa25d3b51a59ec1,e57c36d165189a813392886b34e6f7d2
29
030
=== modified file 'tests/test-couchdb-glib.c'
--- tests/test-couchdb-glib.c 2010-01-11 16:57:19 +0000
+++ tests/test-couchdb-glib.c 2010-04-09 12:13:26 +0000
@@ -115,6 +115,10 @@
115 dbname = generate_uuid ();115 dbname = generate_uuid ();
116 g_assert (dbname != NULL);116 g_assert (dbname != NULL);
117117
118 /* Database name can not start with a digit
119 * we will overwrite the first character with 'a' */
120 dbname[0] = 'a';
121
118 /* Create database */122 /* Create database */
119 couchdb_session_create_database (couchdb, dbname, &error);123 couchdb_session_create_database (couchdb, dbname, &error);
120 if (error) {124 if (error) {

Subscribers

People subscribed via source and target branches

to all changes: