use of org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method shouldCreateConfigMapWithPluginFQNsWithArtifactsBroker.
@Test
public void shouldCreateConfigMapWithPluginFQNsWithArtifactsBroker() throws Exception {
// given
Collection<PluginFQN> pluginFQNs = ImmutableList.of(new PluginFQN(null, "testPublisher/testPlugin1/testver1"), new PluginFQN(new URI("testregistry"), "testPublisher/testPlugin2/testver2"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForArtifactsBroker(pluginFQNs, runtimeId, false);
// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
ConfigMap brokerConfigMap = brokersConfigs.configMaps.values().iterator().next();
String config = brokerConfigMap.getData().get(BrokerEnvironmentFactory.CONFIG_FILE);
assertFalse(config.contains("\"registry\":null"), "Should not serialize null registry");
List<String> expected = ImmutableList.of("\"id\":\"testPublisher/testPlugin1/testver1\"", "\"registry\":\"testregistry\"", "\"id\":\"testPublisher/testPlugin2/testver2\"");
for (String expect : expected) {
assertTrue(config.contains(expect), String.format("Missing field from serialized config: expected '%s' in '%s'", expect, config));
}
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method shouldNotIncludePluginsVolumeInMetadataBroker.
@Test
public void shouldNotIncludePluginsVolumeInMetadataBroker() throws Exception {
// given
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForMetadataBroker(pluginFQNs, runtimeId, false);
// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
InternalMachineConfig machine = brokersConfigs.machines.values().iterator().next();
assertFalse(machine.getVolumes().containsKey(PLUGINS_VOLUME_NAME));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method testQuotasBroker.
@Test
public void testQuotasBroker() throws Exception {
// given
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForMetadataBroker(pluginFQNs, runtimeId, false);
// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
List<Container> containers = brokersConfigs.pods.values().stream().flatMap(p -> p.getSpec().getContainers().stream()).collect(Collectors.toList());
assertEquals(containers.size(), 1);
Container container = containers.get(0);
assertEquals(container.getResources().getRequests().get("memory"), new Quantity("250Mi"));
assertEquals(container.getResources().getLimits().get("memory"), new Quantity("250Mi"));
assertEquals(container.getResources().getRequests().get("cpu"), new Quantity("300m"));
assertEquals(container.getResources().getLimits().get("cpu"), new Quantity("300m"));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method testArtifactsBrokerSelfSignedCertificate.
@Test
public void testArtifactsBrokerSelfSignedCertificate() throws Exception {
when(certProvisioner.isConfigured()).thenReturn(true);
when(certProvisioner.getCertPath()).thenReturn("/tmp/che/cacert");
// given
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForArtifactsBroker(pluginFQNs, runtimeId, false);
// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
List<Container> containers = brokersConfigs.pods.values().stream().flatMap(p -> p.getSpec().getContainers().stream()).collect(Collectors.toList());
assertEquals(containers.size(), 1);
Container container = containers.get(0);
assertEquals(container.getArgs().toArray(), new String[] { "--push-endpoint", PUSH_ENDPOINT, "--runtime-id", String.format("%s:%s:%s", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId()), "--cacert", "/tmp/che/cacert", "--registry-address", DEFAULT_REGISTRY, "--metas", "/broker-config/config.json" });
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN in project devspaces-images by redhat-developer.
the class PluginFQNParserTest method validAttributesProvider.
@DataProvider(name = "validAttributesProvider")
public static Object[][] validAttributesProvider() {
PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver");
PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "publisher/plugin/1.0");
PluginFQN noRegistry = new PluginFQN(null, "publisher/pluginnoregistry/2.0");
PluginFQN pathRegistry = new PluginFQN(URI.create("http://registry/multiple/path"), "publisher/pluginpathregistry/3.0");
PluginFQN reference = new PluginFQN("http://mysite:8080/multiple/path/meta.yaml");
return new AttributeParsingTestCase[][] { { new AttributeParsingTestCase("Test plugin with registry", ImmutableList.of(basicEditor, withRegistry), createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry))) }, { new AttributeParsingTestCase("Test plugin with https registry", ImmutableList.of(new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")), createAttributes(null, formatPlugin(new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")))) }, { new AttributeParsingTestCase("Test plugin with registry containing path", ImmutableList.of(new PluginFQN(URI.create("https://registry:8080/some/path/v3"), "publisher/editor/ver")), createAttributes(null, formatPlugin(new PluginFQN(URI.create("https://registry:8080/some/path/v3/"), "publisher/editor/ver")))) }, { new AttributeParsingTestCase("Test plugin without registry", ImmutableList.of(basicEditor, noRegistry), createAttributes(formatPlugin(basicEditor), formatPlugins(noRegistry))) }, { new AttributeParsingTestCase("Test plugin with multi-level path in registry", ImmutableList.of(basicEditor, pathRegistry), createAttributes(formatPlugin(basicEditor), formatPlugins(pathRegistry))) }, { new AttributeParsingTestCase("Test plugin described by reference", ImmutableList.of(basicEditor, reference), createAttributes(formatPlugin(basicEditor), "http://mysite:8080/multiple/path/meta.yaml")) }, { new AttributeParsingTestCase("Test attributes with no editor field", ImmutableList.of(withRegistry), createAttributes(null, formatPlugins(withRegistry))) }, { new AttributeParsingTestCase("Test attributes with empty editor field", ImmutableList.of(withRegistry), createAttributes("", formatPlugins(withRegistry))) }, { new AttributeParsingTestCase("Test attributes with no plugin field", ImmutableList.of(basicEditor), createAttributes(formatPlugin(basicEditor), (String[]) null)) }, { new AttributeParsingTestCase("Test attributes with empty plugin field", ImmutableList.of(basicEditor), createAttributes(formatPlugin(basicEditor), "")) }, { new AttributeParsingTestCase("Test attributes with no plugin or editor field", Collections.emptyList(), createAttributes(null, (String[]) null)) }, { new AttributeParsingTestCase("Test attributes with empty plugin and editor field", Collections.emptyList(), createAttributes("", "")) }, { new AttributeParsingTestCase("Test multiple plugins and an editor", ImmutableList.of(basicEditor, withRegistry, noRegistry, pathRegistry), createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry, noRegistry, pathRegistry))) } };
}
Aggregations