Package com.splunk.shuttl.archiver.model

Examples of com.splunk.shuttl.archiver.model.Bucket


  public void _givenSuccessfulTransfer_returnBucketTransferedBucketOnLocalDisk()
      throws IOException {
    stub(thawLocationProvider.getThawTransferLocation(any(Bucket.class)))
        .toReturn(createDirectory());
    Bucket bucketToTransfer = TUtilsBucket.createBucket();
    File bucketLocationOnLocalDisk = createDirectory();
    LocalBucket bucketOnLocalDisk = mock(LocalBucket.class);

    when(thawLocationProvider.getLocationInThawForBucket(bucketToTransfer))
        .thenReturn(bucketLocationOnLocalDisk);
    when(
        bucketFactory.createWithIndexDirectoryAndSize(
            bucketToTransfer.getIndex(), bucketLocationOnLocalDisk,
            bucketToTransfer.getFormat(), bucketToTransfer.getSize()))
        .thenReturn(bucketOnLocalDisk);

    Bucket actualBucket = bucketTransferer
        .transferBucketToThaw(bucketToTransfer);
    assertEquals(bucketOnLocalDisk, actualBucket);
  }
View Full Code Here


    when(pathResolver.resolveIndexFromPathToBucket(anyString())).thenReturn(
        index);

    List<Bucket> buckets = archiveBucketsLister.listBucketsInIndex(index);
    assertEquals(2, buckets.size());
    Bucket bucket1 = new Bucket(bucketPath1, index, bucketName1, null);
    Bucket bucket2 = new Bucket(bucketPath2, index, bucketName2, null);
    for (Bucket bucket : buckets)
      assertTrue(TUtilsTestNG
          .isBucketEqualOnIndexFormatAndName(bucket1, bucket)
          || TUtilsTestNG.isBucketEqualOnIndexFormatAndName(bucket2, bucket));
  }
View Full Code Here

    when(pathResolver.resolveIndexFromPathToBucket(anyString())).thenReturn(
        index);

    List<Bucket> buckets = archiveBucketsLister.listBucketsInIndex(index);
    assertEquals(1, buckets.size());
    Bucket bucket1 = new Bucket(bucketPathWithFileSeparator, index, bucketName,
        null);
    assertTrue(TUtilsTestNG.isBucketEqualOnIndexFormatAndName(buckets.get(0),
        bucket1));
  }
View Full Code Here

    tearDownLocalConfig(tgzConf);
  }

  @Test(groups = { "functional" })
  public void _givenTgzConfig_archivesBucketAsTgz() {
    Bucket bucket = getTgzBucketArchived();

    List<Bucket> buckets = ListsBucketsFilteredFactory.create(tgzConf)
        .listFilteredBucketsAtIndex(bucket.getIndex(), bucket.getEarliest(),
            bucket.getLatest());

    assertEquals(1, buckets.size());
    assertEquals(BucketFormat.SPLUNK_BUCKET_TGZ, buckets.get(0).getFormat());
  }
View Full Code Here

  }

  public void _givenSuccessfulImportAndSizeResolving_returnImportedBucketWithSize()
      throws Exception {
    LocalBucket importedBucket = TUtilsBucket.createBucket();
    Bucket sizedBucket = mock(Bucket.class);
    stub(sizedBucket.getSize()).toReturn(121L);
    when(
        bucketImportController
            .restoreToSplunkBucketFormat(any(LocalBucket.class)))
        .thenReturn(importedBucket);
    when(bucketSizeResolver.resolveBucketSize(any(Bucket.class))).thenReturn(
        sizedBucket);
    LocalBucket actualBucket = getsBucketsFromArchive
        .getBucketFromArchive(bucket);

    assertEquals(importedBucket.getDirectory(), actualBucket.getDirectory());
    assertEquals(importedBucket.getEarliest(), actualBucket.getEarliest());
    assertEquals(importedBucket.getLatest(), actualBucket.getLatest());
    assertEquals(importedBucket.getIndex(), actualBucket.getIndex());
    assertEquals(importedBucket.getFormat(), actualBucket.getFormat());
    assertEquals(importedBucket.getName(), actualBucket.getName());
    assertEquals(importedBucket.getPath(), actualBucket.getPath());
    assertEquals(sizedBucket.getSize(), actualBucket.getSize());
  }
View Full Code Here

  // Sad path

  @Test(expectedExceptions = { ThawTransferFailException.class })
  public void _whenTransferBucketsFailToThaw_throwsExceptionAndDoesNotRestoreFailedBucket()
      throws Exception {
    Bucket bucket = mock(Bucket.class);
    doThrow(new IOException()).when(thawBucketTransferer).transferBucketToThaw(
        any(Bucket.class));
    getsBucketsFromArchive.getBucketFromArchive(bucket);
    verifyZeroInteractions(bucketImportController);
  }
View Full Code Here

  @Test(groups = { "functional" })
  public void _givenTgzConfig_thawsTgzBucketToSplunkBucket()
      throws IllegalIndexException {
    File thawDir = createDirectory();

    Bucket bucket = getTgzBucketArchived();
    SplunkIndexesLayer splunkIndexesLayer = new FakeSplunkIndexesLayer(thawDir);

    BucketThawer bucketThawer = BucketThawerFactory
        .createWithConfigAndSplunkSettingsAndLocalFileSystemPaths(tgzConf,
            splunkIndexesLayer, localFileSystemPaths);

    bucketThawer.thawBuckets(bucket.getIndex(), bucket.getEarliest(),
        bucket.getLatest());

    List<LocalBucket> buckets = bucketThawer.getThawedBuckets();
    assertEquals(1, buckets.size());
    Bucket thawedBucket = buckets.get(0);
    File thawedBucketDir = new File(thawedBucket.getPath());
    assertTrue(thawedBucketDir.isDirectory());
    assertTrue(thawedBucketDir.exists());

    assertEquals(BucketFormat.SPLUNK_BUCKET, thawedBucket.getFormat());
    assertEquals(thawDir.getAbsolutePath(), thawedBucketDir.getParentFile()
        .getAbsolutePath());
    int length = thawedBucketDir.listFiles().length;
    assertTrue(2 < length);
  }
View Full Code Here

    localFileSystemPaths = new LocalFileSystemPaths(createDirectory());
    thawBucketLocker = new ThawBucketLocker(localFileSystemPaths);
  }

  public void getLockForBucket_givenThawLocksDirectory_lockIsInThatDirectory() {
    Bucket bucket = TUtilsBucket.createBucket();
    File thawLocksDirectory = localFileSystemPaths
        .getThawLocksDirectory(bucket);
    BucketLock lockForBucket = thawBucketLocker.getLockForBucket(bucket);
    assertEquals(thawLocksDirectory.getAbsolutePath(), lockForBucket
        .getLockFile().getParentFile().getAbsolutePath());
View Full Code Here

    assertTrue(movedBuckets.isEmpty());
  }

  public void getMovedBuckets_givenBucketInMoveLocation_returnsListContainingTheMovedBucket()
      throws FileNotFoundException, IOException {
    Bucket bucket = createBucketInMoveLocationWithIndexPreserved("index");
    List<Bucket> movedBuckets = bucketMover.getMovedBuckets();
    assertEquals(1, movedBuckets.size());
    assertEquals(bucket, movedBuckets.get(0));
  }
View Full Code Here

    List<Bucket> movedBuckets = bucketMover.getMovedBuckets();
    assertTrue(movedBuckets.isEmpty());
  }

  public void getMovedBuckets_givenTwoBucketsWithDifferentIndexInMoveLocation_listWithTheTwoBuckets() {
    Bucket movedBucketIndex = createBucketInMoveLocationWithIndexPreserved("a");
    Bucket movedBucketAnotherIndex = createBucketInMoveLocationWithIndexPreserved("b");
    List<Bucket> movedBuckets = bucketMover.getMovedBuckets();
    assertEquals(2, movedBuckets.size());
    assertTrue(movedBuckets.contains(movedBucketIndex));
    assertTrue(movedBuckets.contains(movedBucketAnotherIndex));
  }
View Full Code Here

TOP

Related Classes of com.splunk.shuttl.archiver.model.Bucket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.