Skip to content

Commit

Permalink
update test-data readme and delete old script
Browse files Browse the repository at this point in the history
  • Loading branch information
NajiObeid committed Oct 19, 2023
1 parent 0fbefa7 commit 66834a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 695 deletions.
42 changes: 28 additions & 14 deletions test-data/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
The
[write-test-data.pl](https://github.com/maxmind/MaxMind-DB/blob/main/test-data/write-test-data.pl)
script will create a small set of test databases with a variety of data and
record sizes (24, 28, & 32 bit).
## How to generate test data
Use the [write-test-data](https://github.com/maxmind/MaxMind-DB/blob/main/cmd/write-test-data)
go tool to create a small set of test databases with a variety of data and
record sizes.

These test databases are useful for testing code that reads MaxMind DB files.

There is also a `maps-with-pointers.raw` file. This contains the raw output of
the MaxMind::DB::Writer::Serializer module, when given a series of maps which
share some keys and values. It is used to test that decoder code can handle
pointers to map keys and values, as well as to the whole map.

There are several ways to figure out what IP addresses are actually in the
test databases. You can take a look at the
[source-data directory](https://github.com/maxmind/MaxMind-DB/tree/main/source-data)
Expand All @@ -21,8 +16,27 @@ You can also use the
in the
[MaxMind-DB-Reader-perl repository](https://github.com/maxmind/MaxMind-DB-Reader-perl).

Some databases are intentionally broken and cannot be dumped. You can look at
the
[script which generates these databases](https://github.com/maxmind/MaxMind-DB/blob/main/test-data/write-test-data.pl)
to see what IP addresses they include, which will be necessary for those
databases which cannot be dumped because they contain intentional errors.
## Static test data
Some of the test files are remnants of the
[old perl test data writer](https://github.com/maxmind/MaxMind-DB/blob/f0a85c671c5b6e9c5e514bd66162724ee1dedea3/test-data/write-test-data.pl)
and cannot be generated with the go tool. These databases are intentionally broken,
and exploited functionality simply not available in the go mmdbwriter:

- MaxMind-DB-test-broken-pointers-24.mmdb
- MaxMind-DB-test-broken-search-tree-24.mmdb
- MaxMind-DB-test-pointer-decoder.mmdb
- GeoIP2-City-Test-Broken-Double-Format.mmdb
- GeoIP2-City-Test-Invalid-Node-Count.mmdb
- maps-with-pointers.raw

## Usage
```
Usage of ./write-test-data:
-source string
Source data directory
-target string
Destination directory for the generated mmdb files
```

Example:
`./write-test-data --source ../../source-data --target ../../test-data`
Loading

0 comments on commit 66834a5

Please sign in to comment.