3meters / proxibase

Patchr web service
1 stars 0 forks source link

Intermittent failure in /test/basic/41 setting hard radius #247

Closed georgesnelling closed 10 years ago

georgesnelling commented 10 years ago

This one comes and goes.....

I don't think this is a bug in our code, more the test being too picky. Usually for tests that are twitchy for provider returned data I will add in some reasonable slack for the test.

41_places_near ✔ getSessions ✔ getCategories ✔ getPlacesNearLocationUsingLimit Roxy photo comes and goes photo properties not being nulled ✔ getPlacesNearLocationUsingLimitAgain Error:

Test failed:

Dump:

req.method: post req.uri: https://localhost:6644/v1/places/near req.body: { provider: 'foursquare|google|yelp', location: { lat: 47.5097, lng: -122.463998 }, radius: 1609, includeRaw: false, limit: 50, log: true, timeout: 10000 }

res.statusCode: 200 res.body: { data: [ { _id: 'pl.140703.83996.447.064266', name: 'Metro Bus Stop #46769', namelc: 'metro bus stop #46769', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', modifier: 'us.000000.00000.000.000000', createdDate: 1404454796447, createdIp: '127.0.0.1', modifiedDate: 1404454796447, modifiedIp: '127.0.0.1', enabled: true, visibility: 'public', location: { lat: 47.510236501693726, lng: -122.46405780315399, geometry: [ -122.46405780315399, 47.510236501693726 ], accuracy: 25 }, phone: '2065533000', address: 'Vashon Ferry Dock', postalCode: '98070', city: 'Vashon Island', region: 'WA', country: 'US', provider: { foursquare: '4baaa777f964a520267d3ae3' }, category: { id: '4bf58dd8d48988d1fe931735', name: 'Bus Station', photo: { prefix: '4bf58dd8d48988d1fe931735', suffix: '.png', source: 'assets.categories' } }, creator: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } }, { _id: 'pl.140703.83996.450.344007', name: 'La Playa Mexican Restaurant', namelc: 'la playa mexican restaurant', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', _modifier: 'us.000000.00000.000.000000', createdDate: 1404454796450, createdIp: '127.0.0.1', modifiedDate: 1404454798470, modifiedIp: '127.0.0.1', enabled: true, photo: { source: 'yelp', prefix: 'http://s3-media3.fl.yelpcdn.com/bphoto/UR_372fIKPNZ_EP3vZFiUg/l.jpg', createdDate: 1404454798470 }, visibility: 'public', location: { lat: 47.508574, lng: -122.463885, accuracy: 25, geometry: [ -122.463885, 47.508574 ] }, phone: '2065670020', address: '10824 Vashon Hwy SW', postalCode: '98070', city: 'Vashon', region: 'WA', country: 'US', provider: { foursquare: '4ace9457f964a5204bd120e3', google: '0ff514498e53249ed817b88835248f620fd27112|CoQBfgAAACAaCLi0QTAsH6QprwK0idy6xCywtFZym8FzAL6glXImBtZEU3QkMhwbC1l2DZc4Gdwb1I4NTA4Jf23oi2aBgB-WLMv5Wlrda4tmYDtjmrjJ6rXWSiw0KFnM702eF3PrgV0MMSSClF9TuyGQEEYYKDBH5b4iC_agLRzlJw5kvKb5EhCix4Dhg6UIanVGPUAwwE8kGhSpckHSbbD9J28u8hWswUwPPP2t3A', google1: '0ff514498e53249ed817b88835248f620fd27112', google2: 'CoQBfgAAACAaCLi0QTAsH6QprwK0idy6xCywtFZym8FzAL6glXImBtZEU3QkMhwbC1l2DZc4Gdwb1I4NTA4Jf23oi2aBgB-WLMv5Wlrda4tmYDtjmrjJ6rXWSiw0KFnM702eF3PrgV0MMSSClF9TuyGQEEYYKDBH5b4iCagLRzlJw5kvKb5EhCix4Dhg6UIanVGPUAwwE8kGhSpckHSbbD9J28u8hWswUwPPP2t3A', yelp: 'laplaya-mexican-restaurant-vashon' }, category: { id: '4bf58dd8d48988d1c1941735', name: 'Mexican Restaurant', photo: { prefix: '4bf58dd8d48988d1c1941735', suffix: '.png', source: 'assets.categories' } }, creator: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } }, { _id: 'pl.140703.83996.457.015221', name: 'Port Vashon', namelc: 'port vashon', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', modifier: 'us.000000.00000.000.000000', createdDate: 1404454796457, createdIp: '127.0.0.1', modifiedDate: 1404454796457, modifiedIp: '127.0.0.1', enabled: true, visibility: 'public', location: { lat: 47.50843240022808, lng: -122.46382713317871, geometry: [ -122.46382713317871, 47.50843240022808 ], accuracy: 25 }, phone: '2066504182', address: '10824 Vashon Hwy SW', postalCode: '98070', city: 'Vashon', region: 'WA', country: 'US', provider: { foursquare: '4e53e47381302f16caf9c6f3' }, category: { id: 'generic', name: 'Place', photo: { prefix: 'generic', suffix: '.png', source: 'assets.categories' } }, creator: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } } ], date: 1404454798484, count: 3, more: false, clientMinVersions: { 'com.aircandi.aruba': 96, 'com.aircandi.catalina': 100 },

time: 3.277 }

at Object.tok (/usr/local/prox/test/util.js:77:22)
at /usr/local/prox/test/basic/41_places_near.js:281:7
at Request._callback (/usr/local/prox/test/util.js:71:7)
at Request.self.callback (/usr/local/prox/node_modules/request/request.js:121:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/usr/local/prox/node_modules/request/request.js:985:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/usr/local/prox/node_modules/request/request.js:936:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:929:16

Tests finished in 50.075 seconds

Test server closed

FAILURES: Undone tests (or their setups/teardowns):

Here's line 281 in the failing test:

t.assert(places.length === 4)

Here's the test:

exports.getPlacesNearLocationUsingRadius = function(test) { // Should take less than 5 seconds but using 10 second timeout anyway. if (disconnected) return skip(test) t.post({ uri: '/places/near', body: { provider: 'foursquare|google|yelp', location: vashonLoc, radius: 1609, // one mile includeRaw: false, limit: 50, log: true, timeout: 10000, } }, function(err, res, body) { var foundVashonFerryTerminal = 0 var foundLaPlaya = 0 t.assert(body.time < 10) // Should take less than 10 seconds var places = body.data t.assert(places.length === 4) placeCount = { aircandi: 0, foursquare: 0, google: 0, yelp: 0 } places.forEach(function(place) { var adminId = util.adminId t.assert(place.location) t.assert(place.provider) t.assert(adminId = place._owner) t.assert(adminId = place._creator) t.assert(adminId = place._modifier) for (var p in place.provider) { placeCount[p]++ } if (place.provider.google) place.provider.google = place.provider.google.split('|')[0] // Vashon ferry terminal if (place.provider.foursquare === vashonFerryTerminalFoursquareId) { foundVashonFerryTerminal++ vashonFerryTerminalId = place._id } // La Playa if (place.provider.foursquare === laPlayaFoursquareId || place.provider.google === laPlayaGoogleId || place.provider.yelp === laPlayaYelpId) { foundLaPlaya++ laPlayaId = place._id } var cat = place.category t.assert(cat, place) t.assert(cat.id) t.assert(cat.name) t.assert(cat.photo) var iconFileName = path.join(util.statics.assetsDir, '/img/categories', cat.photo.prefix + '88' + cat.photo.suffix) t.assert(fs.existsSync(iconFileName)) t.assert(place.location) t.assert(place.location.lat) t.assert(place.location.lng) t.assert(place.location.accuracy) }) t.assert(foundVashonFerryTerminal === 1, {foundVashonFerryTerminal: foundVashonFerryTerminal}) t.assert(foundLaPlaya === 1, {foundLaPlaya: foundLaPlaya}) test.done() })

}

My instinct would be to relax the test and accept any count between 3 and 5, but I haven't been looking at this data much, and you may have reason to solve it some other way.

Jaymassena commented 10 years ago

My initial look at this suggests this is caused by something on our side. A valid place is being returned by our foursquare provider but not getting persisted into the database (confirmed by checking the database)

Partner foursquare req 29569 options: { path: 'search', query: { ll: '47.5097,-122.463998', radius: 1609, limit: 50 }, timeout: 10000, log: true, basePath: 'search?ll=47.5097,-122.463998&radius=1609&limit=50' } Partner foursquare res 29569 0.438 status: 200 foursquare results: 10 Vashon Island Ferry Terminal 2064646400 Sweat! A Private & Small Group Training Studio 2069992375 Fauntleroy Ferry Terminal 2064646400 Metro Bus Stop #46769 2065533000 The Original Bakery 2069385088 La Playa Mexican Restaurant 2065670020 Port Vashon 2066504182 Endolyne Joe's 2069375637 Lincoln Park 2066844075 Arroyos Natural Area 2066844075

In looking at the code, there aren't any additional tests for inclusion/exclusion so the safeUpsert call must be failing silently for Vashon Island Ferry Terminal.

       if (options.log) {
          log(key + ' results: ', externalPlaces.length)
          externalPlaces.forEach(function(place) {
            log(place.name + ' ' + place.phone)
          })
        }

        if (options.includeRaw) raw.push(extRawData)  // for tests

        async.eachSeries(externalPlaces, saveExternalPlace, nextProvider)

        function saveExternalPlace(place, nextPlace) {
          db.places.safeUpsert(place, dbOps, function(err) {
            if (err) return fail(err)
            nextPlace()
          })
        }
Jaymassena commented 10 years ago

This might be a bug on our side. Could you please take a look at my comment.

-J-

From: George Snelling [mailto:notifications@github.com] Sent: Thursday, July 03, 2014 11:31 PM To: 3meters/proxibase Cc: Jay Massena Subject: [proxibase] Intermittent failure in /test/basic/41 setting hard radius (#247)

This one comes and goes.....

I don't think this is a bug in our code, more the test being too picky. Usually for tests that are twitchy for provider returned data I will add in some reasonable slack for the test.

41_places_near ✔ getSessions ✔ getCategories ✔ getPlacesNearLocationUsingLimit Roxy photo comes and goes photo properties not being nulled ✔ getPlacesNearLocationUsingLimitAgain Error:

Test failed:

Dump:

req.method: post req.uri: https://localhost:6644/v1/places/near req.body: { provider: 'foursquare|google|yelp', location: { lat: 47.5097, lng: -122.463998 }, radius: 1609, includeRaw: false, limit: 50, log: true, timeout: 10000 }

res.statusCode: 200 res.body: { data: [ { id: 'pl.140703.83996.447.064266', name: 'Metro Bus Stop #46769', namelc: 'metro bus stop #46769', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', _modifier: 'us.000000.00000.000.000000', createdDate: 1404454796447, createdIp: '127.0.0.1', modifiedDate: 1404454796447, modifiedIp: '127.0.0.1', enabled: true, visibility: 'public', location: { lat: 47.510236501693726, lng: -122.46405780315399, geometry: [ -122.46405780315399, 47.510236501693726 ], accuracy: 25 }, phone: '2065533000', address: 'Vashon Ferry Dock', postalCode: '98070', city: 'Vashon Island', region: 'WA', country: 'US', provider: { foursquare: '4baaa777f964a520267d3ae3' }, category: { id: '4bf58dd8d48988d1fe931735', name: 'Bus Station', photo: { prefix: '4bf58dd8d48988d1fe931735', suffix: '.png', source: 'assets.categories' } }, creator: { id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } }, { _id: 'pl.140703.83996.450.344007', name: 'La Playa Mexican Restaurant', namelc: 'la playa mexican restaurant', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', _modifier: 'us.000000.00000.000.000000', createdDate: 1404454796450, createdIp: '127.0.0.1', modifiedDate: 1404454798470, modifiedIp: '127.0.0.1', enabled: true, photo: { source: 'yelp', prefix: 'http://s3-media3.fl.yelpcdn.com/bphoto/UR_372fIKPNZ_EP3vZFiUg/l.jpg', createdDate: 1404454798470 }, visibility: 'public', location: { lat: 47.508574, lng: -122.463885, accuracy: 25, geometry: [ -122.463885, 47.508574 ] }, phone: '2065670020', address: '10824 Vashon Hwy SW', postalCode: '98070', city: 'Vashon', region: 'WA', country: 'US', provider: { foursquare: '4ace9457f964a5204bd120e3', google: '0ff514498e53249ed817b88835248f620fd27112|CoQBfgAAACAaCLi0QTAsH6QprwK0idy6xCywtFZym8FzAL6glXImBtZEU3QkMhwbC1l2DZc4Gdwb1I4NTA4Jf23oi2aBgB-WLMv5Wlrda4tmYDtjmrjJ6rXWSiw0KFnM702eF3PrgV0MMSSClF9TuyGQEEYYKDBH5b4iC_agLRzlJw5kvKb5EhCix4Dhg6UIanVGPUAwwE8kGhSpckHSbbD9J28u8hWswUwPPP2t3A', google1: '0ff514498e53249ed817b88835248f620fd27112', google2: 'CoQBfgAAACAaCLi0QTAsH6QprwK0idy6xCywtFZym8FzAL6glXImBtZEU3QkMhwbC1l2DZc4Gdwb1I4NTA4Jf23oi2aBgB-WLMv5Wlrda4tmYDtjmrjJ6rXWSiw0KFnM702eF3PrgV0MMSSClF9TuyGQEEYYKDBH5b4iC_agLRzlJw5kvKb5EhCix4Dhg6UIanVGPUAwwE8kGhSpckHSbbD9J28u8hWswUwPPP2t3A', yelp: 'laplaya-mexican-restaurant-vashon' }, category: { id: '4bf58dd8d48988d1c1941735', name: 'Mexican Restaurant', photo: { prefix: '4bf58dd8d48988d1c1941735', suffix: '.png', source: 'assets.categories' } }, creator: { id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } }, { _id: 'pl.140703.83996.457.015221', name: 'Port Vashon', namelc: 'port vashon', schema: 'place', _owner: 'us.000000.00000.000.000000', _creator: 'us.000000.00000.000.000000', _modifier: 'us.000000.00000.000.000000', createdDate: 1404454796457, createdIp: '127.0.0.1', modifiedDate: 1404454796457, modifiedIp: '127.0.0.1', enabled: true, visibility: 'public', location: { lat: 47.50843240022808, lng: -122.46382713317871, geometry: [ -122.46382713317871, 47.50843240022808 ], accuracy: 25 }, phone: '2066504182', address: '10824 Vashon Hwy SW', postalCode: '98070', city: 'Vashon', region: 'WA', country: 'US', provider: { foursquare: '4e53e47381302f16caf9c6f3' }, category: { id: 'generic', name: 'Place', photo: { prefix: 'generic', suffix: '.png', source: 'assets.categories' } }, creator: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, modifier: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' }, owner: { _id: 'us.000000.00000.000.000000', name: 'admin', schema: 'user' } } ], date: 1404454798484, count: 3, more: false, clientMinVersions: { 'com.aircandi.aruba': 96, 'com.aircandi.catalina': 100 },

time: 3.277 }

at Object.tok (/usr/local/prox/test/util.js:77:22)

at /usr/local/prox/test/basic/41_places_near.js:281:7

at Request._callback (/usr/local/prox/test/util.js:71:7)

at Request.self.callback (/usr/local/prox/node_modules/request/request.js:121:22)

at Request.emit (events.js:98:17)

at Request. (/usr/local/prox/node_modules/request/request.js:985:14)

at Request.emit (events.js:117:20)

at IncomingMessage. (/usr/local/prox/node_modules/request/request.js:936:12)

at IncomingMessage.emit (events.js:117:20)

at _stream_readable.js:929:16

Tests finished in 50.075 seconds

Test server closed

FAILURES: Undone tests (or their setups/teardowns):

Here's line 281 in the failing test:

t.assert(places.length === 4)

Here's the test:

exports.getPlacesNearLocationUsingRadius = function(test) { // Should take less than 5 seconds but using 10 second timeout anyway. if (disconnected) return skip(test) t.post({ uri: '/places/near', body: { provider: 'foursquare|google|yelp', location: vashonLoc, radius: 1609, // one mile includeRaw: false, limit: 50, log: true, timeout: 10000, } }, function(err, res, body) { var foundVashonFerryTerminal = 0 var foundLaPlaya = 0 t.assert(body.time < 10) // Should take less than 10 seconds var places = body.data t.assert(places.length === 4) placeCount = { aircandi: 0, foursquare: 0, google: 0, yelp: 0 } places.forEach(function(place) { var adminId = util.adminId t.assert(place.location) t.assert(place.provider) t.assert(adminId = place._owner) t.assert(adminId = place._creator) t.assert(adminId = place._modifier) for (var p in place.provider) { placeCount[p]++ } if (place.provider.google) place.provider.google = place.provider.google.split('|')[0] // Vashon ferry terminal if (place.provider.foursquare === vashonFerryTerminalFoursquareId) { foundVashonFerryTerminal++ vashonFerryTerminalId = place._id } // La Playa if (place.provider.foursquare === laPlayaFoursquareId || place.provider.google === laPlayaGoogleId || place.provider.yelp === laPlayaYelpId) { foundLaPlaya++ laPlayaId = place._id } var cat = place.category t.assert(cat, place) t.assert(cat.id) t.assert(cat.name) t.assert(cat.photo) var iconFileName = path.join(util.statics.assetsDir, '/img/categories', cat.photo.prefix + '88' + cat.photo.suffix) t.assert(fs.existsSync(iconFileName)) t.assert(place.location) t.assert(place.location.lat) t.assert(place.location.lng) t.assert(place.location.accuracy) }) t.assert(foundVashonFerryTerminal === 1, {foundVashonFerryTerminal: foundVashonFerryTerminal}) t.assert(foundLaPlaya === 1, {foundLaPlaya: foundLaPlaya}) test.done() })

}

My instinct would be to relax the test and accept any count between 3 and 5, but I haven't been looking at this data much, and you may have reason to solve it some other way.

— Reply to this email directly or view it on GitHubhttps://github.com/3meters/proxibase/issues/247.

georgesnelling commented 10 years ago

Mystery solved. Using the foursquare search path (without intent=browse -- thanks for pointing that out to me) it was returning both Vashon Ferry Terminal and Fontleroy Ferry Terminal (since it doesn't respect radius). However, they both share the same phone number, so they were merged. Whichever one was processed last won. If Vashon won, it appeared in the results, but if Fonteroy won, it was outside the requested radius and was excluded, thus the intermittent nature of the bug.

This confirms my belief that we should switch to the newer /explore path, which respects radius, is more targeted toward our use case, and includes a single photo for each place.