Skip to content

Commit

Permalink
Provision the instance with all the tools
Browse files Browse the repository at this point in the history
Install the required tooling and code to run the benchmarks.
  • Loading branch information
suizman committed Jun 11, 2018
1 parent 8b10509 commit cf6d597
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
qed

# Autogenerated code
tests/plot.hmtl
Expand Down
25 changes: 25 additions & 0 deletions tests/cloud/aws/install-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh

# Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Get developement tools and build Wrk
sudo yum groupinstall 'Development Tools' -y
sudo yum install -y openssl-devel git -y
git clone https://github.com/wg/wrk.git wrk
cd wrk
echo "Building Wrk. Check logs at /tmp/wrk_make.log"
make >> /tmp/wrk_make.log
# move the executable to somewhere in your PATH
sudo cp wrk /usr/bin/wrk
69 changes: 68 additions & 1 deletion cloud-benchmark/aws/main.tf → tests/cloud/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,78 @@ module "ec2" {
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
vpc_security_group_ids = ["${module.security_group.this_security_group_id}"]
associate_public_ip_address = true
key_name = "${aws_key_pair.qed-benchmark.key_name}"
key_name = "${aws_key_pair.qed-benchmark.key_name}"

root_block_device = [{
volume_type = "gp2"
volume_size = "${var.volume_size}"
delete_on_termination = true
}]
}

// Build qed and outputs a single binary file
resource "null_resource" "build-qed" {
provisioner "local-exec" {
command = "go build ../../../"
}

depends_on = ["aws_eip.qed-benchmark"]

}

// Copies qed binary and bench tools to out EC2 instance using SSH
resource "null_resource" "copy-qed" {
provisioner "file" {
source = "../../../tests"
destination = "/tmp/qed"

connection {
host = "${aws_eip.qed-benchmark.public_ip}"
type = "ssh"
private_key = "${file("~/.ssh/id_rsa")}"
user = "ec2-user"
timeout = "5m"
}
}

depends_on = ["null_resource.build-qed"]

}

resource "null_resource" "install-tools" {
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/qed/cloud/aws/install-tools /tmp/qed/cloud/aws/stress-throughput-60s /tmp/qed/cloud/aws/qed",
"/tmp/qed/cloud/aws/install-tools",
]
connection {
host = "${aws_eip.qed-benchmark.public_ip}"
type = "ssh"
private_key = "${file("~/.ssh/id_rsa")}"
user = "ec2-user"
timeout = "5m"
}
}

depends_on = ["null_resource.copy-qed"]

}

resource "null_resource" "run-benchmarks" {
provisioner "remote-exec" {
inline = [
"/tmp/qed/cloud/aws/stress-throughput-60s",
]

connection {
host = "${aws_eip.qed-benchmark.public_ip}"
type = "ssh"
private_key = "${file("~/.ssh/id_rsa")}"
user = "ec2-user"
timeout = "5m"
}
}

depends_on = ["null_resource.install-tools"]

}
File renamed without changes.
30 changes: 30 additions & 0 deletions tests/cloud/aws/stress-throughput-60s
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env sh

# Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

echo Starting server...
/tmp/qed/cloud/aws/qed start -k pepe -p $(mktemp -d /var/tmp/demo.XXX) -l info &
echo done.

sleep 10

echo Stress time!
wrk -t100 -c100 -d60s --latency -s /tmp/qed/attack_add/attack_add.lua http://localhost:8080
echo done.

echo Cleanup...
/sbin/fuser -k -n tcp 8080
rm -rf /var/tmp/demo.*
echo done.
File renamed without changes.

0 comments on commit cf6d597

Please sign in to comment.