| 
 | 1 | +/*  | 
 | 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one  | 
 | 3 | + * or more contributor license agreements. Licensed under the "Elastic License  | 
 | 4 | + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side  | 
 | 5 | + * Public License v 1"; you may not use this file except in compliance with, at  | 
 | 6 | + * your election, the "Elastic License 2.0", the "GNU Affero General Public  | 
 | 7 | + * License v3.0 only", or the "Server Side Public License, v 1".  | 
 | 8 | + */  | 
 | 9 | + | 
 | 10 | +package org.elasticsearch.ingest.geoip;  | 
 | 11 | + | 
 | 12 | +import fixture.geoip.GeoIpHttpFixture;  | 
 | 13 | + | 
 | 14 | +import com.carrotsearch.randomizedtesting.annotations.Name;  | 
 | 15 | +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;  | 
 | 16 | + | 
 | 17 | +import org.elasticsearch.core.Booleans;  | 
 | 18 | +import org.elasticsearch.core.FixForMultiProject;  | 
 | 19 | +import org.elasticsearch.multiproject.test.MultipleProjectsClientYamlSuiteTestCase;  | 
 | 20 | +import org.elasticsearch.test.cluster.ElasticsearchCluster;  | 
 | 21 | +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;  | 
 | 22 | +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;  | 
 | 23 | +import org.junit.Before;  | 
 | 24 | +import org.junit.ClassRule;  | 
 | 25 | +import org.junit.rules.RuleChain;  | 
 | 26 | +import org.junit.rules.TestRule;  | 
 | 27 | + | 
 | 28 | +import static org.elasticsearch.ingest.geoip.IngestGeoIpClientYamlTestSuiteIT.assertDatabasesLoaded;  | 
 | 29 | +import static org.elasticsearch.ingest.geoip.IngestGeoIpClientYamlTestSuiteIT.putGeoipPipeline;  | 
 | 30 | + | 
 | 31 | +@FixForMultiProject(description = "Potentially remove this test after https://elasticco.atlassian.net/browse/ES-12094 is implemented")  | 
 | 32 | +public class IngestGeoIpClientMultiProjectYamlTestSuiteIT extends MultipleProjectsClientYamlSuiteTestCase {  | 
 | 33 | + | 
 | 34 | +    private static final boolean useFixture = Booleans.parseBoolean(System.getProperty("geoip_use_service", "false")) == false;  | 
 | 35 | + | 
 | 36 | +    private static GeoIpHttpFixture fixture = new GeoIpHttpFixture(useFixture);  | 
 | 37 | + | 
 | 38 | +    private static ElasticsearchCluster cluster = ElasticsearchCluster.local()  | 
 | 39 | +        .module("reindex")  | 
 | 40 | +        .module("ingest-geoip")  | 
 | 41 | +        .systemProperty("ingest.geoip.downloader.enabled.default", "true")  | 
 | 42 | +        // sets the plain (geoip.elastic.co) downloader endpoint, which is used in these tests  | 
 | 43 | +        .setting("ingest.geoip.downloader.endpoint", () -> fixture.getAddress(), s -> useFixture)  | 
 | 44 | +        // also sets the enterprise downloader maxmind endpoint, to make sure we do not accidentally hit the real endpoint from tests  | 
 | 45 | +        // note: it's not important that the downloading actually work at this point -- the rest tests (so far) don't exercise  | 
 | 46 | +        // the downloading code because of license reasons -- but if they did, then it would be important that we're hitting a fixture  | 
 | 47 | +        .systemProperty("ingest.geoip.downloader.maxmind.endpoint.default", () -> fixture.getAddress(), s -> useFixture)  | 
 | 48 | +        .setting("test.multi_project.enabled", "true")  | 
 | 49 | +        .setting("xpack.license.self_generated.type", "trial")  | 
 | 50 | +        .user(USER, PASS)  | 
 | 51 | +        .build();  | 
 | 52 | + | 
 | 53 | +    @ClassRule  | 
 | 54 | +    public static TestRule ruleChain = RuleChain.outerRule(fixture).around(cluster);  | 
 | 55 | + | 
 | 56 | +    @Override  | 
 | 57 | +    protected String getTestRestCluster() {  | 
 | 58 | +        return cluster.getHttpAddresses();  | 
 | 59 | +    }  | 
 | 60 | + | 
 | 61 | +    public IngestGeoIpClientMultiProjectYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {  | 
 | 62 | +        super(testCandidate);  | 
 | 63 | +    }  | 
 | 64 | + | 
 | 65 | +    @ParametersFactory  | 
 | 66 | +    public static Iterable<Object[]> parameters() throws Exception {  | 
 | 67 | +        return ESClientYamlSuiteTestCase.createParameters();  | 
 | 68 | +    }  | 
 | 69 | + | 
 | 70 | +    @Before  | 
 | 71 | +    public void waitForDatabases() throws Exception {  | 
 | 72 | +        putGeoipPipeline("pipeline-with-geoip");  | 
 | 73 | +        assertDatabasesLoaded();  | 
 | 74 | +    }  | 
 | 75 | +}  | 
0 commit comments