Skip to content

Commit

Permalink
fix pr failed checks listed in apache#6535 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
HanFreedom committed Feb 27, 2024
1 parent d822ff5 commit d9463ff
Show file tree
Hide file tree
Showing 33 changed files with 400 additions and 86 deletions.
2 changes: 1 addition & 1 deletion hadoop-compat-bench/HdfsCompatBenchIssue.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Accordingly, we propose to define a formal HCFS compatibility benchmark and prov
to do the compatibility assessment for an HCFS storage system.
The benchmark and tool should consider both HCFS interfaces and hdfs shell commands.
Different scenarios require different kinds of compatibilities.
For such consideration, we could define different suites in the benchmark.
For such consideration, we could define different suites in the benchmark.

## <a name="Benefits"></a> Benefits

Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/attr.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/concat.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/copy.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/fileinfo.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/modification.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/move.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/read.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/remove.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/snapshot.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "1..3"
Expand Down
16 changes: 16 additions & 0 deletions hadoop-compat-bench/shell/cases/storagePolicy.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

. $(dirname "$0")/../misc.sh

echo "Hello World!" > "${localDir}/dat"
Expand Down
39 changes: 33 additions & 6 deletions hadoop-compat-bench/shell/misc.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ntest=1
fname="$0"

Expand All @@ -13,10 +28,10 @@ prepare() {
FAIL_FILE="${HADOOP_COMPAT_FAIL_FILE}"
SKIP_FILE="${HADOOP_COMPAT_SKIP_FILE}"

baseDir="${BASE_URI}/${fname}"
localDir="${LOCAL_URI}/${fname}"
snapshotDir="${SNAPSHOT_URI}"
storagePolicy="${STORAGE_POLICY}"
export baseDir="${BASE_URI}/${fname}"
export localDir="${LOCAL_URI}/${fname}"
export snapshotDir="${SNAPSHOT_URI}"
export storagePolicy="${STORAGE_POLICY}"
stdoutDir="${STDOUT_DIR}/${fname}/stdout"
stderrDir="${STDOUT_DIR}/${fname}/stderr"
mkdir -p "${stdoutDir}"
Expand Down Expand Up @@ -87,15 +102,15 @@ expect_lines() { (
if should_skip "${stderr}"; then
skip_case "${cname}"
else
set -- ${lines}
lineCount="0"
while read -r line; do
case "${line}" in
*"Found"*"items"*)
continue
;;
esac
if ! echo "${line}" | grep -Eq '^'"${1}"'$'; then
selectedLine=$(expect_lines_select "${lines}" "${lineCount}")
if ! echo "${line}" | grep -Eq '^'"${selectedLine}"'$'; then
lineCount="-1"
break
else
Expand All @@ -120,6 +135,18 @@ expect_lines_parse() {
done
}

expect_lines_select() {
lineSelector="0"
echo "${1}" | while read -r splittedLine; do
if [ "${lineSelector}" -eq "${2}" ]; then
echo "${splittedLine}"
return
fi
lineSelector=$((lineSelector + 1))
done
echo ""
}

is_hadoop_shell() {
if [ X"${1}" = X"hadoop" ] || [ X"${1}" = X"hdfs" ]; then
return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class AbstractHdfsCompatCase {
private FileSystem fs;
private HdfsCompatEnvironment env;
private Path localPath;
private static final Random random = new Random();

public AbstractHdfsCompatCase() {
}
Expand Down Expand Up @@ -57,7 +58,7 @@ public Path getUniquePath() {

public static Path getUniquePath(Path basePath) {
return new Path(basePath, System.currentTimeMillis()
+ "_" + new Random().nextLong());
+ "_" + random.nextLong());
}

public Path makePath(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import java.util.stream.Collectors;

public class HdfsCompatEnvironment {
private static final SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
private static final Logger LOG =
LoggerFactory.getLogger(HdfsCompatEnvironment.class);
private static final String dateFormat = "yyyy_MM_dd_HH_mm_ss";
private static final Random random = new Random();
private final Path uri;
private final Configuration conf;
private FileSystem fs;
Expand All @@ -61,7 +61,7 @@ public void init() throws IOException {
Date now = new Date();
String uuid = UUID.randomUUID().toString();
String uniqueDir = "hadoop-compatibility-benchmark/" +
dateFormat.format(now) + "/" + uuid;
new SimpleDateFormat(dateFormat).format(now) + "/" + uuid;

this.fs = uri.getFileSystem(conf);
this.localFs = FileSystem.getLocal(conf);
Expand Down Expand Up @@ -113,7 +113,7 @@ public String[] getStoragePolicyNames() {
final String key = "fs." + scheme + ".compatibility.storage.policies";
final String storagePolicies = conf.get(key, null);
return (storagePolicies != null) ? storagePolicies.split(",") :
defaultStoragePolicyNames;
defaultStoragePolicyNames.clone();
}

public String getDelegationTokenRenewer() {
Expand All @@ -135,7 +135,7 @@ private String getEnvTmpDir() {
return null;
}
final String tmpDir = validDirs.get(
new Random().nextInt(validDirs.size()));
random.nextInt(validDirs.size()));
return new File(tmpDir).getAbsolutePath();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.compat;

public class HdfsCompatIllegalArgumentException
Expand Down
Loading

0 comments on commit d9463ff

Please sign in to comment.