use of org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method shouldIncludePluginsVolumeInArtifactsBroker.
@Test
public void shouldIncludePluginsVolumeInArtifactsBroker() throws Exception {
// 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();
InternalMachineConfig machine = brokersConfigs.machines.values().iterator().next();
assertTrue(machine.getVolumes().containsKey(PLUGINS_VOLUME_NAME));
assertEquals(machine.getVolumes().get(PLUGINS_VOLUME_NAME).getPath(), "/plugins");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method testAddsMergeArgToMetadataBroker.
@Test
public void testAddsMergeArgToMetadataBroker() throws Exception {
// given
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForMetadataBroker(pluginFQNs, runtimeId, true);
// 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);
assertTrue(container.getArgs().stream().anyMatch(e -> "--merge-plugins".equals(e)));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs in project devspaces-images by redhat-developer.
the class BrokerEnvironmentFactoryTest method shouldNameContainersAfterMetadataPluginBrokerImage.
@Test
public void shouldNameContainersAfterMetadataPluginBrokerImage() 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();
PodSpec brokerPodSpec = brokersConfigs.pods.values().iterator().next().getSpec();
List<Container> containers = brokerPodSpec.getContainers();
assertEquals(containers.size(), 1);
assertEquals(containers.get(0).getName(), "metadata-image");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs 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.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs 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));
}
Aggregations