From af9da262a5e4dd675badee20f5d32c1f22d6bdd1 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 19 Jun 2014 11:44:33 +0200 Subject: [PATCH 1/3] Do not assume "postgres" user exists Revert "CDB-3079 enforces postgres user in preparation script" Revert "CDB-3079 enforces postgres user in preparation script" [TRAVIS] set "postgres" user for running tests (using PGUSER) Closes #152 --- .travis.yml | 3 +++ NEWS.md | 5 +++++ README.md | 4 ++++ test/prepare_db.sh | 10 +++++----- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d6f2893..a5593a0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,9 @@ before_script: - psql -c 'CREATE EXTENSION postgis;' -U postgres -d template_postgis - ./configure +env: + - PGUSER=postgres + language: node_js node_js: - "0.8" diff --git a/NEWS.md b/NEWS.md index 8406df94..1cb55fdb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,13 @@ 1.10.2 - 2014-mm-dd ------------------- +Bug fixes: + + * Fixes "make check" on systems with non-default PostgreSQL superuser (#152) + 1.10.1 - 2014-06-05 ------------------- + Bug fixes: * Backing out Stream JSON responses diff --git a/README.md b/README.md index 394ad242..daf28c9e 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,7 @@ tests Run ```make check``` or see test/README.md +Note that the environment should be set to ensure the default +PostgreSQL user is superuser (PGUSER=postgres make check). + + diff --git a/test/prepare_db.sh b/test/prepare_db.sh index 3c130510..324bdc46 100755 --- a/test/prepare_db.sh +++ b/test/prepare_db.sh @@ -65,18 +65,18 @@ export PGHOST PGPORT if test x"$PREPARE_PGSQL" = xyes; then echo "preparing postgres..." - dropdb -U postgres ${TEST_DB} # 2> /dev/null # error expected if doesn't exist, but not otherwise - createdb -U postgres -Ttemplate_postgis -EUTF8 ${TEST_DB} || die "Could not create test database" + dropdb ${TEST_DB} # 2> /dev/null # error expected if doesn't exist, but not otherwise + createdb -Ttemplate_postgis -EUTF8 ${TEST_DB} || die "Could not create test database" cat test.sql | sed "s/:PUBLICUSER/${PUBLICUSER}/" | sed "s/:PUBLICPASS/${PUBLICPASS}/" | sed "s/:TESTUSER/${TESTUSER}/" | sed "s/:TESTPASS/${TESTPASS}/" | - psql -U postgres -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1 + psql -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1 # TODO: send in a single run, togheter with test.sql - psql -U postgres -f support/CDB_QueryStatements.sql ${TEST_DB} - psql -U postgres -f support/CDB_QueryTables.sql ${TEST_DB} + psql -f support/CDB_QueryStatements.sql ${TEST_DB} + psql -f support/CDB_QueryTables.sql ${TEST_DB} fi From ddc4f64ef65bfe94b4a15c419dcbcc0e29e22439 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 22 Sep 2014 15:04:45 +0200 Subject: [PATCH 2/3] Adds postgresql python support: plpythonu --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a5593a0c..fef0a007 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ before_script: - sudo apt-get update - sudo apt-get install -q postgresql-9.3-postgis-2.1 - sudo apt-get install -q postgresql-contrib-9.3 + - sudo apt-get install -q postgresql-plpython-9.3 - sudo apt-get install -q postgis - sudo apt-get install -q gdal-bin - echo -e "local\tall\tall\ttrust\nhost\tall\tall\t127.0.0.1/32\ttrust\nhost\tall\tall\t::1/128\ttrust" |sudo tee /etc/postgresql/9.3/main/pg_hba.conf From d1a444a83caf3ab063f90cca0f94c783e8b7b3d0 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 22 Sep 2014 15:05:38 +0200 Subject: [PATCH 3/3] Check style fixes --- test/acceptance/export/kml.js | 38 ++++++++++++----------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/test/acceptance/export/kml.js b/test/acceptance/export/kml.js index 6abcdf4a..d8c19a2a 100644 --- a/test/acceptance/export/kml.js +++ b/test/acceptance/export/kml.js @@ -10,7 +10,7 @@ var app = require(global.settings.app_root + '/app/controllers/app')() , fs = require('fs') , libxmljs = require('libxmljs') , http = require('http') - , server_utils = require('../../support/server_utils'); + , server_utils = require('../../support/server_utils') ; // allow lots of emitters to be set to silence warning @@ -18,18 +18,6 @@ app.setMaxListeners(0); suite('export.kml', function() { -var expected_cache_control = 'no-cache,max-age=3600,must-revalidate,public'; -var expected_cache_control_persist = 'public,max-age=31536000'; - -// use dec_sep for internationalization -var checkDecimals = function(x, dec_sep){ - var tmp='' + x; - if (tmp.indexOf(dec_sep)>-1) - return tmp.length-tmp.indexOf(dec_sep)-1; - else - return 0; -} - // Check if an attribute is in the KML output // // NOTE: "name" and "description" attributes are threated specially @@ -60,7 +48,7 @@ var hasAttribute = function(kml, att) { //if ( lowerkml.indexOf('simplefield name="'+ loweratt + '"') != -1 ) return true; //if ( lowerkml.indexOf('<'+loweratt+'>') != -1 ) return true; return false; -} +}; // Return the first coordinate array found in KML var extractCoordinates = function(kml) { @@ -85,7 +73,7 @@ var extractCoordinates = function(kml) { } return coo; -} +}; // Return the first folder name in KML var extractFolderName = function(kml) { @@ -104,7 +92,7 @@ var extractFolderName = function(kml) { //console.log("coo: " + coo); if ( ! coo ) return; return coo; -} +}; // KML tests @@ -120,13 +108,13 @@ test('KML format, unauthenticated', function(done){ assert.equal(true, /filename=cartodb-query.kml/gi.test(cd), 'Unexpected KML filename: ' + cd); var row0 = res.body; var checkfields = {'Name':1, 'address':1, 'cartodb_id':1, 'the_geom':0, 'the_geom_webmercator':0}; - for ( var f in checkfields ) { + Object.keys(checkfields).forEach(function(f) { if ( checkfields[f] ) { assert.ok(hasAttribute(row0, f), "result does not include '" + f + "': " + row0); } else { assert.ok(!hasAttribute(row0, f), "result includes '" + f + "'"); } - } + }); done(); }); }); @@ -176,14 +164,14 @@ test('KML format, skipfields', function(done){ assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); assert.equal(true, /filename=cartodb-query.kml/gi.test(cd), 'Unexpected KML filename: ' + cd); var row0 = res.body; - var checkfields = {'Name':1, 'address':0, 'cartodb_id':0, 'the_geom':0, 'the_geom_webmercator':0}; - for ( var f in checkfields ) { - if ( checkfields[f] ) { + var checkFields = {'Name':1, 'address':0, 'cartodb_id':0, 'the_geom':0, 'the_geom_webmercator':0}; + Object.keys(checkFields).forEach(function(f) { + if ( checkFields[f] ) { assert.ok(hasAttribute(row0, f), "result does not include '" + f + "': " + row0); } else { assert.ok(!hasAttribute(row0, f), "result includes '" + f + "'"); } - } + }); done(); }); }); @@ -231,7 +219,7 @@ test('KML format, unauthenticated, concurrent requests', function(done){ //console.log("Listening on port " + port); for (var i=0; icartodb_query$'); + var pat = new RegExp('^<\\?xml version="1.0" encoding="utf-8" \\?>cartodb_query$'); var body = res.body.replace(/\n/g,''); assert.ok(body.match(pat), "Response:\n" + body + '\ndoes not match pattern:\n' + pat); @@ -292,7 +280,7 @@ test('GET /api/v1/sql as kml with ending semicolon', function(done){ },{ }, function(res){ assert.equal(res.statusCode, 200, res.body); // NOTE: GDAL-1.11+ added 'id="root_doc"' attribute to the output - var pat = RegExp('^<\\?xml version="1.0" encoding="utf-8" \\?>cartodb_query$'); + var pat = new RegExp('^<\\?xml version="1.0" encoding="utf-8" \\?>cartodb_query$'); var body = res.body.replace(/\n/g,''); assert.ok(body.match(pat), "Response:\n" + body + '\ndoes not match pattern:\n' + pat);