#!/usr/bin/perl

use strict;
use warnings;

BEGIN
{
  die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
}

print "\n===== Spawn Test Collections =====\n\n";

my $base_path = $ENV{'GSDLHOME'} . '/collect';
my @collections = ('gdbm','sqlite','tdb','gdbmserver');
my @sizes = (100,500,1000,5000,10000,50000,100000,500000,1000000);

foreach my $collection (@collections)
{
    foreach my $size (@sizes)
    {
	my $size_str = sprintf("%07d", $size);
	my $collection_name = $collection . $size_str;
	my $collection_path = $base_path . '/' . $collection_name;
        if (!-d $collection_path)
        {
          print " - Creating collection: " . $collection_name . "\n";
          `mkdir $collection_path`;
          `ln -s $base_path/$collection/etc $collection_path/etc`;
          `ln -s $base_path/lorem$size_str/import $collection_path/import`;
        }
        else
        {
          print " - Collection exists. Skipping: " . $collection_name . "\n";
        }
    }
}
print "\n===== Complete! =====\n\n";
