You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Aleksandra Nowak <al...@man.poznan.pl> on 2016/11/25 15:32:57 UTC

how to test swift api in transient mode

Hi,
I'm trying to migrate my code to use jclouds 2.0.0. I changed from swift 
dependency to openstack-swift, so I use SwiftApi object to access Swift 
(instead of BlobStore which I used before). The code seems to look fine 
when I run it on a live cluster.

But I had unit tests that were using transient mode/container and now I 
cannot make them work.

I got:

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
   while locating org.jclouds.openstack.swift.v1.SwiftApi

Is transient mode still valid in 2.0? It is listed as possible 
"providerOrApi" in 
org.jclouds.ContextBuilder#newBuilder(java.lang.String). How to use it? 
There is no information about it on documentation pages, wheras it still 
claims that " Write your unit tests without mocking complexity or the 
brittleness of remote connections. Writing tests for cloud endpoints is 
difficult. jclouds provides you with Stub connections that simulate a 
cloud without creating network connections." (from 
http://jclouds.apache.org/start/what-is-jclouds/)

Thank you in advance,
Aleksandra


Re: how to test swift api in transient mode

Posted by Andrew Gaul <ga...@apache.org>.
[parallel discussion on Stack Overflow
https://stackoverflow.com/questions/40929969/transient-mode-for-unit-tests-with-jclouds-and-openstack-swift-doesnt-work ]

You can't create a SwiftApi view of a transient blobstore; instead you
must use the portable BlobStore view:

String provider = ...;  // openstack-swift or transient
BlobStoreContext context = ContextBuilder.newBuilder(provider)
            .endpoint(endpoint)
            .credentials(user, password)
            .buildApi(BlobStoreContext.class);
BlobStore blobStore = context.getBlobStore();
// interact with blobStore, e.g., get, put
...
context.close();

On Tue, Nov 29, 2016 at 03:00:00PM +0100, Aleksandra Nowak wrote:
> I had to switch (or I thought that I had to) because I wanted
> JClouds to take care of repeating PUT operations after a failure.
> And for now it looks like it helped for this issue.
> However, I would like to have junit test for this code.
> Before I used the same code but with "transient" as a provider.
> Now after changing dependency version to 2.0.0 it unit tests trow:
> 
> com.google.inject.ConfigurationException: Guice configuration errors:
> 
> 1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
>   while locating org.jclouds.openstack.swift.v1.SwiftApi
> 
> 
> The same piece of code works perfectly  when run with a live swift
> instance and "openstack-swift" as provider.
> Best,
> Aleksandra
> 
> W dniu 25.11.2016 o 20:03, Andrew Gaul pisze:
> >Aleksandra, you can use both openstack-swift and transient APIs via the
> >BlobStore interface.  You should only need to change the provider name
> >from swift to openstack-swift.
> >
> >On Fri, Nov 25, 2016 at 04:32:57PM +0100, Aleksandra Nowak wrote:
> >>Hi,
> >>I'm trying to migrate my code to use jclouds 2.0.0. I changed from
> >>swift dependency to openstack-swift, so I use SwiftApi object to
> >>access Swift (instead of BlobStore which I used before). The code
> >>seems to look fine when I run it on a live cluster.
> >>
> >>But I had unit tests that were using transient mode/container and
> >>now I cannot make them work.
> >>
> >>I got:
> >>
> >>com.google.inject.ConfigurationException: Guice configuration errors:
> >>
> >>1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
> >>   while locating org.jclouds.openstack.swift.v1.SwiftApi
> >>
> >>Is transient mode still valid in 2.0? It is listed as possible
> >>"providerOrApi" in
> >>org.jclouds.ContextBuilder#newBuilder(java.lang.String). How to use
> >>it? There is no information about it on documentation pages, wheras
> >>it still claims that " Write your unit tests without mocking
> >>complexity or the brittleness of remote connections. Writing tests
> >>for cloud endpoints is difficult. jclouds provides you with Stub
> >>connections that simulate a cloud without creating network
> >>connections." (from
> >>http://jclouds.apache.org/start/what-is-jclouds/)
> >>
> >>Thank you in advance,
> >>Aleksandra
> >>
> 

-- 
Andrew Gaul
http://gaul.org/

Re: how to test swift api in transient mode

Posted by Aleksandra Nowak <al...@man.poznan.pl>.
I had to switch (or I thought that I had to) because I wanted JClouds to 
take care of repeating PUT operations after a failure. And for now it 
looks like it helped for this issue.
However, I would like to have junit test for this code.
Before I used the same code but with "transient" as a provider.
Now after changing dependency version to 2.0.0 it unit tests trow:

com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
   while locating org.jclouds.openstack.swift.v1.SwiftApi


The same piece of code works perfectly  when run with a live swift 
instance and "openstack-swift" as provider.
Best,
Aleksandra

W dniu 25.11.2016 o 20:03, Andrew Gaul pisze:
> Aleksandra, you can use both openstack-swift and transient APIs via the
> BlobStore interface.  You should only need to change the provider name
> from swift to openstack-swift.
>
> On Fri, Nov 25, 2016 at 04:32:57PM +0100, Aleksandra Nowak wrote:
>> Hi,
>> I'm trying to migrate my code to use jclouds 2.0.0. I changed from
>> swift dependency to openstack-swift, so I use SwiftApi object to
>> access Swift (instead of BlobStore which I used before). The code
>> seems to look fine when I run it on a live cluster.
>>
>> But I had unit tests that were using transient mode/container and
>> now I cannot make them work.
>>
>> I got:
>>
>> com.google.inject.ConfigurationException: Guice configuration errors:
>>
>> 1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
>>    while locating org.jclouds.openstack.swift.v1.SwiftApi
>>
>> Is transient mode still valid in 2.0? It is listed as possible
>> "providerOrApi" in
>> org.jclouds.ContextBuilder#newBuilder(java.lang.String). How to use
>> it? There is no information about it on documentation pages, wheras
>> it still claims that " Write your unit tests without mocking
>> complexity or the brittleness of remote connections. Writing tests
>> for cloud endpoints is difficult. jclouds provides you with Stub
>> connections that simulate a cloud without creating network
>> connections." (from
>> http://jclouds.apache.org/start/what-is-jclouds/)
>>
>> Thank you in advance,
>> Aleksandra
>>


Re: how to test swift api in transient mode

Posted by Andrew Gaul <ga...@apache.org>.
Aleksandra, you can use both openstack-swift and transient APIs via the
BlobStore interface.  You should only need to change the provider name
from swift to openstack-swift.

On Fri, Nov 25, 2016 at 04:32:57PM +0100, Aleksandra Nowak wrote:
> Hi,
> I'm trying to migrate my code to use jclouds 2.0.0. I changed from
> swift dependency to openstack-swift, so I use SwiftApi object to
> access Swift (instead of BlobStore which I used before). The code
> seems to look fine when I run it on a live cluster.
> 
> But I had unit tests that were using transient mode/container and
> now I cannot make them work.
> 
> I got:
> 
> com.google.inject.ConfigurationException: Guice configuration errors:
> 
> 1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound.
>   while locating org.jclouds.openstack.swift.v1.SwiftApi
> 
> Is transient mode still valid in 2.0? It is listed as possible
> "providerOrApi" in
> org.jclouds.ContextBuilder#newBuilder(java.lang.String). How to use
> it? There is no information about it on documentation pages, wheras
> it still claims that " Write your unit tests without mocking
> complexity or the brittleness of remote connections. Writing tests
> for cloud endpoints is difficult. jclouds provides you with Stub
> connections that simulate a cloud without creating network
> connections." (from
> http://jclouds.apache.org/start/what-is-jclouds/)
> 
> Thank you in advance,
> Aleksandra
> 

-- 
Andrew Gaul
http://gaul.org/