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
1=== modified file 'tests/Makefile.am'
2--- tests/Makefile.am 2010-01-08 15:47:33 +0000
3+++ tests/Makefile.am 2010-04-09 12:13:26 +0000
4@@ -1,3 +1,7 @@
5+NULL =
6+SUBDIRS = \
7+ $(NULL)
8+
9 INCLUDES = \
10 $(COUCHDB_GLIB_CFLAGS) \
11 $(DESKTOPCOUCH_GLIB_CFLAGS) \
12@@ -44,6 +48,31 @@
13
14 check_PROGRAMS = test-couchdb-glib
15
16+
17+COUCHDB_VAR = $(top_srcdir)/tests/var
18+COUCHDB_PID = $(top_srcdir)/tests/config/couchdb.pid
19+COUCHDB_STDOUT = $(top_srcdir)/tests/var/couchdb.stdout
20+COUCHDB_STDERR = $(top_srcdir)/tests/var/couchdb.stderr
21+COUCHDB_CONFIG_NOAUTH = $(top_srcdir)/tests/config/couchdb-noauth.ini
22+COUCHDB_CONFIG_AUTH = $(top_srcdir)/tests/config/couchdb-auth.ini
23+
24+
25+stop-couchdb:
26+ @/usr/bin/couchdb -p $(COUCHDB_PID) -d
27+ @/bin/rm -f $(COUCHDB_PID)
28+
29 test: $(check_PROGRAMS)
30- $(top_srcdir)/tests/test-couchdb-glib
31- $(top_srcdir)/tests/test-desktopcouch-glib
32+ @echo "Setting up the couchdb server..."
33+ @/bin/rm -rf $(COUCHDB_VAR)
34+ @/bin/mkdir -p $(COUCHDB_VAR)
35+ @/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
36+ @/usr/bin/couchdb -n -a /etc/couchdb/default.ini \
37+ -o $(COUCHDB_STDOUT) -e $(COUCHDB_STDERR) \
38+ -a $(COUCHDB_CONFIG_AUTH) -p $(COUCHDB_PID) -b > /dev/null
39+ @/bin/sleep 1
40+ @$(top_srcdir)/tests/test-couchdb-glib "http://test:test@127.0.0.1:5984"
41+ @echo "Tearing down up the couchdb server..."
42+ @/usr/bin/couchdb -p $(COUCHDB_PID) -d > /dev/null
43+ @/bin/rm -f $(COUCHDB_PID)
44+ @/bin/rm -rf $(COUCHDB_VAR)
45+ @$(top_srcdir)/tests/test-desktopcouch-glib
46
47=== added directory 'tests/config'
48=== added file 'tests/config/couchdb-auth.ini'
49--- tests/config/couchdb-auth.ini 1970-01-01 00:00:00 +0000
50+++ tests/config/couchdb-auth.ini 2010-04-09 12:13:26 +0000
51@@ -0,0 +1,29 @@
52+[couch_httpd_auth]
53+require_valid_user = true
54+
55+[oauth_consumer_secrets]
56+tLsCckqFPV = ntRaiJiuBX
57+
58+[oauth_token_users]
59+tqSUhjJRMs = tpxQsaDSWd
60+
61+[oauth_token_secrets]
62+tqSUhjJRMs = sHdBksSvmL
63+
64+[httpd]
65+bind_address = 127.0.0.1
66+port = 5984
67+
68+[couchdb]
69+view_index_dir = var/couchdb_auth
70+database_dir = var/couchdb_auth
71+
72+[log]
73+file = var/couchdb-auth.log
74+level = info
75+
76+; username = test
77+; password = test
78+[admins]
79+test = -hashed-d175a4432182ff1abd6841c58fa25d3b51a59ec1,e57c36d165189a813392886b34e6f7d2
80+
81
82=== modified file 'tests/test-couchdb-glib.c'
83--- tests/test-couchdb-glib.c 2010-01-11 16:57:19 +0000
84+++ tests/test-couchdb-glib.c 2010-04-09 12:13:26 +0000
85@@ -115,6 +115,10 @@
86 dbname = generate_uuid ();
87 g_assert (dbname != NULL);
88
89+ /* Database name can not start with a digit
90+ * we will overwrite the first character with 'a' */
91+ dbname[0] = 'a';
92+
93 /* Create database */
94 couchdb_session_create_database (couchdb, dbname, &error);
95 if (error) {

Subscribers

People subscribed via source and target branches

to all changes: