YARN-10788. TestCsiClient fails (#3989)

Create unix domain socket in java.io.tmpdir instead of
test.build.dir to avoid 'File name too long' error.

Reviewed-by: Ayush Saxena <ayushsaxena@apache.org>
(cherry picked from commit 7fd90cdcbe)
This commit is contained in:
Akira Ajisaka 2022-02-15 01:13:13 +09:00
parent 7512714475
commit 352656999f
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50

View File

@ -20,13 +20,14 @@
import csi.v0.Csi; import csi.v0.Csi;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Assume; import org.junit.Assume;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -36,19 +37,21 @@
* Test class for CSI client. * Test class for CSI client.
*/ */
public class TestCsiClient { public class TestCsiClient {
private static final Logger LOG = LoggerFactory.getLogger(TestCsiClient.class);
private static File testRoot = null; private static File testRoot = null;
private static String domainSocket = null; private static String domainSocket = null;
private static FakeCsiDriver driver = null; private static FakeCsiDriver driver = null;
@BeforeClass @BeforeClass
public static void setUp() throws IOException { public static void setUp() throws IOException {
File testDir = GenericTestUtils.getTestDir(); // Use /tmp to fix bind failure caused by the long file name
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
testRoot = Files testRoot = Files
.createTempDirectory(testDir.toPath(), "test").toFile(); .createTempDirectory(tmpDir.toPath(), "test").toFile();
File socketPath = new File(testRoot, "csi.sock"); File socketPath = new File(testRoot, "csi.sock");
FileUtils.forceMkdirParent(socketPath); FileUtils.forceMkdirParent(socketPath);
domainSocket = "unix://" + socketPath.getAbsolutePath(); domainSocket = "unix://" + socketPath.getAbsolutePath();
LOG.info("Create unix domain socket: {}", domainSocket);
driver = new FakeCsiDriver(domainSocket); driver = new FakeCsiDriver(domainSocket);
} }