Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46a5c82

Browse files
kvapkelvich
authored andcommitted
Fix syntax in Testeaux module. Add an example that uses it.
1 parent dd33aa2 commit 46a5c82

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

testeaux/Testeaux.pm

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
package Testeaux;
22

3-
package combineaux
3+
package Combineaux
44
{
55
sub combine
66
{
77
my ($workloads, $troubles) = @_;
88

9-
my $cluster = starteaux->deploy('lxc');
9+
my $cluster = Starteaux->deploy('lxc');
1010

1111
foreach my $workload (@$workloads)
1212
{
1313
foreach my $trouble (@$troubles)
1414
{
1515
print("run workload $workload during trouble $trouble\n");
1616
# FIXME: generate proper id instead of 'hello'
17-
stresseaux::start('hello', $workload, $cluster);
18-
# FIXME: add a time gap here
19-
troubleaux::cause($cluster, $trouble);
20-
# FIXME: add a time gap here
21-
stresseaux::stop('hello');
22-
troubleaux::fix($cluster);
17+
Stresseaux::start('hello', $workload, $cluster);
18+
sleep(1); # FIXME: will this work?
19+
Troubleaux::cause($cluster, $trouble);
20+
sleep(1); # FIXME: will this work?
21+
Stresseaux::stop('hello');
22+
Troubleaux::fix($cluster);
2323
}
2424
}
25+
26+
$cluster->destroy();
2527
}
2628
}
2729

28-
package stresseaux
30+
package Stresseaux
2931
{
3032
sub start
3133
{
@@ -42,15 +44,15 @@ package stresseaux
4244
}
4345
}
4446

45-
package starteaux
47+
package Starteaux
4648
{
4749
sub deploy
4850
{
4951
my ($class, $driver, @args) = @_;
5052
my $self = {};
5153
print("deploy cluster using driver $driver\n");
5254
# fixme: implement
53-
return bless $self, 'starteaux';
55+
return bless $self, 'Starteaux';
5456
}
5557

5658
sub up
@@ -62,7 +64,7 @@ package starteaux
6264

6365
sub down
6466
{
65-
my ($self, $id = @_;
67+
my ($self, $id) = @_;
6668
print("down node $id\n");
6769
# FIXME: implement
6870
}
@@ -80,6 +82,30 @@ package starteaux
8082
print("delay packets from $src to $dst by $msec msec\n");
8183
# FIXME: implement
8284
}
85+
86+
sub destroy
87+
{
88+
my ($self) = @_;
89+
print("destroy cluster $cluster\n");
90+
# FIXME: implement
91+
}
92+
}
93+
94+
package Troubleaux
95+
{
96+
sub cause
97+
{
98+
my ($cluster, $trouble) = @_;
99+
print("cause $trouble in cluster $cluster\n");
100+
# fixme: implement
101+
}
102+
103+
sub fix
104+
{
105+
my ($cluster) = @_;
106+
print("fix cluster $cluster\n");
107+
# fixme: implement
108+
}
83109
}
84110

85111
1;

testeaux/eaux.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/perl
2+
3+
use Testeaux;
4+
5+
Combineaux::combine(
6+
['bank-transfers', 'pgbench-default'],
7+
['split-brain', 'time-shift'],
8+
)

0 commit comments

Comments
 (0)