forked from ContainX/openstack4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test coverage for loadbalancersv2, listeners, healthmonitorsv2
- Loading branch information
1 parent
4c7756c
commit a03709d
Showing
13 changed files
with
579 additions
and
7 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
core-test/src/main/java/org/openstack4j/api/network/HealthMonitorV2Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package org.openstack4j.api.network; | ||
|
||
import org.openstack4j.api.AbstractTest; | ||
import org.openstack4j.api.Builders; | ||
import org.openstack4j.model.common.ActionResponse; | ||
import org.openstack4j.model.network.ext.HealthMonitorType; | ||
import org.openstack4j.model.network.ext.HealthMonitorV2; | ||
import org.openstack4j.model.network.ext.HealthMonitorV2Update; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
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 ashleykasim | ||
* | ||
*/ | ||
@Test(suiteName="Network/healthMonitorV2", enabled = true) | ||
public class HealthMonitorV2Tests extends AbstractTest { | ||
private static final String HEALTHMONITORSV2_JSON = "/network/healthmonitorsv2.json"; | ||
private static final String HEALTHMONITORV2_JSON = "/network/healthmonitorv2.json"; | ||
private static final String HEALTHMONITORV2_UPDATE_JSON = "/network/healthmonitorv2_update.json"; | ||
|
||
public void testListHealthMonitorsV2() throws IOException { | ||
respondWith(HEALTHMONITORSV2_JSON); | ||
List<? extends HealthMonitorV2> list = osv3().networking().lbaasV2().healthMonitorV2().list(); | ||
assertEquals(list.size(), 3); | ||
assertEquals("350576d8-5015-4d4e-b73f-23df2397e4c4", list.get(0).getId()); | ||
} | ||
|
||
public void testListHealthMonitorsV2Filter() throws IOException { | ||
respondWith(HEALTHMONITORSV2_JSON); | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("tenant_id", "6f759d84e3ca496ab77f8c0ffaa0311e"); | ||
List<? extends HealthMonitorV2> list = osv3().networking().lbaasV2().healthMonitorV2().list(map); | ||
assertEquals(list.size(), 3); | ||
} | ||
|
||
public void testGetHealthMonitorV2() throws IOException { | ||
respondWith(HEALTHMONITORV2_JSON); | ||
String id = "350576d8-5015-4d4e-b73f-23df2397e4c4"; | ||
HealthMonitorV2 hm = osv3().networking().lbaasV2().healthMonitorV2().get(id); | ||
assertNotNull(hm); | ||
assertEquals(hm.getId(), id); | ||
} | ||
|
||
public void testCreateHealthMonitorV2() throws IOException { | ||
respondWith(HEALTHMONITORV2_JSON); | ||
Integer delay = 2; | ||
Integer timeout = 3; | ||
HealthMonitorType type = HealthMonitorType.HTTP; | ||
HealthMonitorV2 create = Builders.healthmonitorV2() | ||
.adminStateUp(true) | ||
.delay(delay) | ||
.type(type) | ||
.timeout(timeout) | ||
.build(); | ||
HealthMonitorV2 result = osv3().networking().lbaasV2().healthMonitorV2().create(create); | ||
assertEquals(result.getDelay(), delay); | ||
assertEquals(result.getTimeout(), timeout); | ||
assertEquals(result.getType(), type); | ||
assertTrue(result.isAdminStateUp()); | ||
} | ||
|
||
public void testUpdateHealthMonitorV2() throws IOException { | ||
respondWith(HEALTHMONITORV2_UPDATE_JSON); | ||
Integer delay = 10; | ||
Integer timeout = 5; | ||
String id = "350576d8-5015-4d4e-b73f-23df2397e4c4"; | ||
HealthMonitorV2Update update = Builders.healthMonitorV2Update() | ||
.delay(delay) | ||
.timeout(timeout) | ||
.build(); | ||
HealthMonitorV2 result = osv3().networking().lbaasV2().healthMonitorV2().update(id, update); | ||
assertEquals(result.getDelay(), delay); | ||
assertEquals(result.getTimeout(), timeout); | ||
} | ||
|
||
public void testDeleteHealthMonitorV2() { | ||
respondWith(204); | ||
ActionResponse result = osv3().networking().lbaasV2().healthMonitorV2().delete("350576d8-5015-4d4e-b73f-23df2397e4c4"); | ||
assertTrue(result.isSuccess()); | ||
} | ||
|
||
@Override | ||
protected Service service() { | ||
return Service.NETWORK; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
core-test/src/main/java/org/openstack4j/api/network/ListenerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package org.openstack4j.api.network; | ||
|
||
|
||
import org.openstack4j.api.AbstractTest; | ||
import org.openstack4j.api.Builders; | ||
import org.openstack4j.model.common.ActionResponse; | ||
import org.openstack4j.model.network.ext.Listener; | ||
import org.openstack4j.model.network.ext.ListenerUpdate; | ||
import org.openstack4j.model.network.ext.Protocol; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.testng.Assert.assertNotNull; | ||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
import static org.testng.Assert.assertFalse; | ||
|
||
/** | ||
* | ||
* @author ashleykasim | ||
* | ||
*/ | ||
@Test(suiteName="Network/listener", enabled = true) | ||
public class ListenerTests extends AbstractTest { | ||
private static final String LISTENERS_JSON = "/network/listeners.json"; | ||
private static final String LISTENER_JSON = "/network/listener.json"; | ||
private static final String LISTENER_UPDATE_JSON = "/network/listener_update.json"; | ||
|
||
public void testListListeners() throws IOException { | ||
respondWith(LISTENERS_JSON); | ||
List<? extends Listener> list = osv3().networking().lbaasV2().listener().list(); | ||
assertEquals(list.size(), 2); | ||
assertEquals(list.get(0).getName(), "listener1"); | ||
} | ||
|
||
public void testListListenersFilter() throws IOException { | ||
respondWith(LISTENERS_JSON); | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("tenantId", "6f759d84e3ca496ab77f8c0ffaa0311e"); | ||
List<? extends Listener> list = osv3().networking().lbaasV2().listener().list(map); | ||
assertEquals(list.size(), 2); | ||
} | ||
|
||
public void testGetListener() throws IOException { | ||
respondWith(LISTENER_JSON); | ||
String id = "c07058a9-8d84-4443-b8f5-508d0facfe10"; | ||
Listener listener = osv3().networking().lbaasV2().listener().get(id); | ||
assertNotNull(listener); | ||
assertEquals(listener.getId(), id); | ||
} | ||
|
||
public void testCreateListener() throws IOException { | ||
respondWith(LISTENER_JSON); | ||
String name = "listener1"; | ||
String description = ""; | ||
Protocol protocol = Protocol.HTTP; | ||
Listener create = Builders.listenerV2() | ||
.adminStateUp(true) | ||
.name(name) | ||
.description(description) | ||
.protocol(protocol) | ||
.build(); | ||
Listener result = osv3().networking().lbaasV2().listener().create(create); | ||
assertEquals(result.getName(), name); | ||
assertEquals(result.getDescription(), description); | ||
assertEquals(result.getProtocol(), protocol); | ||
assertTrue(result.isAdminStateUp()); | ||
} | ||
|
||
public void testUpdateListener() throws IOException { | ||
respondWith(LISTENER_UPDATE_JSON); | ||
String name = "listener_updated"; | ||
String description = "im a good listener"; | ||
Integer connectionLimit = 20; | ||
ListenerUpdate update = Builders.listenerV2Update() | ||
.adminStateUp(false) | ||
.description(description) | ||
.name(name) | ||
.connectionLimit(connectionLimit) | ||
.build(); | ||
Listener result = osv3().networking().lbaasV2().listener().update("c07058a9-8d84-4443-b8f5-508d0facfe10", update); | ||
assertFalse(result.isAdminStateUp()); | ||
assertEquals(result.getName(), name); | ||
assertEquals(result.getDescription(), description); | ||
assertEquals(result.getConnectionLimit(), connectionLimit); | ||
} | ||
|
||
public void testDeleteListener() { | ||
respondWith(204); | ||
ActionResponse result = osv3().networking().lbaasV2().listener().delete("c07058a9-8d84-4443-b8f5-508d0facfe10"); | ||
assertTrue(result.isSuccess()); | ||
} | ||
|
||
@Override | ||
protected Service service() { | ||
return Service.NETWORK; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
core-test/src/main/java/org/openstack4j/api/network/LoadBalancerV2Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package org.openstack4j.api.network; | ||
|
||
|
||
import org.openstack4j.api.AbstractTest; | ||
import org.openstack4j.api.Builders; | ||
import org.openstack4j.model.common.ActionResponse; | ||
import org.openstack4j.model.network.ext.LoadBalancerV2; | ||
import org.openstack4j.model.network.ext.LoadBalancerV2Update; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
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; | ||
import static org.testng.Assert.assertFalse; | ||
|
||
/** | ||
* | ||
* @author ashleykasim | ||
* | ||
*/ | ||
@Test(suiteName="Network/loadBalancerV2", enabled = true) | ||
public class LoadBalancerV2Tests extends AbstractTest { | ||
private static final String LOADBALANCERSV2_JSON = "/network/loadbalancersv2.json"; | ||
private static final String LOADBALANCERV2_JSON = "/network/loadbalancerv2.json"; | ||
private static final String LOADBALANCERV2_UPDATE_JSON = "/network/loadbalancerv2_update.json"; | ||
|
||
public void testListLoadBalancersV2() throws IOException { | ||
respondWith(LOADBALANCERSV2_JSON); | ||
List<? extends LoadBalancerV2> list = osv3().networking().lbaasV2().loadbalancerV2().list(); | ||
assertEquals(list.size(), 3); | ||
assertEquals(list.get(0).getName(), "lb1"); | ||
} | ||
|
||
public void testListLoadBalancersV2Filter() throws IOException { | ||
respondWith(LOADBALANCERSV2_JSON); | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("provider", "octavia"); | ||
List<? extends LoadBalancerV2> list = osv3().networking().lbaasV2().loadbalancerV2().list(map); | ||
assertEquals(list.size(), 3); | ||
} | ||
|
||
public void testGetLoadBalancerV2() throws IOException { | ||
respondWith(LOADBALANCERV2_JSON); | ||
String id = "282b71ea-9ceb-4cd6-8881-cb511af2edb5"; | ||
LoadBalancerV2 lb = osv3().networking().lbaasV2().loadbalancerV2().get(id); | ||
assertNotNull(lb); | ||
assertEquals(lb.getId(), id); | ||
} | ||
|
||
public void testCreateLoadBalancerV2() throws IOException { | ||
respondWith(LOADBALANCERV2_JSON); | ||
String name = "lb1"; | ||
String description = "im a baby lb"; | ||
String address = "10.0.0.13"; | ||
String subnetId = "388c5684-86b0-49ab-90ef-944b1f7328f8"; | ||
LoadBalancerV2 create = Builders.loadbalancerV2() | ||
.adminStateUp(false) | ||
.name(name) | ||
.description(description) | ||
.address(address) | ||
.subnetId(subnetId) | ||
.build(); | ||
LoadBalancerV2 result = osv3().networking().lbaasV2().loadbalancerV2().create(create); | ||
assertEquals(result.getName(), name); | ||
assertEquals(result.getDescription(), description); | ||
assertEquals(result.getVIPAddress(), address); | ||
assertEquals(result.getVIPSubnetId(), subnetId); | ||
assertFalse(result.isAdminStateUp()); | ||
} | ||
|
||
public void testUpdateLoadBalancerV2() throws IOException { | ||
respondWith(LOADBALANCERV2_UPDATE_JSON); | ||
String name = "lb_updated"; | ||
String description = "im no longer a baby lb"; | ||
LoadBalancerV2Update update = Builders.loadBalancerV2Update() | ||
.adminStateUp(true) | ||
.description(description) | ||
.name(name) | ||
.build(); | ||
LoadBalancerV2 result = osv3().networking().lbaasV2().loadbalancerV2().update("282b71ea-9ceb-4cd6-8881-cb511af2edb5", update); | ||
assertTrue(result.isAdminStateUp()); | ||
assertEquals(result.getName(), name); | ||
assertEquals(result.getDescription(), description); | ||
} | ||
|
||
public void testDeleteLoadbalancerV2() { | ||
respondWith(204); | ||
ActionResponse result = osv3().networking().lbaasV2().loadbalancerV2().delete("282b71ea-9ceb-4cd6-8881-cb511af2edb5"); | ||
assertTrue(result.isSuccess()); | ||
} | ||
|
||
@Override | ||
protected Service service() { | ||
return Service.NETWORK; | ||
} | ||
} |
Oops, something went wrong.