Repository navigation
Conversation
| return systemEnv(ALIYUN_TEST_OSS_KEY_PREFIX); | ||
| } | ||
|
|
||
| private static String systemEnv(String name) { |
There was a problem hiding this comment.
nit: seems a bit unnecessary to have an additional method just to wrap System.getenv and perform no additional action.
openinx
left a comment
There was a problem hiding this comment.
Looks like we will need to set few attributions for the AliyunOSSMockRule when constructing the mock rule by testRule = AliyunOSSMockRule.builder().silent().build(); in here https://github.com/apache/iceberg/pull/3596/files#diff-3062807bde819a7913ca06f9e5a400aa27187f4fdac49bcf2d33b72dc2adba64R59
Will the system environment variable ALIYUN_TEST_OSS_TEST_RULE_CLASS also work for the AliyunOSSMockRule ?
| public class AliyunOSSTestUtility { | ||
| private static final Logger LOG = LoggerFactory.getLogger(AliyunOSSTestUtility.class); | ||
| private static final String ALIYUN_TEST_OSS_TEST_RULE_CLASS = "ALIYUN_TEST_OSS_TEST_RULE_CLASS"; | ||
| public class AliyunTestUtility { |
There was a problem hiding this comment.
If this utility is not only for aliyun OSS, then I think it's better to move this class out of the oss package org.apache.iceberg.aliyun.oss ? maybe org.apache.iceberg.aliyun is a better choice ?
| return testRule; | ||
| } | ||
|
|
||
| public static String testOSSEndpoint() { |
There was a problem hiding this comment.
Nit: do we still need the test prefix for the method names ? I see it is already in an AliyunTestUtility.
| ObjectListing objectListing = ossClient().listObjects( | ||
| new ListObjectsRequest(bucket) | ||
| .withPrefix(keyPrefix) | ||
| ); |
There was a problem hiding this comment.
I think this don't list all the objects in the given bucket with the specific keyPreifx actually because the oss list objects API will truncate the list into pages automatically. Pls read the document: https://partners-intl.aliyun.com/help/doc-detail/91923.htm
|
|
@xingbowu, did all the test cases run correctly in your local env ? I tried to verify all the test cases by using the integration test rule by exporting the following environment variables, and find there are many broken cases: |
| private static final String ALIYUN_TEST_OSS_TEST_RULE_CLASS = "ALIYUN_TEST_OSS_TEST_RULE_CLASS"; | ||
| public class AliyunTestUtility { | ||
| private static final Logger LOG = LoggerFactory.getLogger(AliyunTestUtility.class); | ||
| private static final String ALIYUN_TEST_OSS_RULE_CLASS = "ALIYUN_TEST_OSS_TEST_RULE_CLASS"; |
There was a problem hiding this comment.
Why not just use the same name as the assigned value directly ?
| private static final String ALIYUN_TEST_OSS_ENDPOINT = "ALIYUN_TEST_OSS_ENDPOINT"; | ||
| private static final String ALIYUN_TEST_ACCESS_KEY_ID = "ALIYUN_TEST_ACCESS_KEY_ID"; | ||
| private static final String ALIYUN_TEST_ACCESS_KEY_SECRET = "ALIYUN_TEST_ACCESS_KEY_SECRET"; | ||
| private static final String ALIYUN_TEST_BUCKET_NAME = "ALIYUN_TEST_BUCKET"; |
There was a problem hiding this comment.
Nit: It's better to rename it as ALIYUN_TEST_OSS_BUCKET_NAME because the bucket is only used for aliyun oss service.
| return System.getenv(ALIYUN_TEST_ACCESS_KEY_SECRET); | ||
| } | ||
|
|
||
| public static String bucketName() { |
There was a problem hiding this comment.
Similar thing, pls add the prefix oss.
| if (lazyClient == null) { | ||
| synchronized (OSSIntegrationTestRule.class) { | ||
| if (lazyClient == null) { |
There was a problem hiding this comment.
Here if we are assuming that there will may be multiple threads to access the lazyClient, then the lazyClient must be declared as a volatile variable, otherwise other thread may use the cache value of lazyClient which is not stale when checking the nullable condition.
|
|
||
| @ClassRule | ||
| public static final AliyunOSSTestRule OSS_TEST_RULE = AliyunOSSTestUtility.initialize(); | ||
| public static final AliyunOSSTestRule OSS_TEST_RULE = AliyunOSSMockRule.builder().silent().build(); |
There was a problem hiding this comment.
I guess you changed this because you are trying to address the test issue:
export ALIYUN_TEST_OSS_TEST_RULE_CLASS=org.apache.iceberg.aliyun.oss.OSSIntegrationTestRule
export ALIYUN_TEST_BUCKET=iceberg-test
export ALIYUN_TEST_ACCESS_KEY_ID=******
export ALIYUN_TEST_ACCESS_KEY_SECRET=******
export ALIYUN_TEST_OSS_WAREHOUSE=oss://iceberg-test/ci
export ALIYUN_TEST_OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com
./gradlew iceberg-aliyun:test
The broken test:
> Task :iceberg-aliyun:test
org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS > testDeleteBucket FAILED
com.aliyun.oss.OSSException: The bucket has objects. Please delete them first.
[ErrorCode]: BucketNotEmpty
[RequestId]: 61AED497E868B3353408ACE8
[HostId]: iceberg-test.oss-cn-hangzhou.aliyuncs.com
[ResponseError]:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>BucketNotEmpty</Code>
<Message>The bucket has objects. Please delete them first.</Message>
<RequestId>61AED497E868B3353408ACE8</RequestId>
<HostId>iceberg-test.oss-cn-hangzhou.aliyuncs.com</HostId>
<BucketName>iceberg-test</BucketName>
</Error>
at com.aliyun.oss.common.utils.ExceptionFactory.createOSSException(ExceptionFactory.java:100)
at com.aliyun.oss.internal.OSSErrorResponseHandler.handle(OSSErrorResponseHandler.java:70)
at com.aliyun.oss.common.comm.ServiceClient.handleResponse(ServiceClient.java:257)
at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:140)
at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:70)
at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:83)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:145)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:102)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:97)
at com.aliyun.oss.internal.OSSBucketOperation.deleteBucket(OSSBucketOperation.java:231)
at com.aliyun.oss.OSSClient.deleteBucket(OSSClient.java:352)
at com.aliyun.oss.OSSClient.deleteBucket(OSSClient.java:347)
at org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS.testDeleteBucket(TestLocalAliyunOSS.java:100)
org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS > testBuckets FAILED
com.aliyun.oss.OSSException: The bucket has objects. Please delete them first.
[ErrorCode]: BucketNotEmpty
[RequestId]: 61AED497D5C0693231492A8B
[HostId]: iceberg-test.oss-cn-hangzhou.aliyuncs.com
[ResponseError]:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>BucketNotEmpty</Code>
<Message>The bucket has objects. Please delete them first.</Message>
<RequestId>61AED497D5C0693231492A8B</RequestId>
<HostId>iceberg-test.oss-cn-hangzhou.aliyuncs.com</HostId>
<BucketName>iceberg-test</BucketName>
</Error>
at com.aliyun.oss.common.utils.ExceptionFactory.createOSSException(ExceptionFactory.java:100)
at com.aliyun.oss.internal.OSSErrorResponseHandler.handle(OSSErrorResponseHandler.java:70)
at com.aliyun.oss.common.comm.ServiceClient.handleResponse(ServiceClient.java:257)
at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:140)
at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:70)
at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:83)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:145)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:102)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:97)
at com.aliyun.oss.internal.OSSBucketOperation.deleteBucket(OSSBucketOperation.java:231)
at com.aliyun.oss.OSSClient.deleteBucket(OSSClient.java:352)
at com.aliyun.oss.OSSClient.deleteBucket(OSSClient.java:347)
at org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS.testBuckets(TestLocalAliyunOSS.java:75)
org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS > testPutObject FAILED
org.junit.ComparisonFailure: expected:<6[e796fee4afcb1ce49f17ad8e214d]996> but was:<6[E796FEE4AFCB1CE49F17AD8E214D]996>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.junit.Assert.assertEquals(Assert.java:146)
at org.apache.iceberg.aliyun.oss.mock.TestLocalAliyunOSS.testPutObject(TestLocalAliyunOSS.java:115)
37 tests completed, 3 failed
But I think the correct approach to address this issue is change the way to design the unit tests, rather than making the test class only works for AliyunOSSMockRule. In other words, we need to make this test class works fine for both OSSIntegrationTestRule and AliyunOSSMockRule because we need to guarantee the same semantics between the aliyun oss and mock oss app.
|
@xingbowu currently is busying for other things now, let me pick this up. |
|
Closed via #3687. |



No description provided.