1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Fix Java Template Test, add more debug info in Java tests

(cherry picked from commit baa7a252d5f2c5c47d4a6a46983fd7ad125545ce)
This commit is contained in:
Carlos Martín 2012-07-05 16:27:53 +02:00
parent f34593dc60
commit 821339f6ef
6 changed files with 67 additions and 65 deletions

View File

@ -79,7 +79,7 @@ public class AclTest
public void defaultRules()
{
res = aclPool.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertEquals(2, aclPool.getLength());
}
@ -89,7 +89,7 @@ public class AclTest
{
// Allocate rule "#1 VM+HOST/@1 INFO+CREATE"
res = Acl.allocate(client, "0x100000001", "0x3200000001", "0x8");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
acl = aclPool.getById( res.getIntMessage() );
@ -108,7 +108,7 @@ public class AclTest
{
// Allocate rule "#1 VM+HOST/@1 USE"
res = Acl.allocate(client, 0x100000001L, 214748364801L, 0x1L);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
acl = aclPool.getById( res.getIntMessage() );
@ -128,7 +128,7 @@ public class AclTest
try
{
res = Acl.allocate(client, "@507 IMAGE/#456 MANAGE");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
acl = aclPool.getById( res.getIntMessage() );
@ -191,7 +191,7 @@ public class AclTest
try
{
res = Acl.allocate(client, rules[i]);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
acl = aclPool.getById( res.getIntMessage() );
@ -220,13 +220,13 @@ public class AclTest
try
{
res = Acl.allocate(client, "#1 HOST/@2 USE");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
assertTrue( aclPool.getLength() == 3 );
res = Acl.delete(client, res.getIntMessage());
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
aclPool.info();
assertTrue( aclPool.getLength() == 2 );

View File

@ -82,7 +82,7 @@ public class GroupTest
group.delete();
res = Group.allocate(client, group_name);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
int group_id = res.isError() ? -1 : Integer.parseInt(res.getMessage());
group = new Group(group_id, client);
@ -103,7 +103,7 @@ public class GroupTest
public void info()
{
res = group.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( group.id() >= 100 );
assertTrue( group.getName().equals(group_name) );
@ -113,13 +113,13 @@ public class GroupTest
public void delete()
{
res = group.delete();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = group.info();
assertTrue( res.isError() );
res = groupPool.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
boolean found = false;
for(Group g : groupPool)
@ -143,14 +143,14 @@ public class GroupTest
for(String name : names)
{
res = User.allocate(client, "user_"+name, "password");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
users.put( name,
new User(Integer.parseInt(res.getMessage()), client )
);
res = Group.allocate(client, "group_"+name);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
groups.put( name,
new Group(Integer.parseInt(res.getMessage()), client )

View File

@ -84,7 +84,7 @@ public class HostTest
String name = "allocate_test";
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "dummy");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( res.getMessage().equals("0") );
hostPool.info();
@ -102,7 +102,7 @@ public class HostTest
public void info()
{
res = host.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( host.getId().equals("0") );
assertTrue( host.id() >= 0 );
@ -114,7 +114,7 @@ public class HostTest
public void enable()
{
res = host.enable();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
host.info();
assertTrue( host.isEnabled() );
@ -124,7 +124,7 @@ public class HostTest
public void disable()
{
res = host.disable();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
host.info();
assertTrue( !host.isEnabled() );
@ -136,13 +136,13 @@ public class HostTest
String name = host.getName();
res = host.delete();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = host.info();
assertTrue( res.isError() );
res = hostPool.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
boolean found = false;
for(Host h : hostPool)
@ -157,7 +157,7 @@ public class HostTest
public void update()
{
res = host.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) );
assertTrue( host.xpath("TEMPLATE/ATT2").equals( "" ) );
@ -166,11 +166,11 @@ public class HostTest
"ATT3 = VAL3";
res = host.update(new_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = host.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) );
assertTrue( host.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
assertTrue( host.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );

View File

@ -43,6 +43,8 @@ public class TemplateTest
private static String template_str =
"NAME = \"" + name + "\"\n" +
"CPU = \"1\"\n" +
"MEMORY = \"128\"\n" +
"ATT1 = \"VAL1\"\n" +
"ATT2 = \"VAL2\"";
@ -91,7 +93,7 @@ public class TemplateTest
template.delete();
res = Template.allocate(client, template_str);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
template = new Template(oid, client);
@ -112,7 +114,7 @@ public class TemplateTest
public void info()
{
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( template.getId().equals("0") );
// assertTrue( template.id() == 0 );
@ -123,7 +125,7 @@ public class TemplateTest
public void update()
{
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.xpath("TEMPLATE/ATT1").equals( "VAL1" ) );
assertTrue( template.xpath("TEMPLATE/ATT2").equals( "VAL2" ) );
@ -132,11 +134,11 @@ public class TemplateTest
"ATT3 = VAL3";
res = template.update(new_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.xpath("TEMPLATE/ATT1").equals( "" ) );
assertTrue( template.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
assertTrue( template.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );
@ -146,7 +148,7 @@ public class TemplateTest
public void publish()
{
res = template.publish();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
template.info();
assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") );
@ -156,7 +158,7 @@ public class TemplateTest
public void unpublish()
{
res = template.unpublish();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
template.info();
assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("0") );
@ -166,16 +168,16 @@ public class TemplateTest
public void chmod()
{
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
String owner_a = template.xpath("PERMISSIONS/OWNER_A");
String group_a = template.xpath("PERMISSIONS/GROUP_A");
res = template.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") );
assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") );
@ -192,13 +194,13 @@ public class TemplateTest
public void chmod_octet()
{
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.chmod(640);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("1") );
assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") );
@ -211,10 +213,10 @@ public class TemplateTest
assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") );
res = template.chmod("147");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") );
assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("0") );
@ -231,7 +233,7 @@ public class TemplateTest
public void attributes()
{
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( template.xpath("ID").equals("0") );
assertTrue( template.xpath("NAME").equals(name) );
@ -241,7 +243,7 @@ public class TemplateTest
public void delete()
{
res = template.delete();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( res.isError() );
@ -252,26 +254,26 @@ public class TemplateTest
{
// Create a new User and Group
res = User.allocate(client, "template_test_user", "password");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
int uid = Integer.parseInt(res.getMessage());
res = Group.allocate(client, "template_test_group");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
int gid = Integer.parseInt(res.getMessage());
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.uid() == 0 );
assertTrue( template.gid() == 0 );
res = template.chown(uid, gid);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.uid() == uid );
assertTrue( template.gid() == gid );
@ -279,7 +281,7 @@ public class TemplateTest
res = template.chgrp(0);
res = template.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( template.uid() == uid );
assertTrue( template.gid() == 0 );
@ -289,13 +291,13 @@ public class TemplateTest
public void instantiate()
{
res = template.instantiate("new_vm_name");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
int vm_id = Integer.parseInt(res.getMessage());
VirtualMachine vm = new VirtualMachine(vm_id, client);
res = vm.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( vm.getName().equals( "new_vm_name" ) );
}

View File

@ -136,10 +136,10 @@ public class UserTest
"ATT3 = VAL3";
res = user.update(new_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = user.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( user.xpath("TEMPLATE/ATT1").equals( "" ) );
assertTrue( user.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
assertTrue( user.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );

View File

@ -101,7 +101,7 @@ public class VirtualNetworkTest
// "NETWORK_ADDRESS = 192.168.0.0\n";
//
// res = VirtualNetwork.allocate(client, template);
// assertTrue( !res.isError() );
// assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( res.getMessage().equals("0") );
vnetPool.info();
@ -119,7 +119,7 @@ public class VirtualNetworkTest
public void info()
{
res = vnet.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( vnet.getId().equals("0") );
// assertTrue( vnet.id() == 0 );
@ -130,7 +130,7 @@ public class VirtualNetworkTest
public void attributes()
{
res = vnet.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
// assertTrue( vnet.xpath("ID").equals("0") );
assertTrue( vnet.xpath("NAME").equals(name) );
@ -141,7 +141,7 @@ public class VirtualNetworkTest
public void delete()
{
res = vnet.delete();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = vnet.info();
assertTrue( res.isError() );
@ -151,16 +151,16 @@ public class VirtualNetworkTest
public void addLeases()
{
res = VirtualNetwork.allocate(client, fixed_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
VirtualNetwork fixed_vnet =
new VirtualNetwork(Integer.parseInt(res.getMessage()), client);
res = fixed_vnet.addLeases("130.10.0.5");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = fixed_vnet.addLeases("130.10.0.6", "50:20:20:20:20:20");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = fixed_vnet.addLeases("130.10.0.6");
assertTrue( res.isError() );
@ -172,13 +172,13 @@ public class VirtualNetworkTest
public void rmLeases()
{
res = VirtualNetwork.allocate(client, fixed_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
VirtualNetwork fixed_vnet =
new VirtualNetwork(Integer.parseInt(res.getMessage()), client);
res = fixed_vnet.rmLeases("130.10.0.1");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = fixed_vnet.rmLeases("130.10.0.5");
assertTrue( res.isError() );
@ -190,19 +190,19 @@ public class VirtualNetworkTest
public void holdFixed()
{
res = VirtualNetwork.allocate(client, fixed_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
VirtualNetwork fixed_vnet =
new VirtualNetwork(Integer.parseInt(res.getMessage()), client);
res = fixed_vnet.hold("130.10.0.1");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = fixed_vnet.hold("130.10.0.5");
assertTrue( res.isError() );
res = fixed_vnet.release("130.10.0.1");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = fixed_vnet.release("130.10.0.1");
assertTrue( res.isError() );
@ -217,13 +217,13 @@ public class VirtualNetworkTest
public void holdRanged()
{
res = vnet.hold("192.168.0.10");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = vnet.hold("192.168.100.1");
assertTrue( res.isError() );
res = vnet.release("192.168.0.10");
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = vnet.release("192.168.0.10");
assertTrue( res.isError() );
@ -241,10 +241,10 @@ public class VirtualNetworkTest
"ATT3 = VAL3";
res = vnet.update(new_template);
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
res = vnet.info();
assertTrue( !res.isError() );
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( vnet.xpath("TEMPLATE/ATT1").equals( "" ) );
assertTrue( vnet.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
assertTrue( vnet.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );