You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Zack Shoylev <no...@github.com> on 2013/07/04 06:18:48 UTC
[jclouds-labs-openstack] Makes the trove live tests robust (#12)
You can merge this Pull Request by running:
git pull https://github.com/rackerlabs/jclouds-labs-openstack trove-helper
Or you can view, comment on it, or merge it online at:
https://github.com/jclouds/jclouds-labs-openstack/pull/12
-- Commit Summary --
* Makes the trove live tests robust
-- File Changes --
M openstack-trove/pom.xml (3)
M openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/DatabaseApiLiveTest.java (20)
M openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/InstanceApiLiveTest.java (15)
M openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/UserApiLiveTest.java (22)
M openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/BaseTroveApiExpectTest.java (2)
A openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/TroveHelper.java (110)
A openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/TroveHelperExpectTest.java (66)
A openstack-trove/src/test/resources/instance_get_bad_instance.json (37)
M rackspace-clouddatabases-uk/pom.xml (4)
M rackspace-clouddatabases-us/pom.xml (4)
-- Patch Links --
https://github.com/jclouds/jclouds-labs-openstack/pull/12.patch
https://github.com/jclouds/jclouds-labs-openstack/pull/12.diff
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
sleepUninterruptibly seems to work fine.. done with changes unless more comments. Thanks!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774999
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
Looks good to me! Thanks, @zack-shoylev !
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20805212
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #193](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/193/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20775098
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #164](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/164/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20458477
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #13](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/13/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20700827
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #171](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/171/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20638052
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #192](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/192/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774767
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> +
> + public Instance getWorkingInstance(String zone) {
> + return getWorkingInstance(zone, UUID.randomUUID().toString(), "1", 1);
> + }
> +
> + private Instance awaitAvailable(Instance instance, InstanceApi iapi) {
> + for (int n = 0; n < 40; n = n + 1) {
> + Instance updatedInstance = iapi.get(instance.getId());
> + if (updatedInstance.getStatus() == Instance.Status.ACTIVE)
> + return updatedInstance;
> + if (updatedInstance.getStatus() == Instance.Status.UNRECOGNIZED)
> + return null; // fast fail
> + try {
> + Thread.sleep(15000);
> + } catch (InterruptedException e) {
> + logger.info(e.getStackTrace().toString());
Info or warn..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5111710
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
> + return getWorkingInstance(zone, UUID.randomUUID().toString(), "1", 1);
> + }
> +
> + private Instance awaitAvailable(Instance instance, InstanceApi iapi) {
> + for (int n = 0; n < 40; n = n + 1) {
> + Instance updatedInstance = iapi.get(instance.getId());
> + if (updatedInstance.getStatus() == Instance.Status.ACTIVE)
> + return updatedInstance;
> + if (updatedInstance.getStatus() == Instance.Status.UNRECOGNIZED)
> + return null; // fast fail
> + try {
> + Thread.sleep(15000);
> + } catch (InterruptedException e) {
> + logger.info(e.getStackTrace().toString());
> + }
> + }
This is only after the last loop iteration, which should only happen on a timeout. Timeout here is supposed to be very much an edge case - we expect the instance to become either available or error out within a few minutes.
The sleep is needed between status retries.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5127442
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> + return getWorkingInstance(zone, UUID.randomUUID().toString(), "1", 1);
> + }
> +
> + private Instance awaitAvailable(Instance instance, InstanceApi iapi) {
> + for (int n = 0; n < 40; n = n + 1) {
> + Instance updatedInstance = iapi.get(instance.getId());
> + if (updatedInstance.getStatus() == Instance.Status.ACTIVE)
> + return updatedInstance;
> + if (updatedInstance.getStatus() == Instance.Status.UNRECOGNIZED)
> + return null; // fast fail
> + try {
> + Thread.sleep(15000);
> + } catch (InterruptedException e) {
> + logger.info(e.getStackTrace().toString());
> + }
> + }
Why are we waiting before returning `null`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5111725
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> +
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
Would `TroveInstanceHelper` be more specific, or is this class also doing other things?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5069904
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> + * @param size
> + * Size of the instance
> + * @return Instance object in active state or NULL
> + */
> + public Instance getWorkingInstance(String zone, String name, String flavorId, int size) {
> + InstanceApi instanceApi = api.getInstanceApiForZone(zone);
> + for (int retries = 0; retries < 10; retries++) {
> + Instance instance = null;
> + try {
> + instance = instanceApi.create(flavorId, size, name);
> + } catch (Exception e) {
> +
> + try {
> + Thread.sleep(50);
> + } catch (InterruptedException ie) {
> + }
Any comments on this try block? What is it for? And is there a "sleepUninterruptibly" call somewhere? If not, name the InterruptedException `ignored` or something like that..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5111544
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Everett Toews <no...@github.com>.
Closed #12.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
> +
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
One possible such feature is creating a loadbalancer for a set of new instances.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5076612
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #16](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/16/) FAILURE
Looks like there's a problem with this pull request
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774280
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> + try {
> + Thread.sleep(50);
> + } catch (InterruptedException ie) {
> + }
> +
> + logger.error(e.getStackTrace().toString());
> + continue;
> + }
> +
> + Instance updatedInstance = awaitAvailable(instance, instanceApi);
> + if (updatedInstance == null) {
> + instanceApi.delete(instance.getId());
> + InstancePredicates.awaitDeleted(instanceApi).apply(instance);
> + continue;
> + }
> + return updatedInstance;
Just a style thing, but would it read more easily if the "exit case" were more explicit? I.e.
```
if (updatedInstance != null) {
return updatedInstance;
}
instanceApi.delete(instance.getId());
InstancePredicates.awaitDeleted(instanceApi).apply(instance);
...
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5111681
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
Updated with small fixes
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20773863
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #15](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/15/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774286
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #180](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/180/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20700747
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Everett Toews <no...@github.com>.
Merged.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20971274
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #17](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/17/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774916
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
> + * @param size
> + * Size of the instance
> + * @return Instance object in active state or NULL
> + */
> + public Instance getWorkingInstance(String zone, String name, String flavorId, int size) {
> + InstanceApi instanceApi = api.getInstanceApiForZone(zone);
> + for (int retries = 0; retries < 10; retries++) {
> + Instance instance = null;
> + try {
> + instance = instanceApi.create(flavorId, size, name);
> + } catch (Exception e) {
> +
> + try {
> + Thread.sleep(50);
> + } catch (InterruptedException ie) {
> + }
Supposedly guava has sleepUninterruptibly. I have not used it before.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5127578
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #18](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/18/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20775183
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
> +
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
Left it open-ended in case (somewhat plausible) I add more similar functionality to it.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5076572
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #4](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/4/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20638120
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #191](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/191/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774507
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> @@ -47,12 +50,12 @@
> @BeforeClass(groups = { "integration", "live" })
> public void setup() {
> super.setup();
> + TroveUtils helper = new TroveUtils(api);
This doesn't need to be changed, just a small comment...the variable here (and elsewhere) is still named `helper`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5111756
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
https://issues.apache.org/jira/browse/JCLOUDS-140
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20839973
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
> + private TroveApi api = null;
Is the `null` init needed? And could this be `final`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5069892
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-openstack #190](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/190/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20774148
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #3](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/3/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12#issuecomment-20458515
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Andrew Phillips <no...@github.com>.
> +
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
> Left it open-ended in case
Fine!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5096144
Re: [jclouds-labs-openstack] Makes the trove live tests robust (#12)
Posted by Zack Shoylev <no...@github.com>.
> +
> +import javax.annotation.Resource;
> +
> +import org.jclouds.openstack.trove.v1.TroveApi;
> +import org.jclouds.openstack.trove.v1.domain.Instance;
> +import org.jclouds.openstack.trove.v1.features.InstanceApi;
> +import org.jclouds.openstack.trove.v1.predicates.InstancePredicates;
> +import org.jclouds.logging.Logger;
> +
> +/**
> + * @author Zack Shoylev
> + *
> + * Helper methods for dealing with instances that get created with
> + * errors
> + */
> +public class TroveHelper {
Ah excellent... yes Utils is way better
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/12/files#r5099301