Skip to content

Commit 25aa155

Browse files
committed
Split Testeaux into multiple files. Implement stub stresses and troubles as plugins.
1 parent 04134df commit 25aa155

File tree

10 files changed

+211
-117
lines changed

10 files changed

+211
-117
lines changed

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: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@ my %running = ();
44

55
sub start
66
{
7-
my ($id, $workload, $cluster) = @_;
8-
print("start stress $id: workload $workload, cluster $cluster\n");
7+
my ($id, $stressname, $cluster, @args) = @_;
98

109
if (exists $running{$id})
1110
{
12-
print("cannot start stress $id: that id has already been taken\n");
11+
print("cannot start stress $stressname as $id: that id has already been taken\n");
1312
return 0;
1413
}
1514

16-
# FIXME: implement 'stress'/'workload' objects
17-
$running{$id} = {hello => 'world'};
18-
19-
# FIXME: implement
15+
require "stress/$stressname.pm";
16+
$running{$id} = "stress::$stressname"->start($id, $cluster, @args);
2017

2118
return 1;
2219
}
2320

2421
sub stop
2522
{
2623
my $id = shift;
27-
print("stop stress $id\n");
2824

2925
my $stress = delete $running{$id};
3026

@@ -34,7 +30,7 @@ sub stop
3430
return 0;
3531
}
3632

37-
# FIXME: implement
33+
$stress->stop();
3834

3935
return 1;
4036
}

contrib/mmts/testeaux/Testeaux.pm

Lines changed: 0 additions & 96 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: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
#!/usr/bin/perl
22

3-
use Testeaux;
4-
5-
my @workloads = qw(
6-
bank-transfers
7-
pgbench-default
8-
);
9-
my @troubles = qw(
10-
split-brain
11-
time-shift
12-
);
13-
14-
Combineaux::combine(\@workloads, \@troubles);
3+
use Combineaux;
4+
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 @workloads = qw(
24+
# banktransfer
25+
# pgbench
26+
#);
27+
#my @troubles = qw(
28+
# splitbrain
29+
# timeshift
30+
#);
31+
32+
my @stresses = list_modules('stress');
33+
my @troubles = list_modules('trouble');
34+
35+
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;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package trouble::timeshift;
2+
3+
sub cause
4+
{
5+
my $class = shift;
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