Skip to content
Browse files

adding a test for the image description

optimization on fetching decription info

fixing bug in option setting
  • Loading branch information...
1 parent 9b9a4eb commit 81e06576c60e6a1a85feb7b6bf5ede6ab25ed8e7 @buzztroll buzztroll committed Sep 27, 2011
View
2 service/client/java/source/src/org/globus/workspace/cloud/client/Opts.java
@@ -171,7 +171,7 @@
public static final String IMAGE_DESC_OPT_STRING = "imagedesc";
public final Option IMAGE_DESC_OPT =
- OptionBuilder.withLongOpt(IMAGE_DESC_OPT_STRING).create();
+ OptionBuilder.hasArg().withLongOpt(IMAGE_DESC_OPT_STRING).create();
public static final String NOSPINNER_OPT_STRING = "nospinner";
public final Option NOSPINNER_OPT =
View
18 service/client/java/source/src/org/globus/workspace/cloud/client/util/CumulusTask.java
@@ -976,9 +976,9 @@ public String getImagePath(
ArrayList files = new ArrayList();
// first get all of this users objects
S3Object[] usersVMs = s3Service.listObjects(baseBucketName, keyName, "", 1000);
- s3ObjToFileList(files, usersVMs, true);
+ s3ObjToFileList(files, usersVMs, true, s3Service);
S3Object[] VMs = s3Service.listObjects(baseBucketName, this.makeKey("", "common"), "", 1000);
- s3ObjToFileList(files, VMs, false);
+ s3ObjToFileList(files, VMs, false, s3Service);
return (FileListing[]) files.toArray(new FileListing[files.size()]);
}
@@ -992,13 +992,12 @@ public String getImagePath(
}
}
- private String s3DownloadImageDescription(String name, boolean rw)
+ private String s3DownloadImageDescription(String name, boolean rw, S3Service s3Service)
throws ExecutionProblem
{
String description = null;
String descriptionName = name + this.descSuffix;
- S3Service s3Service = null;
-
+
try
{
String baseBucketName = this.args.getS3Bucket();
@@ -1027,18 +1026,15 @@ private String s3DownloadImageDescription(String name, boolean rw)
{
//throw new ExecutionProblem(s3ex.toString());
}
- finally
- {
- this.shutdownService(s3Service);
- }
return description;
}
private void s3ObjToFileList(
ArrayList files,
S3Object [] s3Objs,
- boolean rw)
+ boolean rw,
+ S3Service s3Service)
throws ExecutionProblem
{
Calendar cal = Calendar.getInstance();
@@ -1064,7 +1060,7 @@ private void s3ObjToFileList(
fl.setReadWrite(rw);
fl.setOwner(s3Objs[i].getOwner().getDisplayName());
- String desc = this.s3DownloadImageDescription(name, rw);
+ String desc = this.s3DownloadImageDescription(name, rw, s3Service);
fl.setDescription(desc);
files.add(fl);
View
48 tests/cc-list-desc-test.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+import pexpect
+import sys
+import os
+import uuid
+
+tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
+tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
+
+to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
+cc_home=os.environ['CLOUD_CLIENT_HOME']
+logfile = sys.stdout
+
+(x, rc)=pexpect.run("%s/bin/cloud-client.sh --delete --name %s" % (cc_home, tst_image_name), withexitstatus=1)
+print x
+
+image_description = "Hello Worl Nimbus %s" % (str(uuid.uuid4()))
+cmd = "%s/bin/cloud-client.sh --imagedesc %s --transfer --sourcefile %s" % (cc_home, image_description, tst_image_src)
+(x, rc)=pexpect.run(cmd, withexitstatus=1)
+print x
+if rc != 0:
+ print "failed to transfer"
+ sys.exit(1)
+
+cmd = "%s/bin/cloud-client.sh --list" % (cc_home)
+child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
+rc = child.expect (tst_image_name)
+if rc != 0:
+ print "%s not found in the list" % (tst_image_name)
+ sys.exit(1)
+print child.before
+rc = child.expect(image_description)
+if rc != 0:
+ print "%s not found in the list" % (image_description)
+ sys.exit(1)
+rc = child.expect(pexpect.EOF)
+print child.before
+if rc != 0:
+ print "failed to list"
+ sys.exit(1)
+
+(x, rc)=pexpect.run("%s/bin/cloud-client.sh --delete --name %s" % (cc_home, tst_image_name) , withexitstatus=1)
+print x
+if rc != 0:
+ print "failed to delete"
+ sys.exit(1)
+sys.exit(0)

0 comments on commit 81e0657

Please sign in to comment.
Something went wrong with that request. Please try again.