github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/hadoopfs/src/test/java/io/lakefs/contract/LakeFSTestUtils.java (about)

     1  package io.lakefs.contract;
     2  
     3  import io.lakefs.LakeFSFileSystem;
     4  import org.apache.commons.lang3.StringUtils;
     5  import org.apache.hadoop.conf.Configuration;
     6  import org.apache.hadoop.fs.s3a.Constants;
     7  import org.junit.AssumptionViolatedException;
     8  
     9  import java.io.IOException;
    10  import java.net.URI;
    11  
    12  public class LakeFSTestUtils {
    13  
    14    public static final String NULL_RESULT = "(null)";
    15  
    16    public static LakeFSFileSystem createTestFileSystem(Configuration conf) throws IOException {
    17      String fsname = conf.getTrimmed(TestLakeFSFileSystemContract.TEST_FS_LAKEFS_NAME, "");
    18  
    19      boolean liveTest = !StringUtils.isEmpty(fsname);
    20      URI testURI = null;
    21      if (liveTest) {
    22        testURI = URI.create(fsname);
    23        liveTest = testURI.getScheme().equals("lakefs");
    24      }
    25      if (!liveTest) {
    26        // This doesn't work with our JUnit 3 style test cases, so instead we'll
    27        // make this whole class not run by default
    28        throw new AssumptionViolatedException(
    29            "No test filesystem in " + TestLakeFSFileSystemContract.TEST_FS_LAKEFS_NAME);
    30      }
    31      LakeFSFileSystem fs1 = new LakeFSFileSystem();
    32      //enable purging in tests
    33      conf.setBoolean(Constants.PURGE_EXISTING_MULTIPART, true);
    34      conf.setInt(Constants.PURGE_EXISTING_MULTIPART_AGE, 0);
    35      fs1.initialize(testURI, conf);
    36      return fs1;
    37    }
    38  
    39  }