IP address for testing MaxMind GeoIP DB
Asked Answered
L

3

7

I'm experimenting with the MaxMind GeoIP (lite) DB.

Part of this is trying to see if I can make solid unittests.

For unittests I'd need to have some IP addresses I can rely on sending the same information always.

Most IP addresses will move around, and I'm assuming they're even more fluid in a GeoIP database, but are there some IP addresses I can reasonably rely on (for whatever reason)?

Ludie answered 12/5, 2014 at 13:16 Comment(0)
M
6

Martijn,

You can use the Pingdom probe servers IP address as reference. It is physical server running 24x7 and it is rarely reallocated to other locations unless required by data center.

https://www.pingdom.com/rss/probe_servers.xml

Mazman answered 13/5, 2014 at 0:5 Comment(0)
T
6

You could also use a test database from the API unit tests. These are small enough to just include in your repo.

Toxicity answered 12/5, 2014 at 18:29 Comment(2)
This does not work - I upvoted the answer before I tried it out and now I can not undo that - for example the IP 12.87.118.0 shows "Pittsburgh PA US" in the unit test file but a Geo Lite database file from last month shows "Garden City KS US", and in the Test Demo at maxmind.com/en/geoip-demo I get "McKinney TX US"Foal
These databases provide stable test data to use in tests. The intent is not to provide real data that matches the production databases.Toxicity
M
6

Martijn,

You can use the Pingdom probe servers IP address as reference. It is physical server running 24x7 and it is rarely reallocated to other locations unless required by data center.

https://www.pingdom.com/rss/probe_servers.xml

Mazman answered 13/5, 2014 at 0:5 Comment(0)
G
1

Approach 1: If the point is to test how your code behaves when Maxmind reports that an IP address is in a particular country or whatever, stub the Maxmind library method to return the answer you need for each test. I have used Maxmind and this approach was all I ever needed.

Approach 2: Pick a hostname which you expect to be in the country you need (say whitehouse.gov), look up its IP address each time you run the test, and use that.

Gaillardia answered 12/5, 2014 at 17:27 Comment(1)
I need something like Approach 1; return the same country/city/latitude/longitude/etc across database updates. A stub it is, I guess.Ludie

© 2022 - 2024 — McMap. All rights reserved.