Search in sources :

Example 11 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ServerTemplateVFSStorageTest method testStoreLoadAndUpdateServerTemplate.

@Test
public void testStoreLoadAndUpdateServerTemplate() {
    templateStorage.store(serverTemplate);
    ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
    assertNotNull(fromStorage);
    assertEquals(serverTemplate.getId(), fromStorage.getId());
    assertEquals(serverTemplate.getName(), fromStorage.getName());
    // let's add new container
    ContainerSpec newContainerSpec = new ContainerSpec();
    newContainerSpec.setId("test container 2");
    newContainerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    newContainerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "3.0"));
    newContainerSpec.setStatus(KieContainerStatus.STARTED);
    fromStorage.addContainerSpec(newContainerSpec);
    // now let's add server instance
    fromStorage.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), "http://localhost:8080/server"));
    templateStorage.update(fromStorage);
    ServerTemplate template = templateStorage.load(serverTemplate.getId());
    assertNotNull(template);
    assertEquals(serverTemplate.getId(), template.getId());
    assertEquals(serverTemplate.getName(), template.getName());
    Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ServerInstanceKey serverInstanceKey = instances.iterator().next();
    assertNotNull(serverInstanceKey);
    assertEquals(serverTemplate.getId(), serverInstanceKey.getServerTemplateId());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerName());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerInstanceId());
    assertEquals("http://localhost:8080/server", serverInstanceKey.getUrl());
    Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(2, containerSpecs.size());
    Iterator<ContainerSpec> iterator = containerSpecs.iterator();
    // first container spec...
    ContainerSpec spec = iterator.next();
    assertNotNull(spec);
    assertEquals(containerSpec.getId(), spec.getId());
    assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
    assertTrue(spec.getConfigs().containsKey(Capability.RULE));
    assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
    RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
    assertNotNull(ruleConfig);
    assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
    assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
    ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
    assertNotNull(processConfig);
    assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
    assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
    assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
    assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
    // second container spec
    spec = iterator.next();
    assertNotNull(spec);
    assertEquals(newContainerSpec.getId(), spec.getId());
    assertEquals(newContainerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(newContainerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(newContainerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(newContainerSpec.getConfigs().size(), spec.getConfigs().size());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Example 12 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ServerTemplateVFSStorageTest method createServerTemplateWithContainer.

/*
     * helper method to setup template container and container spec
     */
protected void createServerTemplateWithContainer() {
    serverTemplate = new ServerTemplate();
    serverTemplate.setName("test server");
    serverTemplate.setId(UUID.randomUUID().toString());
    Map<Capability, ContainerConfig> configs = new HashMap<Capability, ContainerConfig>();
    ruleConfig = new RuleConfig();
    ruleConfig.setPollInterval(1000l);
    ruleConfig.setScannerStatus(KieScannerStatus.STARTED);
    configs.put(Capability.RULE, ruleConfig);
    processConfig = new ProcessConfig();
    processConfig.setKBase("defaultKieBase");
    processConfig.setKSession("defaultKieSession");
    processConfig.setMergeMode("MERGE_COLLECTION");
    processConfig.setRuntimeStrategy("PER_PROCESS_INSTANCE");
    configs.put(Capability.PROCESS, processConfig);
    containerSpec = new ContainerSpec();
    containerSpec.setId("test container");
    containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    containerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "1.0"));
    containerSpec.setStatus(KieContainerStatus.STOPPED);
    containerSpec.setConfigs(configs);
    serverTemplate.addContainerSpec(containerSpec);
    container = new Container();
    container.setServerInstanceId(serverTemplate.getId());
    container.setServerTemplateId(serverTemplate.getId());
    container.setResolvedReleasedId(containerSpec.getReleasedId());
    container.setContainerName(containerSpec.getContainerName());
    container.setContainerSpecId(containerSpec.getId());
    container.setUrl("http://fake.server.net/kie-server");
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Container(org.kie.server.controller.api.model.runtime.Container) Capability(org.kie.server.controller.api.model.spec.Capability) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) HashMap(java.util.HashMap) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) ReleaseId(org.kie.server.api.model.ReleaseId)

Example 13 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ContainerRulesConfigPresenter method upgrade.

public void upgrade(final String version) {
    view.disableActions();
    ruleCapabilitiesService.call(new RemoteCallback<Void>() {

        @Override
        public void callback(final Void response) {
            if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) {
                notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
            }
            updateViewState();
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR));
            updateViewState();
            return false;
        }
    }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version));
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ReleaseId(org.kie.server.api.model.ReleaseId) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 14 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdatedNewInstance.

