PluginManager: Fix elastic.co download URLs, add snapshot ones
The URL to download the main elasticsearch plugins did not match what the S3 wageon is supposed to write to. In addition this PR adds support for snapshots to access the snapshot S3 bucket, so we can possibly download snapshot versions of plugins. The format of the URLs stems from #12270 Closes #12632
This commit is contained in:
parent
0b0846f84b
commit
88842f3319
|
@ -425,7 +425,10 @@ public class PluginManager {
|
||||||
// Elasticsearch new download service uses groupId org.elasticsearch.plugins from 2.0.0
|
// Elasticsearch new download service uses groupId org.elasticsearch.plugins from 2.0.0
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
// TODO Update to https
|
// TODO Update to https
|
||||||
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/org.elasticsearch.plugins/%1$s/%1$s-%2$s.zip", repo, version));
|
if (Version.CURRENT.snapshot()) {
|
||||||
|
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/snapshot/org/elasticsearch/plugin/%s/%s-SNAPSHOT/%s-%s-SNAPSHOT.zip", repo, version, repo, version));
|
||||||
|
}
|
||||||
|
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip", repo, version, repo, version));
|
||||||
} else {
|
} else {
|
||||||
// Elasticsearch old download service
|
// Elasticsearch old download service
|
||||||
// TODO Update to https
|
// TODO Update to https
|
||||||
|
|
|
@ -29,8 +29,11 @@ import org.junit.Test;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||||
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@ -62,22 +65,40 @@ public class PluginManagerUnitTests extends ESTestCase {
|
||||||
public void testSimplifiedNaming() throws IOException {
|
public void testSimplifiedNaming() throws IOException {
|
||||||
String pluginName = randomAsciiOfLength(10);
|
String pluginName = randomAsciiOfLength(10);
|
||||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
|
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
|
||||||
assertThat(handle.urls(), hasSize(1));
|
|
||||||
URL expected = new URL("http", "download.elastic.co", "/org.elasticsearch.plugins/" + pluginName + "/" +
|
assertThat(handle.urls(), hasSize(Version.CURRENT.snapshot() ? 2 : 1));
|
||||||
|
|
||||||
|
Iterator<URL> iterator = handle.urls().iterator();
|
||||||
|
|
||||||
|
if (Version.CURRENT.snapshot()) {
|
||||||
|
String expectedSnapshotUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/snapshot/org/elasticsearch/plugin/%s/%s-SNAPSHOT/%s-%s-SNAPSHOT.zip",
|
||||||
|
pluginName, Version.CURRENT.number(), pluginName, Version.CURRENT.number());
|
||||||
|
assertThat(iterator.next(), is(new URL(expectedSnapshotUrl)));
|
||||||
|
}
|
||||||
|
|
||||||
|
URL expected = new URL("http", "download.elastic.co", "/elasticsearch/release/org/elasticsearch/plugin/" + pluginName + "/" + Version.CURRENT.number() + "/" +
|
||||||
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
||||||
assertThat(handle.urls().get(0), is(expected));
|
assertThat(iterator.next(), is(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTrimmingElasticsearchFromOfficialPluginName() throws IOException {
|
public void testTrimmingElasticsearchFromOfficialPluginName() throws IOException {
|
||||||
String randomName = randomAsciiOfLength(10);
|
String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList());
|
||||||
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName);
|
||||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
|
assertThat(handle.name, is(randomPluginName.replaceAll("^elasticsearch-", "")));
|
||||||
assertThat(handle.name, is(randomName));
|
|
||||||
assertThat(handle.urls(), hasSize(1));
|
assertThat(handle.urls(), hasSize(Version.CURRENT.snapshot() ? 2 : 1));
|
||||||
URL expected = new URL("http", "download.elastic.co", "/org.elasticsearch.plugins/" + pluginName + "/" +
|
Iterator<URL> iterator = handle.urls().iterator();
|
||||||
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
|
||||||
assertThat(handle.urls().get(0), is(expected));
|
if (Version.CURRENT.snapshot()) {
|
||||||
|
String expectedSnapshotUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/snapshot/org/elasticsearch/plugin/%s/%s-SNAPSHOT/%s-%s-SNAPSHOT.zip",
|
||||||
|
randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||||
|
assertThat(iterator.next(), is(new URL(expectedSnapshotUrl)));
|
||||||
|
}
|
||||||
|
|
||||||
|
String releaseUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
|
||||||
|
randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||||
|
assertThat(iterator.next(), is(new URL(releaseUrl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue