def test_plugin_config_with_default_url(self): renderer = supplier.TemplateRenderer(version="5.5.0") repo = supplier.DistributionRepository(name="release", distribution_config={ "runtime.jdk.bundled": "false", "plugin_example_release_url": "https://artifacts.example.org/downloads/plugins/example-{{VERSION}}.zip" }, template_renderer=renderer) self.assertEqual("https://artifacts.example.org/downloads/plugins/example-5.5.0.zip", repo.plugin_download_url("example"))
def test_plugin_config_with_user_url(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "plugin_example_release_url": "https://artifacts.example.org/downloads/plugins/example-{{VERSION}}.zip", # user override "plugin.example.release.url": "https://mirror.example.org/downloads/plugins/example-{{VERSION}}.zip" }, version="5.5.0") self.assertEqual("https://mirror.example.org/downloads/plugins/example-5.5.0.zip", repo.plugin_download_url("example"))
def test_release_repo_config_with_default_url(self, os_name, cpu_arch): repo = supplier.DistributionRepository(name="release", distribution_config={ "release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}-{{OSNAME}}-{{ARCH}}.tar.gz", "release.cache": "true" }, version="7.3.2") self.assertEqual("https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz", repo.download_url) self.assertEqual("elasticsearch-7.3.2-linux-x86_64.tar.gz", repo.file_name) self.assertTrue(repo.cache)
def test_release_repo_config_with_default_url(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "true" }, version="5.5.0") self.assertEqual("https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.tar.gz", repo.download_url) self.assertEqual("elasticsearch-5.5.0.tar.gz", repo.file_name) self.assertTrue(repo.cache)
def test_missing_cache(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "release.url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", }, version="2.4.3") with self.assertRaises(exceptions.SystemSetupError) as ctx: # noinspection PyStatementEffect repo.cache self.assertEqual("Mandatory config key [release.cache] is undefined.", ctx.exception.args[0])
def test_missing_url(self): repo = supplier.DistributionRepository(name="miss", distribution_config={ "release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "true" }, version="2.4.3") with self.assertRaises(exceptions.SystemSetupError) as ctx: # noinspection PyStatementEffect repo.download_url self.assertEqual("Neither config key [miss.url] nor [miss_url] is defined.", ctx.exception.args[0])
def test_invalid_cache_value(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "release.url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "Invalid" }, version="2.4.3") with self.assertRaises(exceptions.SystemSetupError) as ctx: # noinspection PyStatementEffect repo.cache self.assertEqual("Value [Invalid] for config key [release.cache] is not a valid boolean value.", ctx.exception.args[0])
def test_missing_plugin_config(self): renderer = supplier.TemplateRenderer(version="5.5.0") repo = supplier.DistributionRepository(name="release", distribution_config={ "runtime.jdk.bundled": "false", }, template_renderer=renderer) self.assertIsNone(repo.plugin_download_url("not existing"))
def test_resolve_plugin_url(self): v = {"plugin_custom-analyzer_release_url": "http://example.org/elasticearch/custom-analyzer-{{VERSION}}.zip"} s = supplier.PluginDistributionSupplier(repo=supplier.DistributionRepository(name="release", distribution_config=v, version="6.3.0"), plugin=team.PluginDescriptor("custom-analyzer")) binaries = {} s.add(binaries) self.assertDictEqual(binaries, {"custom-analyzer": "http://example.org/elasticearch/custom-analyzer-6.3.0.zip"})
def test_release_repo_config_with_version_url(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "release.2.url": "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/" "{{VERSION}}/elasticsearch-{{VERSION}}.tar.gz", "release.url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "false" }, version="2.4.3") self.assertEqual("https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.3/" "elasticsearch-2.4.3.tar.gz", repo.download_url) self.assertFalse(repo.cache)
def test_release_repo_config_with_user_url(self): repo = supplier.DistributionRepository(name="release", distribution_config={ "release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", # user override "release.url": "https://es-mirror.example.org/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "false" }, version="2.4.3") self.assertEqual("https://es-mirror.example.org/downloads/elasticsearch/elasticsearch-2.4.3.tar.gz", repo.download_url) self.assertEqual("elasticsearch-2.4.3.tar.gz", repo.file_name) self.assertFalse(repo.cache)
def test_missing_cache(self): renderer = supplier.TemplateRenderer(version="2.4.3") repo = supplier.DistributionRepository(name="release", distribution_config={ "jdk.unbundled.release.url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "runtime.jdk.bundled": "false" }, template_renderer=renderer) with self.assertRaises(exceptions.SystemSetupError) as ctx: # pylint: disable=pointless-statement # noinspection PyStatementEffect repo.cache self.assertEqual("Mandatory config key [release.cache] is undefined.", ctx.exception.args[0])
def test_missing_url(self): renderer = supplier.TemplateRenderer(version="2.4.3") repo = supplier.DistributionRepository( name="miss", distribution_config={ "jdk.unbundled.release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "runtime.jdk.bundled": "false", "release.cache": "true", }, template_renderer=renderer, ) with pytest.raises(exceptions.SystemSetupError) as exc: # pylint: disable=pointless-statement # noinspection PyStatementEffect repo.download_url assert exc.value.args[ 0] == "Neither config key [miss.url] nor [jdk.unbundled.miss_url] is defined."
def test_invalid_cache_value(self): renderer = supplier.TemplateRenderer(version="2.4.3") repo = supplier.DistributionRepository( name="release", distribution_config={ "jdk.unbundled.release.url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "runtime.jdk.bundled": "false", "release.cache": "Invalid", }, template_renderer=renderer, ) with pytest.raises(exceptions.SystemSetupError) as exc: # pylint: disable=pointless-statement # noinspection PyStatementEffect repo.cache assert exc.value.args[ 0] == "Value [Invalid] for config key [release.cache] is not a valid boolean value."
def test_plugin_config_with_user_url(self): renderer = supplier.TemplateRenderer(version="5.5.0") repo = supplier.DistributionRepository( name="release", distribution_config={ "runtime.jdk.bundled": "false", "plugin_example_release_url": "https://artifacts.example.org/downloads/plugins/example-{{VERSION}}.zip", # user override "plugin.example.release.url": "https://mirror.example.org/downloads/plugins/example-{{VERSION}}.zip", }, template_renderer=renderer, ) assert repo.plugin_download_url( "example" ) == "https://mirror.example.org/downloads/plugins/example-5.5.0.zip"
def test_resolve_plugin_url(self): v = { "plugin_custom-analyzer_release_url": "http://example.org/elasticearch/custom-analyzer-{{VERSION}}.zip" } renderer = supplier.TemplateRenderer(version="6.3.0") s = supplier.PluginDistributionSupplier( repo=supplier.DistributionRepository(name="release", distribution_config=v, template_renderer=renderer), plugin=team.PluginDescriptor("custom-analyzer"), ) binaries = {} s.add(binaries) assert binaries == { "custom-analyzer": "http://example.org/elasticearch/custom-analyzer-6.3.0.zip", }
def test_release_repo_config_with_default_url(self, os_name, cpu_arch): renderer = supplier.TemplateRenderer(version="7.3.2") repo = supplier.DistributionRepository( name="release", distribution_config={ "runtime.jdk.bundled": "true", "jdk.bundled.release_url": ("https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}-{{OSNAME}}-{{ARCH}}.tar.gz" ), "release.cache": "true", }, template_renderer=renderer, ) assert repo.download_url == "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz" assert repo.file_name == "elasticsearch-7.3.2-linux-x86_64.tar.gz" assert repo.cache
def test_release_repo_config_with_user_url(self): renderer = supplier.TemplateRenderer(version="2.4.3") repo = supplier.DistributionRepository( name="release", distribution_config={ "jdk.unbundled.release_url": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "runtime.jdk.bundled": "false", # user override "release.url": "https://es-mirror.example.org/downloads/elasticsearch/elasticsearch-{{VERSION}}.tar.gz", "release.cache": "false", }, template_renderer=renderer, ) assert repo.download_url == "https://es-mirror.example.org/downloads/elasticsearch/elasticsearch-2.4.3.tar.gz" assert repo.file_name == "elasticsearch-2.4.3.tar.gz" assert not repo.cache
def test_missing_plugin_config(self): repo = supplier.DistributionRepository(name="release", distribution_config={}, version="5.5.0") self.assertIsNone(repo.plugin_download_url("not existing"))