Skip to content

Commit 2a5f35f

Browse files
committed
2 parents 558d2a2 + 56fc560 commit 2a5f35f

File tree

12 files changed

+237
-119
lines changed

12 files changed

+237
-119
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pPostgreSQL Database Management System
1+
PostgreSQL Database Management System
22
=====================================
33

44
This directory contains the source code distribution of the PostgreSQL

contrib/mmts/testeaux/Combineaux.pm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package Combineaux;
2+
3+
use Troubleaux;
4+
use Stresseaux;
5+
use Starteaux;
6+
7+
sub combine
8+
{
9+
my ($stresses, $troubles) = @_;
10+
11+
my $cluster = Starteaux->deploy('lxc');
12+
13+
foreach my $stress (@$stresses)
14+
{
15+
foreach my $trouble (@$troubles)
16+
{
17+
print("--- $stress vs. $trouble ---\n");
18+
my $id = "$stress+$trouble";
19+
Stresseaux::start($id, $stress, $cluster) || die "stress wouldn't start";
20+
sleep(1); # FIXME: will this work?
21+
Troubleaux::cause($cluster, $trouble);
22+
sleep(1); # FIXME: will this work?
23+
Stresseaux::stop($id) || die "stress wouldn't stop";
24+
Troubleaux::fix($cluster);
25+
}
26+
}
27+
28+
$cluster->destroy();
29+
}
30+
31+
1;

contrib/mmts/testeaux/Starteaux.pm

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package Starteaux;
2+
3+
sub deploy
4+
{
5+
my ($class, $driver, @args) = @_;
6+
my $self = {};
7+
print("deploy cluster using driver $driver\n");
8+
# fixme: implement
9+
return bless $self, 'Starteaux';
10+
}
11+
12+
sub up
13+
{
14+
my ($self, $id) = @_;
15+
print("up node $id\n");
16+
# FIXME: implement
17+
}
18+
19+
sub down
20+
{
21+
my ($self, $id) = @_;
22+
print("down node $id\n");
23+
# FIXME: implement
24+
}
25+
26+
sub drop
27+
{
28+
my ($self, $src, $dst, $ratio) = @_;
29+
print("drop $ratio packets from $src to $dst\n");
30+
# FIXME: implement
31+
}
32+
33+
sub delay
34+
{
35+
my ($self, $src, $dst, $msec) = @_;
36+
print("delay packets from $src to $dst by $msec msec\n");
37+
# FIXME: implement
38+
}
39+
40+
sub destroy
41+
{
42+
my ($self) = @_;
43+
print("destroy cluster $cluster\n");
44+
# FIXME: implement
45+
}
46+
47+
1;

contrib/mmts/testeaux/Stresseaux.pm

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Stresseaux;
2+
3+
my %running = ();
4+
5+
sub start
6+
{
7+
my ($id, $stressname, $cluster, @args) = @_;
8+
9+
if (exists $running{$id})
10+
{
11+
print("cannot start stress $stressname as $id: that id has already been taken\n");
12+
return 0;
13+
}
14+
15+
require "stress/$stressname.pm";
16+
$running{$id} = "stress::$stressname"->start($id, $cluster, @args);
17+
18+
return 1;
19+
}
20+
21+
sub stop
22+
{
23+
my $id = shift;
24+
25+
my $stress = delete $running{$id};
26+
27+
if (!defined $stress)
28+
{
29+
print("cannot stop stress $id: that id is not running\n");
30+
return 0;
31+
}
32+
33+
$stress->stop();
34+
35+
return 1;
36+
}
37+
38+
1;

contrib/mmts/testeaux/Testeaux.pm

Lines changed: 0 additions & 111 deletions
This file was deleted.

contrib/mmts/testeaux/Troubleaux.pm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
my @caused = ();
2+
3+
package Troubleaux
4+
{
5+
sub cause
6+
{
7+
my $cluster = shift;
8+
my $troublename = shift;
9+
my @args = @_;
10+
11+
require "trouble/$troublename.pm";
12+
push @caused, "trouble::$troublename"->cause(@args);
13+
}
14+
15+
sub fix
16+
{
17+
my ($cluster) = @_;
18+
19+
while (@caused)
20+
{
21+
my $trouble = pop @caused;
22+
$trouble->fix();
23+
}
24+
}
25+
}
26+
27+
1;

contrib/mmts/testeaux/eaux.pl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
#!/usr/bin/perl
22

3-
use Testeaux;
3+
use Combineaux;
44

5-
Combineaux::combine(
6-
['bank-transfers', 'pgbench-default'],
7-
['split-brain', 'time-shift'],
8-
)
5+
sub list_modules
6+
{
7+
my $dir = shift;
8+
my @modules = ();
9+
10+
opendir DIR, $dir or die "Cannot open directory: $!";
11+
12+
while (my $file = readdir(DIR)) {
13+
# Use a regular expression to ignore files beginning with a period
14+
next unless ($file =~ m/\.pm$/);
15+
push @modules, substr($file, 0, -3);
16+
}
17+
18+
closedir DIR;
19+
20+
return @modules;
21+
}
22+
23+
my @stresses = list_modules('stress');
24+
my @troubles = list_modules('trouble');
25+
26+
Combineaux::combine(\@stresses, \@troubles);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package stress::banktransfer;
2+
3+
sub start
4+
{
5+
my ($class, @args) = @_;
6+
my $self = {};
7+
print("start $class with args " . join(',', @args) . "\n");
8+
return bless $self, $class;
9+
}
10+
11+
sub stop
12+
{
13+
my $self = shift;
14+
print("stop $self\n");
15+
}
16+
17+
1;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package stress::pgbench;
2+
3+
sub start
4+
{
5+
my ($class, @args) = @_;
6+
my $self = {};
7+
print("start $class with args " . join(',', @args) . "\n");
8+
return bless $self, $class;
9+
}
10+
11+
sub stop
12+
{
13+
my $self = shift;
14+
print("stop $self\n");
15+
}
16+
17+
1;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package trouble::splitbrain;
2+
3+
sub cause
4+
{
5+
my ($class, @args) = @_;
6+
my $self = {};
7+
print("cause $class with args " . join(',', @args) . "\n");
8+
return bless $self, $class;
9+
}
10+
11+
sub fix
12+
{
13+
my $self = shift;
14+
print("fix $self\n");
15+
}
16+
17+
1;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy