Skip to content

Conversation

zhouaoe
Copy link
Contributor

@zhouaoe zhouaoe commented Jul 31, 2024

Description of PR

How was this patch tested?

New unit tests; cloud store tests

For code changes:

  • Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 11m 47s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 45m 5s trunk passed
+1 💚 compile 0m 28s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 compile 0m 27s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 checkstyle 0m 27s trunk passed
+1 💚 mvnsite 0m 32s trunk passed
+1 💚 javadoc 0m 33s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 30s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 48s trunk passed
+1 💚 shadedclient 33m 44s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 20s the patch passed
+1 💚 compile 0m 19s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javac 0m 19s the patch passed
+1 💚 compile 0m 17s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 javac 0m 17s the patch passed
+1 💚 blanks 0m 1s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 15s /results-checkstyle-hadoop-tools_hadoop-aliyun.txt hadoop-tools/hadoop-aliyun: The patch generated 15 new + 0 unchanged - 0 fixed = 15 total (was 0)
+1 💚 mvnsite 0m 21s the patch passed
+1 💚 javadoc 0m 21s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 18s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 45s the patch passed
+1 💚 shadedclient 33m 34s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 23s hadoop-aliyun in the patch passed.
+1 💚 asflicense 0m 38s The patch does not generate ASF License warnings.
133m 53s
Subsystem Report/Notes
Docker ClientAPI=1.46 ServerAPI=1.46 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/1/artifact/out/Dockerfile
GITHUB PR #6967
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux f740b5f6e52a 5.15.0-106-generic #116-Ubuntu SMP Wed Apr 17 09:17:56 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / b672ebc
Default Java Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/1/testReport/
Max. process+thread count 704 (vs. ulimit of 5500)
modules C: hadoop-tools/hadoop-aliyun U: hadoop-tools/hadoop-aliyun
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/1/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

Copy link

@masteryhx masteryhx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.
PTAL my comments.
@steveloughran Kindly ping. Could you also help to take a look ? Thanks.

}
}

private void constructOssClient(Configuration conf) throws IOException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid repeating these codes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such as is done in AliyunOSSTestUtils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,I will simplify the code.

@@ -147,6 +147,13 @@ public void initialize(URI uri, Configuration conf, String user,
throw new IllegalArgumentException(msg);
}

boolean redirectEnable = conf.getBoolean(REDIRECT_ENABLE_KEY,
REDIRECT_ENABLE_DEFAULT);
if (!redirectEnable) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just use clientConf.setRedirectEnable(redirectEnable); ?
Current implementation always assumes true is default for clientConf, right ?

Copy link
Contributor Author

@zhouaoe zhouaoe Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 I will simplify the code to clientConf.setRedirectEnable(redirectEnable)
2 yes,the OSS SDK defaults the redirect setting to true

Copy link
Contributor

@steveloughran steveloughran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to review how other Ailyun integration tests are binding...they should all have the prefix ITest to make clear they are integration tests to only run in a mvn verify target

REDIRECT_ENABLE_DEFAULT);
if (!redirectEnable) {
clientConf.setRedirectEnable(false);
LOG.info("oss redirectEnable closed");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log at debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the log level to debug in the next commit


package org.apache.hadoop.fs.aliyun.oss;

import org.apache.commons.lang3.StringUtils;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: import ordering, especially keeping apache stuff on their own

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: import ordering, especially keeping apache stuff on their own

OK. I will optimize the import ordering

}
}

private void constructOssClient(Configuration conf) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such as is done in AliyunOSSTestUtils

@zhouaoe
Copy link
Contributor Author

zhouaoe commented Sep 2, 2024

I think we need to review how other Ailyun integration tests are binding...they should all have the prefix ITest to make clear they are integration tests to only run in a mvn verify target

Currently, none of the OSS test cases have the ITest prefix. I'm not sure about the historical reasons, and I may need to discuss this with other colleagues on the Aliyun OSS team. Can this PR be considered separately from the changes to add the ITest prefix?

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 12m 15s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 46m 29s trunk passed
+1 💚 compile 0m 27s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 compile 0m 26s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 checkstyle 0m 26s trunk passed
+1 💚 mvnsite 0m 29s trunk passed
+1 💚 javadoc 0m 31s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 27s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 44s trunk passed
+1 💚 shadedclient 34m 23s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 19s the patch passed
+1 💚 compile 0m 20s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javac 0m 20s the patch passed
+1 💚 compile 0m 18s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 javac 0m 18s the patch passed
-1 ❌ blanks 0m 0s /blanks-eol.txt The patch has 4 line(s) that end in blanks. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
-0 ⚠️ checkstyle 0m 14s /results-checkstyle-hadoop-tools_hadoop-aliyun.txt hadoop-tools/hadoop-aliyun: The patch generated 5 new + 0 unchanged - 0 fixed = 5 total (was 0)
+1 💚 mvnsite 0m 20s the patch passed
+1 💚 javadoc 0m 19s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 19s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 47s the patch passed
+1 💚 shadedclient 34m 0s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 21s hadoop-aliyun in the patch passed.
+1 💚 asflicense 0m 35s The patch does not generate ASF License warnings.
136m 33s
Subsystem Report/Notes
Docker ClientAPI=1.47 ServerAPI=1.47 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/2/artifact/out/Dockerfile
GITHUB PR #6967
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux c099904aa814 5.15.0-117-generic #127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / c195866
Default Java Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/2/testReport/
Max. process+thread count 627 (vs. ulimit of 5500)
modules C: hadoop-tools/hadoop-aliyun U: hadoop-tools/hadoop-aliyun
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/2/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 30s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 44m 39s trunk passed
+1 💚 compile 0m 29s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 compile 0m 28s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 checkstyle 0m 28s trunk passed
+1 💚 mvnsite 0m 32s trunk passed
+1 💚 javadoc 0m 33s trunk passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 30s trunk passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 47s trunk passed
+1 💚 shadedclient 33m 25s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 20s the patch passed
+1 💚 compile 0m 19s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javac 0m 19s the patch passed
+1 💚 compile 0m 17s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 javac 0m 17s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 16s /results-checkstyle-hadoop-tools_hadoop-aliyun.txt hadoop-tools/hadoop-aliyun: The patch generated 5 new + 0 unchanged - 0 fixed = 5 total (was 0)
+1 💚 mvnsite 0m 21s the patch passed
+1 💚 javadoc 0m 20s the patch passed with JDK Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04
+1 💚 javadoc 0m 19s the patch passed with JDK Private Build-1.8.0_422-8u422-b05-1~20.04-b05
+1 💚 spotbugs 0m 46s the patch passed
+1 💚 shadedclient 33m 46s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 22s hadoop-aliyun in the patch passed.
+1 💚 asflicense 0m 38s The patch does not generate ASF License warnings.
122m 10s
Subsystem Report/Notes
Docker ClientAPI=1.47 ServerAPI=1.47 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/4/artifact/out/Dockerfile
GITHUB PR #6967
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux e6c6e86593a3 5.15.0-117-generic #127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 4c1cb97
Default Java Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.24+8-post-Ubuntu-1ubuntu320.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_422-8u422-b05-1~20.04-b05
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/4/testReport/
Max. process+thread count 552 (vs. ulimit of 5500)
modules C: hadoop-tools/hadoop-aliyun U: hadoop-tools/hadoop-aliyun
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-6967/4/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@zhouaoe
Copy link
Contributor Author

zhouaoe commented Sep 4, 2024

@steveloughran @masteryhx @zeekling hi,I have made the suggested changes to the code. Please take a look again. Thanks.
The main changes include simplifying the code mentioned in the comments, updating some comments, and adding Javadoc for the flag.
Additionally, I consulted with other colleagues from the Aliyun OSS team. Since the original code did not include the ITest prefix for OSS integration tests, and the case names have not been changed since then, I do not plan to modify the case names in this PR. I propose creating a separate PR to update the integration test names later.

@ColdL
Copy link

ColdL commented Jan 14, 2025

This patch looks good. There are still a few checkstyle issues that haven't been fully resolved. Can these problems be further addressed? @zhouaoe

@apache apache deleted a comment from hadoop-yetus Jan 14, 2025
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import com.aliyun.oss.common.auth.CredentialsProvider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not an apache import

Copy link
Contributor

@steveloughran steveloughran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok went through it, main area of change is in the tests where i

  • reviewed object close() code everywhere
  • suggested new parent class
  • proposed move to assertj for meaningful failures
  • more

the problem with asserTrue() is that when it is false, there is no meaning at all. AssertJ is really, really good at providing details on a failure. It's a bit hard to learn, but now is the time

* When the redirection feature is available, it will access the
* redirected target file
*/
public class TestAliyunOSSRedirect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to to suggest subclassing AbstractHadoopTestBase

This

  • adds the test timeout, and supports a system property to extend it
  • sets the thread name to the test method, different names for setup and teardown. this is really useful
    Once you do that you can cut line 81; nothing else should change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, steveloughran, for the review. I will carefully revise these comments and submit the improved code as soon as possible.

}

testURI = URI.create(fsname);
assertTrue(testURI.getScheme().equals(Constants.FS_OSS));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertJ assertions here please

Assertions.assertThat(testURI.getScheme())
 .isEqualsTo(Constants.FS_OSS));

}
String proxyUsername = conf.getTrimmed(PROXY_USERNAME_KEY);
String proxyPassword = conf.getTrimmed(PROXY_PASSWORD_KEY);
if ((proxyUsername == null) != (proxyPassword == null)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use org.apache.hadoop.util.Preconditions.checkArgument() with an xor statement

Preconditions.checkArgument(!(proxyUsername == null ^ proxyPassword == null),
  "Proxy error: " + PROXY_USERNAME_KEY + " or " +
            PROXY_PASSWORD_KEY + " set without the other.")

This is about the only place the ^ can be used in normal code, so something to consider just to tick it off your software developer career!

}

String endPoint = conf.getTrimmed(ENDPOINT_KEY, "");
if (StringUtils.isEmpty(endPoint)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Preconditions.checkArgument

fs = AliyunOSSTestUtils.createTestFileSystem(conf);

Path srcFilePath = new Path(testRootPath, "redirect_test_src.txt");
FSDataInputStream instream = this.fs.open(srcFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try with resources

fs = AliyunOSSTestUtils.createTestFileSystem(conf);

Path srcFilePath = new Path(testRootPath,"redirect_test_src.txt");
assertThrows(IOException.class, () -> this.fs.open(srcFilePath));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if this doesn't throw, there's actually a new open stream. better to use our LambdaTestUtils.intercept() which is often more informative on failures, and close the stream.

intercept(IOException.class, () -> 
   fs.open(srcFilePath).close());

String fsname = conf.getTrimmed(
TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME, "");

if (StringUtils.isEmpty(fsname)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertJ assume

Assumptions.assumeThat(fsName)
  .describedAs(No test filesystem in "
          + TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME)
  .isNotEmpty();

@After
public void tearDown() throws Exception {
if (fs != null) {
fs.delete(new Path(testRootPath), true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fs.close(), so the filesystems aren't leaked

boolean redirectEnable = conf.getBoolean(REDIRECT_ENABLE_KEY,
REDIRECT_ENABLE_DEFAULT);
clientConf.setRedirectEnable(redirectEnable);
LOG.debug("oss redirectEnable " + redirectEnable);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer using {} expansion sin the log

LOG.debug("oss redirectEnable {}", redirectEnable);
  1. saves building the string when debug is not enabled
  2. the toString() call on every argument is very robust, handles raised exceptions and more. Not an issue for boolean, but stull a good habit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants