Skip to content

Commit

Permalink
Replace Nginx fixture usage with UrlFixture (elastic#103494)
Browse files Browse the repository at this point in the history
- Simplify test setup in URLSearchableSnapshotsIT
- Delete nginx test fixture project
  • Loading branch information
breskeby authored Dec 20, 2023
1 parent 842303c commit 7773364
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 78 deletions.
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/nginx-fixture/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions test/fixtures/nginx-fixture/build.gradle

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/nginx-fixture/docker-compose.yml

This file was deleted.

10 changes: 0 additions & 10 deletions test/fixtures/nginx-fixture/nginx.conf

This file was deleted.

35 changes: 3 additions & 32 deletions x-pack/plugin/searchable-snapshots/qa/url/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,45 @@

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;
}

@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();
Expand All @@ -40,9 +63,14 @@ protected String readRepositoryType() {

@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();
}
}

0 comments on commit 7773364

Please sign in to comment.