@Test
public void testOnServerInstanceUpdatedNewInstance() {
    presenter = spy(new ContainerRemoteStatusPresenter(logger, view, presenterProvider));
    final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
    when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter2 = mock(ContainerCardPresenter.class);
    when(cardPresenter2.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    final ContainerCardPresenter cardPresenter3 = mock(ContainerCardPresenter.class);
    when(cardPresenter3.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
    doReturn(cardPresenter).doReturn(cardPresenter2).doReturn(cardPresenter3).when(presenterProvider).get();
    final ServerInstance serverInstance = new ServerInstance("templateId", "serverInstanceId", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container existingContainer = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
    existingContainer.setStatus(KieContainerStatus.STARTED);
    final ServerInstance newServerInstance = new ServerInstance("templateId", "newserverInstanceId", "newserverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
    final Container newContainer = new Container("containerSpecId", "containerName", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer);
    presenter.setup(new ContainerSpec("containerSpecId", "containerName", new ServerTemplateKey("templateId", "templateId"), new ReleaseId(), KieContainerStatus.STARTED, Collections.<Capability, ContainerConfig>emptyMap()), Arrays.asList(existingContainer));
    verify(cardPresenter).setup(toKey(serverInstance), existingContainer);
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    // One container added
    verify(cardPresenter2).setup(toKey(newServerInstance), newContainer);
    final Container newContainer2 = new Container("containerSpecId", "containerNameX", newServerInstance, Collections.<Message>emptyList(), null, null);
    newContainer2.setStatus(KieContainerStatus.STARTED);
    newServerInstance.addContainer(newContainer2);
    // One new container added to existing server
    presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
    verify(cardPresenter3).setup(newContainer2.getServerInstanceKey(), newContainer2);
}
Also used : ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) Capability(org.kie.server.controller.api.model.spec.Capability) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Example 15 with ReleaseId

use of org.kie.server.api.model.ReleaseId in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testSetup.

@Test
public void testSetup() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverTemplateId", "serverName", "serverInstanceId", "url");
    serverTemplate.addServerInstance(serverInstanceKey);
    final ReleaseId releaseId = new ReleaseId("org.kie", "container", "1.0.0");
    final ContainerSpec containerSpec = new ContainerSpec("containerId", "containerName", serverTemplate, releaseId, KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec);
    final ContainerSpec containerSpec1 = new ContainerSpec("containerId1", "containerName1", serverTemplate, new ReleaseId("org.kie", "container2", "1.0.0"), KieContainerStatus.CREATING, null);
    serverTemplate.addContainerSpec(containerSpec1);
    presenter.setup(serverTemplate, containerSpec);
    assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
    verify(view).clear();
    verify(view).setTemplate(serverTemplate.getId(), serverTemplate.getName());
    verify(view).setProcessCapability(false);
    verify(view).setRulesCapability(false);
    verify(view).setPlanningCapability(false);
    verify(view).addContainer(eq(containerSpec.getServerTemplateKey().getId()), eq(containerSpec.getId()), eq(containerSpec.getContainerName()), any(Command.class));
    verify(view).addContainer(eq(containerSpec1.getServerTemplateKey().getId()), eq(containerSpec1.getId()), eq(containerSpec1.getContainerName()), any(Command.class));
    final ArgumentCaptor<ContainerSpecSelected> selectedCaptor = ArgumentCaptor.forClass(ContainerSpecSelected.class);
    verify(containerSpecSelectedEvent).fire(selectedCaptor.capture());
    assertEquals(containerSpec, selectedCaptor.getValue().getContainerSpecKey());
    verify(view).addServerInstance(eq(serverInstanceKey.getServerTemplateId()), eq(serverInstanceKey.getServerInstanceId()), eq(serverInstanceKey.getServerName()), any(Command.class));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ContainerSpecSelected(org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Aggregations

ReleaseId (org.kie.server.api.model.ReleaseId)18 Test (org.junit.Test)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)12 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)8 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)7 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)7 Container (org.kie.server.controller.api.model.runtime.Container)6 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 Before (org.junit.Before)3 Capability (org.kie.server.controller.api.model.spec.Capability)3 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)3 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)3 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)3 Command (org.uberfire.mvp.Command)3 HashMap (java.util.HashMap)2 GAV (org.guvnor.common.services.project.model.GAV)2 Message (org.kie.server.api.model.Message)2 ContainerSpecKey (org.kie.server.controller.api.model.spec.ContainerSpecKey)2 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)2 ContainerSpecSelected (org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected)2