Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit438f77d

Browse files
kvapkelvich
authored andcommitted
Split Testeaux into multiple files. Implement stub stresses and troubles as plugins.
1 parentdfe876d commit438f77d

File tree

10 files changed

+211
-117
lines changed

10 files changed

+211
-117
lines changed

‎testeaux/Combineaux.pm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
packageCombineaux;
2+
3+
use Troubleaux;
4+
use Stresseaux;
5+
use Starteaux;
6+
7+
subcombine
8+
{
9+
my ($stresses,$troubles) =@_;
10+
11+
my$cluster = Starteaux->deploy('lxc');
12+
13+
foreachmy$stress (@$stresses)
14+
{
15+
foreachmy$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;

‎testeaux/Starteaux.pm

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
packageStarteaux;
2+
3+
subdeploy
4+
{
5+
my ($class,$driver,@args) =@_;
6+
my$self = {};
7+
print("deploy cluster using driver$driver\n");
8+
# fixme: implement
9+
returnbless$self,'Starteaux';
10+
}
11+
12+
subup
13+
{
14+
my ($self,$id) =@_;
15+
print("up node$id\n");
16+
# FIXME: implement
17+
}
18+
19+
subdown
20+
{
21+
my ($self,$id) =@_;
22+
print("down node$id\n");
23+
# FIXME: implement
24+
}
25+
26+
subdrop
27+
{
28+
my ($self,$src,$dst,$ratio) =@_;
29+
print("drop$ratio packets from$src to$dst\n");
30+
# FIXME: implement
31+
}
32+
33+
subdelay
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+
subdestroy
41+
{
42+
my ($self) =@_;
43+
print("destroy cluster$cluster\n");
44+
# FIXME: implement
45+
}
46+
47+
1;

‎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
substart
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
substop
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
}

‎testeaux/Testeaux.pm

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

‎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+
packageTroubleaux
4+
{
5+
subcause
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+
subfix
16+
{
17+
my ($cluster) =@_;
18+
19+
while (@caused)
20+
{
21+
my$trouble =pop@caused;
22+
$trouble->fix();
23+
}
24+
}
25+
}
26+
27+
1;

‎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+
sublist_modules
6+
{
7+
my$dir =shift;
8+
my@modules = ();
9+
10+
opendir DIR,$dirordie"Cannot open directory:$!";
11+
12+
while (my$file =readdir(DIR)) {
13+
# Use a regular expression to ignore files beginning with a period
14+
nextunless ($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);

‎testeaux/stress/banktransfer.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagestress::banktransfer;
2+
3+
substart
4+
{
5+
my ($class,@args) =@_;
6+
my$self = {};
7+
print("start$class with args" .join(',',@args) ."\n");
8+
returnbless$self,$class;
9+
}
10+
11+
substop
12+
{
13+
my$self =shift;
14+
print("stop$self\n");
15+
}
16+
17+
1;

‎testeaux/stress/pgbench.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagestress::pgbench;
2+
3+
substart
4+
{
5+
my ($class,@args) =@_;
6+
my$self = {};
7+
print("start$class with args" .join(',',@args) ."\n");
8+
returnbless$self,$class;
9+
}
10+
11+
substop
12+
{
13+
my$self =shift;
14+
print("stop$self\n");
15+
}
16+
17+
1;

‎testeaux/trouble/splitbrain.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagetrouble::splitbrain;
2+
3+
subcause
4+
{
5+
my ($class,@args) =@_;
6+
my$self = {};
7+
print("cause$class with args" .join(',',@args) ."\n");
8+
returnbless$self,$class;
9+
}
10+
11+
subfix
12+
{
13+
my$self =shift;
14+
print("fix$self\n");
15+
}
16+
17+
1;

‎testeaux/trouble/timeshift.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
packagetrouble::timeshift;
2+
3+
subcause
4+
{
5+
my$class =shift;
6+
my$self = {};
7+
print("cause$class with args" .join(',',@args) ."\n");
8+
returnbless$self,$class;
9+
}
10+
11+
subfix
12+
{
13+
my$self =shift;
14+
print("fix$self\n");
15+
}
16+
17+
1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp