commit
16620da96b
@ -0,0 +1,59 @@ |
||||
package attack |
||||
|
||||
import ( |
||||
"harmony-benchmark/log" |
||||
"math/rand" |
||||
"os" |
||||
"time" |
||||
) |
||||
|
||||
const ( |
||||
DroppingTickDuration = 2 * time.Second |
||||
AttackEnabled = false |
||||
HitRate = 10 |
||||
DelayResponseDuration = 10 * time.Second |
||||
) |
||||
|
||||
// AttackModel contains different models of attacking.
|
||||
type Attack struct { |
||||
log log.Logger // Log utility
|
||||
} |
||||
|
||||
func New(log log.Logger) *Attack { |
||||
attackModel := Attack{} |
||||
// Logger
|
||||
attackModel.log = log |
||||
return &attackModel |
||||
} |
||||
|
||||
// Run runs all attack models in goroutine mode.
|
||||
func (attack *Attack) Run() { |
||||
if !AttackEnabled { |
||||
return |
||||
} |
||||
// Adding attack model here.
|
||||
go func() { |
||||
attack.NodeKilledByItSelf() |
||||
}() |
||||
} |
||||
|
||||
// NodeKilledByItSelf runs killing itself attack
|
||||
func (attack *Attack) NodeKilledByItSelf() { |
||||
tick := time.Tick(DroppingTickDuration) |
||||
for { |
||||
<-tick |
||||
if rand.Intn(HitRate) == 0 { |
||||
attack.log.Debug("***********************Killing myself***********************", "PID: ", os.Getpid()) |
||||
os.Exit(1) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func DelayResponse() { |
||||
if !AttackEnabled { |
||||
return |
||||
} |
||||
if rand.Intn(HitRate) == 0 { |
||||
time.Sleep(DelayResponseDuration) |
||||
} |
||||
} |
@ -1,3 +1,4 @@ |
||||
#!/bin/bash -x |
||||
echo "Run Instances" >> tmplog |
||||
cd /home/ec2-user/projects/src/harmony-benchmark |
||||
./deploy_one_instance.sh global_nodes.txt |
@ -0,0 +1 @@ |
||||
echo "Bye" >> tmplog |
@ -1 +1 @@ |
||||
echo "Hi, I am in aws-scripts and its seems to have worked." |
||||
echo "Hello" >> tmplog |
@ -0,0 +1,16 @@ |
||||
aws ec2 request-spot-instances \ |
||||
--instance-count 1 \ |
||||
--block-duration-minutes 60 \ |
||||
--launch-specification "{ \ |
||||
\"ImageId\": \"ami-f2d3638a\", \ |
||||
\"InstanceType\": \"m3.medium\", \ |
||||
\"SecurityGroups\": [ \ |
||||
\"richard-spot-instance SSH\" \ |
||||
], \ |
||||
\"KeyName\": \"richard-spot-instance\", \ |
||||
\"IamInstanceProfile\": { \ |
||||
\"Name\": \"RichardCodeDeployInstanceRole\" \ |
||||
}, \ |
||||
\"UserData\": \"`base64 -w 0 userdata.sh`\" \ |
||||
}" \ |
||||
--dry-run # uncomment this line to send a real request. |
@ -0,0 +1,7 @@ |
||||
#!/bin/bash |
||||
yum -y update |
||||
yum install -y ruby |
||||
cd /home/ec2-user |
||||
curl -O https://aws-codedeploy-us-west-2.s3.amazonaws.com/latest/install |
||||
chmod +x ./install |
||||
./install auto |
Binary file not shown.
Loading…
Reference in new issue