Skip to content

Commit 69ebdf6

Browse files
committed
fix test
1 parent 40111c1 commit 69ebdf6

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8838,10 +8838,6 @@ private Supplier<String> getLockReportInfoSupplier(String src, String dst,
88388838
UserGroupInformation ugi = Server.getRemoteUser();
88398839
String userName = ugi != null ? ugi.toString() : null;
88408840
InetAddress addr = Server.getRemoteIp();
8841-
if (addr != null) {
8842-
// The host name resolution on InetAddress provides Hostname with IP address
8843-
addr.getHostName();
8844-
}
88458841
StringBuilder sb = new StringBuilder();
88468842
String s = escapeJava(src);
88478843
String d = escapeJava(dst);

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemLockReport.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ public void test() throws Exception {
103103
FSDataOutputStream os = testLockReport(() ->
104104
userfs.create(new Path("/file")),
105105
".* by create \\(ugi=bob \\(auth:SIMPLE\\)," +
106-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
106+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
107107
"perm=bob:hadoop:rw-r--r--\\) .*");
108108
os.close();
109109

110110
// The log output should contain "by open (ugi=bob (auth:SIMPLE),
111111
// ip=/127.0.0.1,src=/file,dst=null,perm=null)"
112112
FSDataInputStream is = testLockReport(() -> userfs.open(new Path("/file")),
113113
".* by open \\(ugi=bob \\(auth:SIMPLE\\)," +
114-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
114+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
115115
"perm=null\\) .*");
116116
is.close();
117117

@@ -120,49 +120,49 @@ public void test() throws Exception {
120120
testLockReport(() ->
121121
userfs.setPermission(new Path("/file"), new FsPermission(644)),
122122
".* by setPermission \\(ugi=bob \\(auth:SIMPLE\\)," +
123-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
123+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
124124
"perm=bob:hadoop:-w----r-T\\) .*");
125125

126126
// The log output should contain "by setOwner (ugi=bob (auth:SIMPLE),
127127
// ip=/127.0.0.1,src=/file,dst=null,perm=alice:group1:-w----r-T)"
128128
testLockReport(() -> userfs.setOwner(new Path("/file"), "alice", "group1"),
129129
".* by setOwner \\(ugi=bob \\(auth:SIMPLE\\)," +
130-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
130+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
131131
"perm=alice:group1:-w----r-T\\) .*");
132132

133133
// The log output should contain "by listStatus (ugi=bob (auth:SIMPLE),
134134
// ip=/127.0.0.1,src=/,dst=null,perm=null)"
135135
testLockReport(() -> userfs.listStatus(new Path("/")),
136136
".* by listStatus \\(ugi=bob \\(auth:SIMPLE\\)," +
137-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/,dst=null," +
137+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/,dst=null," +
138138
"perm=null\\) .*");
139139

140140
// The log output should contain "by getfileinfo (ugi=bob (auth:SIMPLE),
141141
// ip=/127.0.0.1,src=/file,dst=null,perm=null)"
142142
testLockReport(() -> userfs.getFileStatus(new Path("/file")),
143143
".* by getfileinfo \\(ugi=bob \\(auth:SIMPLE\\)," +
144-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
144+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=null," +
145145
"perm=null\\) .*");
146146

147147
// The log output should contain "by mkdirs (ugi=bob (auth:SIMPLE),
148148
// ip=/127.0.0.1,src=/dir,dst=null,perm=bob:hadoop:rwxr-xr-x)"
149149
testLockReport(() -> userfs.mkdirs(new Path("/dir")),
150150
".* by mkdirs \\(ugi=bob \\(auth:SIMPLE\\)," +
151-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/dir,dst=null," +
151+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/dir,dst=null," +
152152
"perm=bob:hadoop:rwxr-xr-x\\) .*");
153153

154154
// The log output should contain "by delete (ugi=bob (auth:SIMPLE),
155155
// ip=/127.0.0.1,src=/file2,dst=null,perm=null)"
156156
testLockReport(() -> userfs.rename(new Path("/file"), new Path("/file2")),
157157
".* by rename \\(ugi=bob \\(auth:SIMPLE\\)," +
158-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=/file2," +
158+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file,dst=/file2," +
159159
"perm=alice:group1:-w----r-T\\) .*");
160160

161161
// The log output should contain "by rename (ugi=bob (auth:SIMPLE),
162162
// ip=/127.0.0.1,src=/file,dst=/file2,perm=alice:group1:-w----r-T)"
163163
testLockReport(() -> userfs.delete(new Path("/file2"), false),
164164
".* by delete \\(ugi=bob \\(auth:SIMPLE\\)," +
165-
"ip=[a-zA-Z0-9.]+/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file2,dst=null," +
165+
"ip=/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3},src=/file2,dst=null," +
166166
"perm=null\\) .*");
167167
}
168168

0 commit comments

Comments
 (0)