summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/s3/suite.pm
blob: cdefbc5e323c85410681d9c77680e5b2b235c58b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package My::Suite::S3;

use Socket;

@ISA = qw(My::Suite);

return "Need S3 engine" unless $::mysqld_variables{'s3'} eq "ON" or $ENV{HA_S3_SO};

my $paddr = sockaddr_in(9000, INADDR_ANY);
my $protocol = getprotobyname("tcp");
socket(SOCK, PF_INET, SOCK_STREAM, $protocol);

if(connect(SOCK, $paddr))
{
  $ENV{'S3_HOST_NAME'} = "127.0.0.1";
  $ENV{'S3_PORT'} = 9000;
  $ENV{'S3_BUCKET'} = "storage-engine";
  $ENV{'S3_ACCESS_KEY'} = "minio";
  $ENV{'S3_SECRET_KEY'} = "minioadmin";
  $ENV{'S3_REGION'} = "";
  $ENV{'S3_PROTOCOL_VERSION'} = "Auto";
  $ENV{'S3_USE_HTTP'} = "ON";
}
else
{
  if (!$ENV{'S3_HOST_NAME'})
  {
    $ENV{'S3_HOST_NAME'} = "s3.amazonaws.com";
  }

  if (!$ENV{'S3_BUCKET'})
  {
    $ENV{'S3_BUCKET'} = "MariaDB";
  }

  if (!$ENV{'S3_REGION'})
  {
    $ENV{'S3_REGION'} = "";
  }

  if (!$ENV{'S3_ACCESS_KEY'})
  {
    return "Environment variable S3_ACCESS_KEY need to be set";
  }

  if (!$ENV{'S3_SECRET_KEY'})
  {
    return "Environment variable S3_SECRET_KEY need to be set";
  }

  if (!$ENV{'S3_PROTOCOL_VERSION'})
  {
    $ENV{'S3_PROTOCOL_VERSION'} = "Auto";
  }

  if (!$ENV{'S3_PORT'})
  {
    $ENV{'S3_PORT'} = 0;
  }

  if (!$ENV{'S3_USE_HTTP'})
  {
    $ENV{'S3_USE_HTTP'} = "OFF";
  }
}
bless { };