Search in sources :

Example 46 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplateMigrationTest method testMigrationOfServerTemplateOnly.

@Test
public void testMigrationOfServerTemplateOnly() throws Exception {
    String serverTemplateId = "kie_server";
    String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-just-server.xml"));
    assertNotNull(oldServerTemplateContent);
    Path path = buildPath(serverTemplateId);
    assertNotNull(path);
    // let's store it in the old way -info.xml file
    ioService.write(path, oldServerTemplateContent);
    ServerTemplateMigration templateMigration = new ServerTemplateMigration();
    templateMigration.migrate(path.getParent(), ioService, xstream, templateStorage);
    boolean exists = templateStorage.exists(serverTemplateId);
    assertTrue(exists);
    ServerTemplate fromStorage = templateStorage.load(serverTemplateId);
    assertNotNull(fromStorage);
    // verify server template
    assertEquals(serverTemplateId, fromStorage.getId());
    assertEquals("kie server name", fromStorage.getName());
    Collection<String> capabilities = fromStorage.getCapabilities();
    assertNotNull(capabilities);
    assertEquals(0, capabilities.size());
    // verify server instances (previously known as managedInstances)
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // verify containers
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(0, containerSpecs.size());
}
Also used : Path(org.uberfire.java.nio.file.Path) ServerTemplateMigration(org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 47 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplateMigrationTest method testMigrationOfOldServerTemplateWithInstances.

@Test
public void testMigrationOfOldServerTemplateWithInstances() throws Exception {
    String serverTemplateId = "kie_server";
    String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-with-instances.xml"));
    assertNotNull(oldServerTemplateContent);
    Path path = buildPath(serverTemplateId);
    assertNotNull(path);
    // let's store it in the old way -info.xml file
    ioService.write(path, oldServerTemplateContent);
    ServerTemplateMigration templateMigration = new ServerTemplateMigration();
    templateMigration.migrate(path.getParent(), ioService, xstream, templateStorage);
    boolean exists = templateStorage.exists(serverTemplateId);
    assertTrue(exists);
    ServerTemplate fromStorage = templateStorage.load(serverTemplateId);
    assertNotNull(fromStorage);
    // verify server template
    assertEquals(serverTemplateId, fromStorage.getId());
    assertEquals("kie server name", fromStorage.getName());
    Collection<String> capabilities = fromStorage.getCapabilities();
    assertNotNull(capabilities);
    assertTrue(capabilities.contains("KieServer"));
    assertTrue(capabilities.contains("BRM"));
    assertTrue(capabilities.contains("BPM"));
    // verify server instances (previously known as managedInstances)
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ServerInstanceKey serverInstanceKey = instances.iterator().next();
    assertNotNull(serverInstanceKey);
    assertEquals(serverTemplateId, serverInstanceKey.getServerTemplateId());
    assertEquals("kie_server@localhost:8180", serverInstanceKey.getServerName());
    assertEquals("kie_server@localhost:8180", serverInstanceKey.getServerInstanceId());
    assertEquals("http://localhost:8180/kie-server/services/rest/server", serverInstanceKey.getUrl());
    // verify containers
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(0, containerSpecs.size());
}
Also used : Path(org.uberfire.java.nio.file.Path) ServerTemplateMigration(org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 48 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.

the class ServerTemplateMigrationTest method testMigrationOfOldServerTemplateWithContainers.

@Test
public void testMigrationOfOldServerTemplateWithContainers() throws Exception {
    String serverTemplateId = "kie_server";
    String oldServerTemplateContent = IOUtils.toString(this.getClass().getResourceAsStream("/kie-server-6.3-info-with-containers.xml"));
    assertNotNull(oldServerTemplateContent);
    Path path = buildPath(serverTemplateId);
    assertNotNull(path);
    // let's store it in the old way -info.xml file
    ioService.write(path, oldServerTemplateContent);
    ServerTemplateMigration templateMigration = new ServerTemplateMigration();
    templateMigration.migrate(path.getParent(), ioService, xstream, templateStorage);
    boolean exists = templateStorage.exists(serverTemplateId);
    assertTrue(exists);
    ServerTemplate fromStorage = templateStorage.load(serverTemplateId);
    assertNotNull(fromStorage);
    // verify server template
    assertEquals(serverTemplateId, fromStorage.getId());
    assertEquals("kie server name", fromStorage.getName());
    Collection<String> capabilities = fromStorage.getCapabilities();
    assertNotNull(capabilities);
    assertEquals(0, capabilities.size());
    // verify server instances (previously known as managedInstances)
    Collection<ServerInstanceKey> instances = fromStorage.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // verify containers
    Collection<ContainerSpec> containerSpecs = fromStorage.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(1, containerSpecs.size());
    Iterator<ContainerSpec> iterator = containerSpecs.iterator();
    // first container spec...
    ContainerSpec spec = iterator.next();
    assertNotNull(spec);
    assertEquals("project-1", spec.getId());
    assertEquals(new ReleaseId("org.kie.server", "project-1", "1.0.0"), spec.getReleasedId());
    assertEquals(serverTemplateId, spec.getServerTemplateKey().getId());
    assertEquals("kie server name", spec.getServerTemplateKey().getName());
    assertEquals(KieContainerStatus.STARTED, spec.getStatus());
    assertEquals(0, spec.getConfigs().size());
}
Also used : Path(org.uberfire.java.nio.file.Path) ServerTemplateMigration(org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 49 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate 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 50 with ServerTemplate

use of org.kie.server.controller.api.model.spec.ServerTemplate 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)

Aggregations

ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)61 Test (org.junit.Test)49 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)24 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)12 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)11 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)10 ArrayList (java.util.ArrayList)9 Capability (org.kie.server.controller.api.model.spec.Capability)9 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)9 Path (org.uberfire.java.nio.file.Path)9 ReleaseId (org.kie.server.api.model.ReleaseId)8 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)8 Command (org.uberfire.mvp.Command)7 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)7 Matchers.anyString (org.mockito.Matchers.anyString)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Container (org.kie.server.controller.api.model.runtime.Container)5 ValidateExistingContainerCallback (org.kie.workbench.common.screens.projecteditor.client.editor.DeploymentScreenPopupViewImpl.ValidateExistingContainerCallback)5 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)5