Bump jclouds.version from 1.9.1 to 2.0.3 (#14746)

* Updates `org.apache.jclouds:*` from 1.9.1 to 2.0.3
* Pin jclouds to 2.0.x since 2.1.x requires Guava 18+
* replace easymock with mockito

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Xavier Léauté 2023-08-10 15:24:01 +02:00 committed by GitHub
parent 4b9846b90f
commit 37ed0f4a17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 53 deletions

View File

@ -18,3 +18,6 @@ updates:
# Even then this will involve significant effort. # Even then this will involve significant effort.
# See https://github.com/apache/druid/pull/12258 # See https://github.com/apache/druid/pull/12258
- dependency-name: "org.apache.calcite" - dependency-name: "org.apache.calcite"
# jclouds 2.1 needs Guava 18+
- dependency-name: "org.apache.jclouds"
versions: "[2.1,)"

View File

@ -35,10 +35,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jclouds.version>1.9.1</jclouds.version> <jclouds.version>2.0.0</jclouds.version>
<!-- The version of guice is forced to 3.0 since JClouds 1.9.1 does not
work with guice 4.0-beta -->
<guice.version>3.0</guice.version>
</properties> </properties>
<dependencies> <dependencies>
@ -151,8 +148,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.easymock</groupId> <groupId>org.mockito</groupId>
<artifactId>easymock</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -19,8 +19,6 @@
package org.apache.druid.storage.cloudfiles; package org.apache.druid.storage.cloudfiles;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -28,30 +26,35 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class CloudFilesByteSourceTest extends EasyMockSupport import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class CloudFilesByteSourceTest
{ {
@Test @Test
public void openStreamTest() throws IOException public void openStreamTest() throws IOException
{ {
final String path = "path"; final String path = "path";
CloudFilesObjectApiProxy objectApi = createMock(CloudFilesObjectApiProxy.class); CloudFilesObjectApiProxy objectApi = mock(CloudFilesObjectApiProxy.class);
CloudFilesObject cloudFilesObject = createMock(CloudFilesObject.class); CloudFilesObject cloudFilesObject = mock(CloudFilesObject.class);
Payload payload = createMock(Payload.class); Payload payload = mock(Payload.class);
InputStream stream = createMock(InputStream.class); InputStream stream = mock(InputStream.class);
EasyMock.expect(objectApi.get(path, 0)).andReturn(cloudFilesObject); when(objectApi.get(path, 0)).thenReturn(cloudFilesObject);
EasyMock.expect(cloudFilesObject.getPayload()).andReturn(payload); when(cloudFilesObject.getPayload()).thenReturn(payload);
EasyMock.expect(payload.openStream()).andReturn(stream); when(payload.openStream()).thenReturn(stream);
payload.close(); payload.close();
replayAll();
CloudFilesByteSource byteSource = new CloudFilesByteSource(objectApi, path); CloudFilesByteSource byteSource = new CloudFilesByteSource(objectApi, path);
Assert.assertEquals(stream, byteSource.openStream()); Assert.assertEquals(stream, byteSource.openStream());
byteSource.closeStream(); byteSource.closeStream();
verifyAll(); verify(objectApi).get(path, 0);
verify(cloudFilesObject).getPayload();
verify(payload).openStream();
} }
@Test() @Test()
@ -59,18 +62,17 @@ public class CloudFilesByteSourceTest extends EasyMockSupport
{ {
final String path = "path"; final String path = "path";
CloudFilesObjectApiProxy objectApi = createMock(CloudFilesObjectApiProxy.class); CloudFilesObjectApiProxy objectApi = mock(CloudFilesObjectApiProxy.class);
CloudFilesObject cloudFilesObject = createMock(CloudFilesObject.class); CloudFilesObject cloudFilesObject = mock(CloudFilesObject.class);
Payload payload = createMock(Payload.class); Payload payload = mock(Payload.class);
InputStream stream = createMock(InputStream.class); InputStream stream = mock(InputStream.class);
EasyMock.expect(objectApi.get(path, 0)).andReturn(cloudFilesObject); when(objectApi.get(path, 0)).thenReturn(cloudFilesObject);
EasyMock.expect(cloudFilesObject.getPayload()).andReturn(payload); when(cloudFilesObject.getPayload()).thenReturn(payload);
EasyMock.expect(payload.openStream()).andThrow(new IOException()).andReturn(stream); when(payload.openStream()).thenThrow(new IOException())
.thenReturn(stream);
payload.close(); payload.close();
replayAll();
CloudFilesByteSource byteSource = new CloudFilesByteSource(objectApi, path); CloudFilesByteSource byteSource = new CloudFilesByteSource(objectApi, path);
try { try {
byteSource.openStream(); byteSource.openStream();
@ -82,6 +84,8 @@ public class CloudFilesByteSourceTest extends EasyMockSupport
Assert.assertEquals(stream, byteSource.openStream()); Assert.assertEquals(stream, byteSource.openStream());
byteSource.closeStream(); byteSource.closeStream();
verifyAll(); verify(objectApi).get(path, 0);
verify(cloudFilesObject).getPayload();
verify(payload, times(2)).openStream();
} }
} }

View File

@ -24,7 +24,6 @@ import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.NoneShardSpec; import org.apache.druid.timeline.partition.NoneShardSpec;
import org.easymock.EasyMock;
import org.jclouds.openstack.swift.v1.features.ObjectApi; import org.jclouds.openstack.swift.v1.features.ObjectApi;
import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi; import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;
import org.junit.Assert; import org.junit.Assert;
@ -36,6 +35,12 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/** /**
*/ */
public class CloudFilesDataSegmentPusherTest public class CloudFilesDataSegmentPusherTest
@ -46,16 +51,12 @@ public class CloudFilesDataSegmentPusherTest
@Test @Test
public void testPush() throws Exception public void testPush() throws Exception
{ {
ObjectApi objectApi = EasyMock.createStrictMock(ObjectApi.class); ObjectApi objectApi = mock(ObjectApi.class);
EasyMock.expect(objectApi.put(EasyMock.anyString(), EasyMock.anyObject())).andReturn(null).atLeastOnce(); when(objectApi.put(any(), any())).thenReturn(null);
EasyMock.replay(objectApi);
CloudFilesApi api = EasyMock.createStrictMock(CloudFilesApi.class);
EasyMock.expect(api.getObjectApi(EasyMock.anyString(), EasyMock.anyString()))
.andReturn(objectApi)
.atLeastOnce();
EasyMock.replay(api);
CloudFilesApi api = mock(CloudFilesApi.class);
when(api.getObjectApi(any(), any()))
.thenReturn(objectApi);
CloudFilesDataSegmentPusherConfig config = new CloudFilesDataSegmentPusherConfig(); CloudFilesDataSegmentPusherConfig config = new CloudFilesDataSegmentPusherConfig();
config.setRegion("region"); config.setRegion("region");
@ -87,6 +88,7 @@ public class CloudFilesDataSegmentPusherTest
Assert.assertEquals(segmentToPush.getSize(), segment.getSize()); Assert.assertEquals(segmentToPush.getSize(), segment.getSize());
EasyMock.verify(api); verify(objectApi, atLeastOnce()).put(any(), any());
verify(api, atLeastOnce()).getObjectApi(any(), any());
} }
} }

View File

@ -19,8 +19,6 @@
package org.apache.druid.storage.cloudfiles; package org.apache.druid.storage.cloudfiles;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.openstack.swift.v1.domain.SwiftObject; import org.jclouds.openstack.swift.v1.domain.SwiftObject;
import org.jclouds.openstack.swift.v1.features.ObjectApi; import org.jclouds.openstack.swift.v1.features.ObjectApi;
@ -28,7 +26,11 @@ import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class CloudFilesObjectApiProxyTest extends EasyMockSupport import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class CloudFilesObjectApiProxyTest
{ {
@Test @Test
public void getTest() public void getTest()
@ -37,16 +39,14 @@ public class CloudFilesObjectApiProxyTest extends EasyMockSupport
final String region = "region"; final String region = "region";
final String container = "container"; final String container = "container";
CloudFilesApi cloudFilesApi = createMock(CloudFilesApi.class); CloudFilesApi cloudFilesApi = mock(CloudFilesApi.class);
ObjectApi objectApi = createMock(ObjectApi.class); ObjectApi objectApi = mock(ObjectApi.class);
SwiftObject swiftObject = createMock(SwiftObject.class); SwiftObject swiftObject = mock(SwiftObject.class);
Payload payload = createMock(Payload.class); Payload payload = mock(Payload.class);
EasyMock.expect(cloudFilesApi.getObjectApi(region, container)).andReturn(objectApi); when(cloudFilesApi.getObjectApi(region, container)).thenReturn(objectApi);
EasyMock.expect(objectApi.get(path)).andReturn(swiftObject); when(objectApi.get(path)).thenReturn(swiftObject);
EasyMock.expect(swiftObject.getPayload()).andReturn(payload); when(swiftObject.getPayload()).thenReturn(payload);
replayAll();
CloudFilesObjectApiProxy cfoApiProxy = new CloudFilesObjectApiProxy(cloudFilesApi, region, container); CloudFilesObjectApiProxy cfoApiProxy = new CloudFilesObjectApiProxy(cloudFilesApi, region, container);
CloudFilesObject cloudFilesObject = cfoApiProxy.get(path, 0); CloudFilesObject cloudFilesObject = cfoApiProxy.get(path, 0);
@ -56,6 +56,8 @@ public class CloudFilesObjectApiProxyTest extends EasyMockSupport
Assert.assertEquals(cloudFilesObject.getContainer(), container); Assert.assertEquals(cloudFilesObject.getContainer(), container);
Assert.assertEquals(cloudFilesObject.getPath(), path); Assert.assertEquals(cloudFilesObject.getPath(), path);
verifyAll(); verify(cloudFilesApi).getObjectApi(region, container);
verify(objectApi).get(path);
verify(swiftObject).getPayload();
} }
} }