Skip to content

Commit

Permalink
Move tests out of geo ip processor tests (elastic#114656)
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke authored Oct 11, 2024
1 parent 693fb95 commit e65ee92
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 433 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.ingest.geoip;

import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.test.ESTestCase;

import java.util.Set;

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

public class DatabaseTests extends ESTestCase {

public void testDatabasePropertyInvariants() {
// the city database is like a specialization of the country database
assertThat(Sets.difference(Database.Country.properties(), Database.City.properties()), is(empty()));
assertThat(Sets.difference(Database.Country.defaultProperties(), Database.City.defaultProperties()), is(empty()));

// the isp database is like a specialization of the asn database
assertThat(Sets.difference(Database.Asn.properties(), Database.Isp.properties()), is(empty()));
assertThat(Sets.difference(Database.Asn.defaultProperties(), Database.Isp.defaultProperties()), is(empty()));

// the enterprise database is like these other databases joined together
for (Database type : Set.of(
Database.City,
Database.Country,
Database.Asn,
Database.AnonymousIp,
Database.ConnectionType,
Database.Domain,
Database.Isp
)) {
assertThat(Sets.difference(type.properties(), Database.Enterprise.properties()), is(empty()));
}
// but in terms of the default fields, it's like a drop-in replacement for the city database
// n.b. this is just a choice we decided to make here at Elastic
assertThat(Database.Enterprise.defaultProperties(), equalTo(Database.City.defaultProperties()));
}
}
Loading

0 comments on commit e65ee92

Please sign in to comment.