Replace Nginx fixture usage with UrlFixture (#103494)
- Simplify test setup in URLSearchableSnapshotsIT - Delete nginx test fixture project
This commit is contained in:
parent
842303cd7f
commit
7773364284
|
@ -100,7 +100,6 @@ List projects = [
|
|||
'test:fixtures:testcontainer-utils',
|
||||
'test:fixtures:geoip-fixture',
|
||||
'test:fixtures:url-fixture',
|
||||
'test:fixtures:nginx-fixture',
|
||||
'test:logger-usage',
|
||||
'test:test-clusters',
|
||||
'test:x-content',
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
FROM nginx
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* 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 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 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
apply plugin: 'elasticsearch.test.fixtures'
|
||||
|
||||
description = 'Fixture for an external http service'
|
||||
|
||||
// These directories are shared between the URL repository and the FS repository in integration tests
|
||||
project.ext {
|
||||
fsRepositoryDir = file("${testFixturesDir}/fs-repository")
|
||||
}
|
||||
|
||||
tasks.named("preProcessFixture").configure {
|
||||
doLast {
|
||||
// tests expect to have an empty repo
|
||||
project.ext.fsRepositoryDir.mkdirs()
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
nginx-fixture:
|
||||
build:
|
||||
context: .
|
||||
volumes:
|
||||
- ./testfixtures_shared/fs-repository:/data
|
||||
ports:
|
||||
- "80"
|
|
@ -1,10 +0,0 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
root /data;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
||||
|
||||
apply plugin: 'elasticsearch.legacy-java-rest-test'
|
||||
apply plugin: 'elasticsearch.internal-java-rest-test'
|
||||
apply plugin: 'elasticsearch.rest-resources'
|
||||
|
||||
final Project fixture = project(':test:fixtures:nginx-fixture')
|
||||
|
||||
dependencies {
|
||||
javaRestTestImplementation(testArtifact(project(xpackModule('searchable-snapshots'))))
|
||||
javaRestTestImplementation project(':test:fixtures:url-fixture')
|
||||
}
|
||||
|
||||
restResources {
|
||||
|
@ -15,34 +14,6 @@ restResources {
|
|||
}
|
||||
}
|
||||
|
||||
apply plugin: 'elasticsearch.test.fixtures'
|
||||
testFixtures.useFixture(fixture.path, 'nginx-fixture')
|
||||
|
||||
def fixtureAddress = { fixtureName ->
|
||||
int ephemeralPort = fixture.postProcessFixture.ext."test.fixtures.${fixtureName}.tcp.80"
|
||||
assert ephemeralPort > 0
|
||||
'http://127.0.0.1:' + ephemeralPort
|
||||
}
|
||||
|
||||
File repositoryDir = fixture.fsRepositoryDir as File
|
||||
|
||||
tasks.named("javaRestTest").configure {
|
||||
dependsOn fixture.getTasks().named("postProcessFixture")
|
||||
|
||||
nonInputProperties.systemProperty 'test.url.fs.repo.dir', repositoryDir.absolutePath
|
||||
nonInputProperties.systemProperty 'test.url.http', "${-> fixtureAddress('nginx-fixture')}"
|
||||
}
|
||||
|
||||
testClusters.matching { it.name == "javaRestTest" }.configureEach {
|
||||
testDistribution = 'DEFAULT'
|
||||
setting 'path.repo', repositoryDir.absolutePath, IGNORE_VALUE
|
||||
setting 'repositories.url.allowed_urls', { "${-> fixtureAddress('nginx-fixture')}" }, IGNORE_VALUE
|
||||
|
||||
setting 'xpack.license.self_generated.type', 'trial'
|
||||
|
||||
setting 'xpack.searchable.snapshot.shared_cache.size', '16MB'
|
||||
setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB'
|
||||
setting 'xpack.searchable_snapshots.cache_fetch_async_thread_pool.keep_alive', '0ms'
|
||||
|
||||
setting 'xpack.security.enabled', 'false'
|
||||
usesDefaultDistribution()
|
||||
}
|
||||
|
|
|
@ -7,14 +7,37 @@
|
|||
|
||||
package org.elasticsearch.xpack.searchablesnapshots;
|
||||
|
||||
import fixture.url.URLFixture;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.repositories.fs.FsRepository;
|
||||
import org.elasticsearch.test.cluster.ElasticsearchCluster;
|
||||
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
import static org.hamcrest.Matchers.blankOrNullString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class URLSearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTestCase {
|
||||
|
||||
public static URLFixture urlFixture = new URLFixture();
|
||||
|
||||
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
|
||||
.distribution(DistributionType.DEFAULT)
|
||||
.setting("xpack.license.self_generated.type", "trial")
|
||||
.setting("repositories.url.allowed_urls", () -> urlFixture.getAddress())
|
||||
.setting("path.repo", () -> urlFixture.getRepositoryDir())
|
||||
.setting("xpack.searchable.snapshot.shared_cache.size", "16MB")
|
||||
.setting("xpack.searchable.snapshot.shared_cache.region_size", "256KB")
|
||||
.setting("xpack.searchable_snapshots.cache_fetch_async_thread_pool.keep_alive", "0ms")
|
||||
.setting("xpack.security.enabled", "false")
|
||||
.build();
|
||||
|
||||
@ClassRule
|
||||
public static TestRule ruleChain = RuleChain.outerRule(urlFixture).around(cluster);
|
||||
|
||||
@Override
|
||||
protected String writeRepositoryType() {
|
||||
return FsRepository.TYPE;
|
||||
|
@ -22,7 +45,7 @@ public class URLSearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTes
|
|||
|
||||
@Override
|
||||
protected Settings writeRepositorySettings() {
|
||||
final String repoDirectory = System.getProperty("test.url.fs.repo.dir");
|
||||
final String repoDirectory = urlFixture.getRepositoryDir();
|
||||
assertThat(repoDirectory, not(blankOrNullString()));
|
||||
|
||||
return Settings.builder().put("location", repoDirectory).build();
|
||||
|
@ -40,9 +63,14 @@ public class URLSearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTes
|
|||
|
||||
@Override
|
||||
protected Settings readRepositorySettings() {
|
||||
final String url = System.getProperty("test.url.http");
|
||||
final String url = urlFixture.getAddress();
|
||||
assertThat(url, not(blankOrNullString()));
|
||||
|
||||
return Settings.builder().put("url", url).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestRestCluster() {
|
||||
return cluster.getHttpAddresses();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue