<commit_before>/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio.master;

import alluxio.AlluxioURI;
import alluxio.Constants;
import alluxio.LocalAlluxioClusterResource;
import alluxio.PropertyKey;
import alluxio.client.WriteType;
import alluxio.client.file.FileSystem;
import alluxio.client.file.options.CreateDirectoryOptions;
import alluxio.client.file.options.CreateFileOptions;
import alluxio.master.file.FileSystemMaster;
import alluxio.underfs.UnderFileSystem;
import alluxio.util.CommonUtils;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

/**
 * Test the consistency check which happens on master start up.
 */
public class StartupConsistencyCheckTest {
  private static final AlluxioURI TOP_LEVEL_FILE = new AlluxioURI("/file");
  private static final AlluxioURI TOP_LEVEL_DIR = new AlluxioURI("/dir");
  private static final AlluxioURI SECOND_LEVEL_FILE = new AlluxioURI("/dir/file");
  private static final AlluxioURI SECOND_LEVEL_DIR = new AlluxioURI("/dir/dir");
  private static final AlluxioURI THIRD_LEVEL_FILE = new AlluxioURI("/dir/dir/file");

  private LocalAlluxioCluster mCluster;
  private FileSystem mFileSystem;

  @Rule
  public LocalAlluxioClusterResource mLocalAlluxioClusterResource =
      new LocalAlluxioClusterResource.Builder()
          .setProperty(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, Integer.toString(Constants.KB))
          .setProperty(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "false")
          .build();

  @Before
  public void before() throws Exception {
    CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.THROUGH);
    CreateDirectoryOptions dirOptions =
        CreateDirectoryOptions.defaults().setWriteType(WriteType.THROUGH);

    mCluster = mLocalAlluxioClusterResource.get();
    mFileSystem = mCluster.getClient();
    mFileSystem.createFile(TOP_LEVEL_FILE, fileOptions).close();
    mFileSystem.createDirectory(TOP_LEVEL_DIR, dirOptions);
    mFileSystem.createDirectory(SECOND_LEVEL_DIR, dirOptions);
    mFileSystem.createFile(SECOND_LEVEL_FILE, fileOptions).close();
    mFileSystem.createFile(THIRD_LEVEL_FILE, fileOptions).close();
  }<commit_msg>Fix checkstyle.<commit_after>/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio.master;

import alluxio.AlluxioURI;
import alluxio.LocalAlluxioClusterResource;
import alluxio.PropertyKey;
import alluxio.client.WriteType;
import alluxio.client.file.FileSystem;
import alluxio.client.file.options.CreateDirectoryOptions;
import alluxio.client.file.options.CreateFileOptions;
import alluxio.master.file.FileSystemMaster;
import alluxio.underfs.UnderFileSystem;
import alluxio.util.CommonUtils;

import com.google.common.base.Function;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

/**
 * Test the consistency check which happens on master start up.
 */
public class StartupConsistencyCheckTest {
  private static final AlluxioURI TOP_LEVEL_FILE = new AlluxioURI("/file");
  private static final AlluxioURI TOP_LEVEL_DIR = new AlluxioURI("/dir");
  private static final AlluxioURI SECOND_LEVEL_FILE = new AlluxioURI("/dir/file");
  private static final AlluxioURI SECOND_LEVEL_DIR = new AlluxioURI("/dir/dir");
  private static final AlluxioURI THIRD_LEVEL_FILE = new AlluxioURI("/dir/dir/file");

  private LocalAlluxioCluster mCluster;
  private FileSystem mFileSystem;

  @Rule
  public LocalAlluxioClusterResource mLocalAlluxioClusterResource =
      new LocalAlluxioClusterResource.Builder()
          .setProperty(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "false")
          .build();

  @Before
  public void before() throws Exception {
    CreateFileOptions fileOptions = CreateFileOptions.defaults().setWriteType(WriteType.THROUGH);
    CreateDirectoryOptions dirOptions =
        CreateDirectoryOptions.defaults().setWriteType(WriteType.THROUGH);

    mCluster = mLocalAlluxioClusterResource.get();
    mFileSystem = mCluster.getClient();
    mFileSystem.createFile(TOP_LEVEL_FILE, fileOptions).close();
    mFileSystem.createDirectory(TOP_LEVEL_DIR, dirOptions);
    mFileSystem.createDirectory(SECOND_LEVEL_DIR, dirOptions);
    mFileSystem.createFile(SECOND_LEVEL_FILE, fileOptions).close();
    mFileSystem.createFile(THIRD_LEVEL_FILE, fileOptions).close();
  }
{'fraction_non_alphanumeric': 0.08557675164913532, 'fraction_numerical': 0.0014262791941522554, 'mean_word_length': 5.3533408833522085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5396573', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1612, 'n_words': 411}