Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ protected enum Service {
DATABASE(8779),
TACKER(9890),
IMAGE(9292),
CLUSTERING(8778);
CLUSTERING(8778),
APP_CATALOG(8082);

private final int port;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.openstack4j.api.murano.v1;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.api.Builders;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.murano.v1.domain.Environment;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.List;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author nmakhotkin
*/
@Test(suiteName="Murano/AppCatalog", enabled = true)
public class EnvironmentTests extends AbstractTest {
private static final String ENVIRONMENTS_JSON = "/murano/v1/environments.json";
private static final String ENVIRONMENT_JSON = "/murano/v1/environment.json";
private static final String ENVIRONMENT_RENAME_JSON = "/murano/v1/environment-rename.json";

public void testListEnvironments() throws IOException {
respondWith(ENVIRONMENTS_JSON);
List<? extends Environment> list = osv3().murano().environments().list();
assertEquals(list.size(), 2);
assertEquals(list.get(0).getId(), "e1c1b5a0b3284f188c5d91ab18bf0451");
assertEquals(list.get(0).getName(), "some_env");
}

public void testGetEnvironment() throws IOException {
respondWith(ENVIRONMENT_JSON);
String id = "721f76f9a9d64ebcacc76189cb8978a9";
Environment env = osv3().murano().environments().get(id);
assertNotNull(env);
assertNotNull(env.getId());
assertEquals(env.getId(), id);
}

public void testCreateEnvironment() throws IOException {
respondWith(ENVIRONMENT_JSON);
String id = "721f76f9a9d64ebcacc76189cb8978a9";
String name = "test";
Environment env = Builders.environment().name(name).build();
env = osv3().murano().environments().create(env);
assertNotNull(env);
assertEquals(env.getId(), id);
assertEquals(env.getName(), name);
}

public void testDeleteEnvironment() throws IOException {
respondWith(204);
ActionResponse delete = osv3().murano().environments().delete("721f76f9a9d64ebcacc76189cb8978a9");
assertTrue(delete.isSuccess());
}

public void testRenameEnvironment() throws IOException {
respondWith(ENVIRONMENT_RENAME_JSON);
String name = "renamed-test";
String envId = "721f76f9a9d64ebcacc76189cb8978a9";
Environment env = osv3().murano().environments().rename(envId, name);
assertEquals(env.getName(), name);
assertEquals(env.getId(), envId);
}

@Override
protected Service service() {
return Service.APP_CATALOG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package org.openstack4j.api.murano.v1;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.ByteStreams;
import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.murano.v1.domain.Application;
import org.testng.annotations.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author nmakhotkin
*/
@Test(suiteName="Murano/AppCatalog", enabled = true)
public class ServicesTests extends AbstractTest {
private static final String SERVICE_JSON = "/murano/v1/service.json";
private static final String SERVICES_JSON = "/murano/v1/services.json";
private static final String envId = "e1c1b5a0b3284f188c5d91ab18bf0451";
private static final String sessionId = "c2e2b5a0b3284f188c5d91ab18bf8754";

private String getResourceAsString(String path) throws IOException {
InputStream is = getClass().getResourceAsStream(path);
return new String(ByteStreams.toByteArray(is));
}

public void testListServices() throws IOException {
respondWith(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().list(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testListServicesWithoutSession() throws IOException {
respondWith(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().list(envId);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testGetServicesListResponse() throws IOException {
respondWith(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().get(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testGetServicesEmptySession() throws IOException {
respondWith(200, "[]");
List<? extends Application> apps = osv3().murano().services().get(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 0);
}

public void testCreateOneService() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().create(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testCreateOneServiceFromMap() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> serviceMap = mapper.readValue(json, Map.class);

Application app = osv3().murano().services().create(envId, sessionId, serviceMap);
assertNotNull(app);
assertEquals(app.getData(), serviceMap);
}

public void testCreateManyServices() throws IOException {
respondWith(SERVICES_JSON);
String json = this.getResourceAsString(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().create(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testUpdateOneService() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().update(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testUpdateOneServiceFromMap() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> serviceMap = mapper.readValue(json, Map.class);

Application app = osv3().murano().services().update(envId, sessionId, serviceMap);
assertNotNull(app);
assertEquals(app.getData(), serviceMap);
}

public void testUpdateManyServices() throws IOException {
respondWith(SERVICES_JSON);
String json = this.getResourceAsString(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().update(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testDeleteService() throws IOException {
respondWith(200);
ActionResponse delete = osv3().murano().services().delete(envId, "/", sessionId);
assertTrue(delete.isSuccess());
}

@Override
protected Service service() {
return Service.APP_CATALOG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.openstack4j.api.murano.v1;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.murano.v1.domain.AppCatalogSession;
import org.testng.annotations.Test;

import java.io.IOException;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author nmakhotkin
*/
@Test(suiteName="Murano/AppCatalog", enabled = true)
public class SessionTests extends AbstractTest {
private static final String SESSION_JSON = "/murano/v1/session.json";
private static final String envId = "e1c1b5a0b3284f188c5d91ab18bf0451";

public void testGetSession() throws IOException {
respondWith(SESSION_JSON);
String id = "b8f4006064d24c10a33d9ed68e554f0f";
AppCatalogSession ses = osv3().murano().sessions().get(envId, id);
assertNotNull(ses);
assertNotNull(ses.getId());
assertEquals(ses.getId(), id);
}

public void testConfigureSession() throws IOException {
respondWith(SESSION_JSON);
AppCatalogSession session = osv3().murano().sessions().configure(envId);
assertNotNull(session);
assertEquals(envId, session.getEnvId());
}

public void testDeleteSession() throws IOException {
respondWith(200);
String id = "b8f4006064d24c10a33d9ed68e554f0f";
ActionResponse delete = osv3().murano().sessions().delete(envId, id);
assertTrue(delete.isSuccess());
}

public void testDeploySession() throws IOException {
respondWith(200);
String id = "b8f4006064d24c10a33d9ed68e554f0f";
ActionResponse deploy = osv3().murano().sessions().deploy(envId, id);
assertTrue(deploy.isSuccess());
}

@Override
protected Service service() {
return Service.APP_CATALOG;
}
}
25 changes: 25 additions & 0 deletions core-test/src/main/resources/identity/v3/authv3_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,31 @@
"type": "telemetry",
"id": "1236500210a24c38a3702b6825e12345",
"name": "ceilometeter"
}, {
"endpoints": [
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8082",
"region": "RegionOne",
"interface": "public",
"id": "123458912d3f49a09df51035681d6789"
}, {
"region_id": "RegionOne",
"url": "http://127.0.0.1:8082",
"region": "RegionOne",
"interface": "admin",
"id": "12345321ae80457abc3728fa1e6f4567"
}, {
"region_id": "RegionOne",
"url": "http://127.0.0.1:8082",
"region": "RegionOne",
"interface": "internal",
"id": "123450a4597040849c03bc1358857654"
}
],
"type": "application-catalog",
"id": "1236500210a24c38a3702b6825e56789",
"name": "murano"
}, {
"endpoints": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name" : "renamed-test",
"tenant_id" : "e62d6f1538074da1a56c5e393398c999",
"updated" : "2016-09-18T15:30:34",
"id" : "721f76f9a9d64ebcacc76189cb8978a9",
"version" : 1,
"created" : "2016-09-18T14:16:34",
"status" : "ready"
}
9 changes: 9 additions & 0 deletions core-test/src/main/resources/murano/v1/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name" : "test",
"tenant_id" : "e62d6f1538074da1a56c5e393398c999",
"updated" : "2016-09-18T15:30:34",
"id" : "721f76f9a9d64ebcacc76189cb8978a9",
"version" : 1,
"created" : "2016-09-18T14:16:34",
"status" : "ready"
}
22 changes: 22 additions & 0 deletions core-test/src/main/resources/murano/v1/environments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"environments" : [
{
"version" : 0,
"name" : "some_env",
"id" : "e1c1b5a0b3284f188c5d91ab18bf0451",
"tenant_id" : "e62d6f1538074da1a56c5e393398c999",
"status" : "ready",
"created" : "2016-09-27T11:35:19",
"updated" : "2016-09-27T11:35:19"
},
{
"updated" : "2016-09-18T15:30:34",
"created" : "2016-09-18T14:16:34",
"status" : "deploy failure",
"id" : "721f76f9a9d64ebcacc76189cb8978a9",
"tenant_id" : "e62d6f1538074da1a56c5e393398c999",
"version" : 1,
"name" : "test"
}
]
}
33 changes: 33 additions & 0 deletions core-test/src/main/resources/murano/v1/service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"instance" : {
"availabilityZone" : "nova",
"openstackId" : "8204d92c-9a79-4474-9f65-2f54f092948e",
"name" : "Docker",
"securityGroupName" : null,
"image" : "500375f8-e64b-453e-8b46-5d5d0d1d926a",
"ipAddresses" : [ "10.0.115.3", "172.16.167.175" ],
"networks" : {
"useFlatNetwork" : false,
"primaryNetwork" : null,
"useEnvironmentNetwork" : true,
"customNetworks" : []
},
"keyname" : "nmakhotkin",
"sharedIps" : [],
"floatingIpAddress" : "172.16.167.175",
"flavor" : "m1.medium",
"assignFloatingIp" : true,
"?" : {
"classVersion" : "0.0.0",
"name" : null,
"package" : "io.murano",
"type" : "io.murano.resources.LinuxMuranoInstance",
"_actions" : {},
"id" : "c350d3f6-5d58-44e8-97ce-930f112c7f9e"
}
},
"name" : "DockerVM",
"dockerRegistry" : null,
"containers" : [ "DockerHTTPdSite" ],
"applicationEndpoints" : []
}
Loading