diff --git a/README.md b/README.md index b09ceb4..3ad107b 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,11 @@ This module proposes a simple and uncomplicated way to run your load tests creat module "loadtest" { source = "marcosborges/loadtest-distribuited/aws" - version = "1.0.0" name = "nome-da-implantacao" executor = "jmeter" loadtest_dir_source = "./assets" - loadtest_entrypoint = "jmeter -n -t -R \"{NODES_IPS}\" *.jmx" + loadtest_entrypoint = "jmeter -n -t jmeter/basic.jmx -R \"{NODES_IPS}\" *.jmx" nodes_size = 2 subnet_id = data.aws_subnet.current.id @@ -48,7 +47,6 @@ In its basic use it is necessary to provide information about which network will module "loadtest" { source = "marcosborges/loadtest-distribuited/aws" - version = "1.0.0" name = "nome-da-implantacao" executor = "bzt" @@ -87,7 +85,6 @@ The module also provides advanced settings. module "loadtest" { source = "marcosborges/loadtest-distribuited/aws" - version = "1.0.0" subnet_id = data.aws_subnet.current.id @@ -101,7 +98,9 @@ module "loadtest" { #AUTO SPLIT split_data_mass_between_nodes = { enable = true - data_mass_filename = "../plan/data/data.csv" + data_mass_filenames = [ + "../plan/data/data.csv" + ] } #EXPORT SSH KEY @@ -190,13 +189,6 @@ data "aws_ami" "my_image" { -## Examples with another executors - -- [Taurus](#taurus) -- [Jmeter](#jmeter) -- [Locust](#locust) -- [K6](#k6) - --- @@ -208,16 +200,14 @@ data "aws_ami" "my_image" { |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | | [aws](#requirement\_aws) | >= 3.63 | -| [null](#requirement\_null) | >= 3.1.0 | -| [tls](#requirement\_tls) | >= 3.1.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.63 | -| [null](#provider\_null) | >= 3.1.0 | -| [tls](#provider\_tls) | >= 3.1.0 | +| [null](#provider\_null) | n/a | +| [tls](#provider\_tls) | n/a | ## Modules @@ -227,15 +217,18 @@ No modules. | Name | Type | |------|------| -| [aws_iam_instance_profile.jmeter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | -| [aws_iam_role.jmeter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | +| [aws_iam_instance_profile.loadtest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | +| [aws_iam_role.loadtest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | [aws_instance.leader](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource | | [aws_instance.nodes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource | -| [aws_key_pair.jmeter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair) | resource | -| [aws_security_group.jmeter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | -| [null_resource.publish_split_data](https://registry.terraform.io/providers/hashicorp/terraform-provider-null/latest/docs/resources/resource) | resource | -| [null_resource.split_data](https://registry.terraform.io/providers/hashicorp/terraform-provider-null/latest/docs/resources/resource) | resource | -| [tls_private_key.jmeter](https://registry.terraform.io/providers/hashicorp/terraform-provider-tls/latest/docs/resources/private_key) | resource | +| [aws_key_pair.loadtest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair) | resource | +| [aws_security_group.loadtest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | +| [null_resource.executor](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [null_resource.key_pair_exporter](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [null_resource.publish_split_data](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [null_resource.split_data](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [tls_private_key.loadtest](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | resource | +| [aws_ami.amazon_linux_2](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | | [aws_subnet.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source | | [aws_vpc.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source | @@ -243,35 +236,38 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [auto\_execute](#input\_auto\_execute) | Execute Loadtest after leader and nodes available | `bool` | `true` | no | | [auto\_setup](#input\_auto\_setup) | Install and configure instances Amazon Linux2 with JMeter and Taurus | `bool` | `true` | no | | [executor](#input\_executor) | Executor of the loadtest | `string` | `"jmeter"` | no | | [jmeter\_version](#input\_jmeter\_version) | JMeter version | `string` | `"5.4.1"` | no | -| [leader\_ami\_id](#input\_leader\_ami\_id) | Id of the AMI | `string` | n/a | yes | +| [leader\_ami\_id](#input\_leader\_ami\_id) | Id of the AMI | `string` | `""` | no | | [leader\_associate\_public\_ip\_address](#input\_leader\_associate\_public\_ip\_address) | Associate public IP address to the leader | `bool` | `true` | no | +| [leader\_custom\_setup\_base64](#input\_leader\_custom\_setup\_base64) | Custom bash script encoded in base64 to setup the leader | `string` | `""` | no | | [leader\_instance\_type](#input\_leader\_instance\_type) | Instance type of the cluster leader | `string` | `"t2.medium"` | no | -| [leader\_jvm\_args](#input\_leader\_jvm\_args) | JVM Leader JVM\_ARGS | `string` | `" -Xms2g -Xmx4g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 "` | no | +| [leader\_jvm\_args](#input\_leader\_jvm\_args) | JVM Leader JVM\_ARGS | `string` | `" -Xms2g -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 "` | no | | [leader\_monitoring](#input\_leader\_monitoring) | Enable monitoring for the leader | `bool` | `true` | no | -| [leader\_tags](#input\_leader\_tags) | Tags of the cluster leader | `map` | n/a | yes | +| [leader\_tags](#input\_leader\_tags) | Tags of the cluster leader | `map` | `{}` | no | | [loadtest\_dir\_destination](#input\_loadtest\_dir\_destination) | Path to the destination loadtest directory | `string` | `"/loadtest"` | no | | [loadtest\_dir\_source](#input\_loadtest\_dir\_source) | Path to the source loadtest directory | `string` | n/a | yes | | [loadtest\_entrypoint](#input\_loadtest\_entrypoint) | Path to the entrypoint command | `string` | `"bzt -q -o execution.0.distributed=\"{NODES_IPS}\" *.yml"` | no | | [name](#input\_name) | Name of the provision | `string` | n/a | yes | -| [nodes\_ami\_id](#input\_nodes\_ami\_id) | Id of the AMI | `string` | n/a | yes | +| [nodes\_ami\_id](#input\_nodes\_ami\_id) | Id of the AMI | `string` | `""` | no | | [nodes\_associate\_public\_ip\_address](#input\_nodes\_associate\_public\_ip\_address) | Associate public IP address to the nodes | `bool` | `true` | no | +| [nodes\_custom\_setup\_base64](#input\_nodes\_custom\_setup\_base64) | Custom bash script encoded in base64 to setup the nodes | `string` | `""` | no | | [nodes\_intance\_type](#input\_nodes\_intance\_type) | Instance type of the cluster nodes | `string` | `"t2.medium"` | no | -| [nodes\_jvm\_args](#input\_nodes\_jvm\_args) | JVM Nodes JVM\_ARGS | `string` | `"-Xms4g -Xmx8g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Dnashorn.args=--no-deprecation-warning -XX:+HeapDumpOnOutOfMemoryError "` | no | +| [nodes\_jvm\_args](#input\_nodes\_jvm\_args) | JVM Nodes JVM\_ARGS | `string` | `"-Xms2g -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -Dnashorn.args=--no-deprecation-warning -XX:+HeapDumpOnOutOfMemoryError "` | no | | [nodes\_monitoring](#input\_nodes\_monitoring) | Enable monitoring for the leader | `bool` | `true` | no | | [nodes\_size](#input\_nodes\_size) | Total number of nodes in the cluster | `number` | `2` | no | -| [nodes\_tags](#input\_nodes\_tags) | Tags of the cluster nodes | `map` | n/a | yes | +| [nodes\_tags](#input\_nodes\_tags) | Tags of the cluster nodes | `map` | `{}` | no | | [region](#input\_region) | Name of the region | `string` | `"us-east-1"` | no | -| [split\_data\_mass\_between\_nodes](#input\_split\_data\_mass\_between\_nodes) | Split data mass between nodes |
object({
enable = bool
data_mass_filename = string
})
|
{
"data_mass_filename": "../plan/data/data.csv",
"enable": true
}
| no | -| [ssh\_cidr\_ingress\_block](#input\_ssh\_cidr\_ingress\_block) | SSH user for the leader | `list` |
[
"0.0.0.0/0"
]
| no | -| [ssh\_export\_pem](#input\_ssh\_export\_pem) | n/a | `bool` | `true` | no | +| [split\_data\_mass\_between\_nodes](#input\_split\_data\_mass\_between\_nodes) | Split data mass between nodes |
object({
enable = bool
data_mass_filename = string
})
|
{
"data_mass_filename": "../plan/data/data.csv",
"enable": false
}
| no | +| [ssh\_cidr\_ingress\_blocks](#input\_ssh\_cidr\_ingress\_blocks) | SSH user for the leader | `list` |
[
"0.0.0.0/0"
]
| no | +| [ssh\_export\_pem](#input\_ssh\_export\_pem) | n/a | `bool` | `false` | no | | [ssh\_user](#input\_ssh\_user) | SSH user for the leader | `string` | `"ec2-user"` | no | | [subnet\_id](#input\_subnet\_id) | Id of the subnet | `string` | n/a | yes | -| [tags](#input\_tags) | Common tags | `map` | n/a | yes | +| [tags](#input\_tags) | Common tags | `map` | `{}` | no | | [taurus\_version](#input\_taurus\_version) | Taurus version | `string` | `"1.16.0"` | no | -| [vpc\_id](#input\_vpc\_id) | Id of the VPC | `string` | n/a | yes | +| [web\_cidr\_ingress\_blocks](#input\_web\_cidr\_ingress\_blocks) | web for the leader | `list` |
[
"0.0.0.0/0"
]
| no | ## Outputs diff --git a/assets/split-cmd-result.png b/assets/split-cmd-result.png new file mode 100644 index 0000000..cb35829 Binary files /dev/null and b/assets/split-cmd-result.png differ diff --git a/assets/split-cmd.png b/assets/split-cmd.png new file mode 100644 index 0000000..95a16c0 Binary files /dev/null and b/assets/split-cmd.png differ diff --git a/assets/split-transfer.png b/assets/split-transfer.png new file mode 100644 index 0000000..09d5137 Binary files /dev/null and b/assets/split-transfer.png differ diff --git a/assets/split.png b/assets/split.png new file mode 100644 index 0000000..c814cd6 Binary files /dev/null and b/assets/split.png differ diff --git a/examples/basic/.terraform.lock.hcl b/examples/basic/.terraform.lock.hcl deleted file mode 100644 index 210b198..0000000 --- a/examples/basic/.terraform.lock.hcl +++ /dev/null @@ -1,57 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "3.63.0" - constraints = ">= 3.63.0" - hashes = [ - "h1:v9aPF3aaBpk0uSO5pfggYJKGgP/Ur28hZRJs1jS+ttI=", - "zh:42c6c98b294953a4e1434a331251e539f5372bf6779bd61ab5df84cac0545287", - "zh:5493773762a470889c9a23db97582d3a82035847c8d3bd13323b4c3012abf325", - "zh:550d22ff9fed4d817a922e7b84bd9d1f2ef8d3afa00832cf66b8cd5f0e6dc748", - "zh:632cb5e2d9d5041875f57174236eafe5b05dbf26750c1041ab57eb08c5369fe2", - "zh:7cfeaf5bde1b28bd010415af1f3dc494680a8374f1a26ec19db494d99938cc4e", - "zh:99d871606b67c8aefce49007315de15736b949c09a9f8f29ad8af1e9ce383ed3", - "zh:c4fc8539ffe90df5c7ae587fde495fac6bc0186fec2f2713a8988a619cef265f", - "zh:d0a26493206575c99ca221d78fe64f96a8fbcebe933af92eea6b39168c1f1c1d", - "zh:e156fdc964fdd4a7586ec15629e20d2b06295b46b4962428006e088145db07d6", - "zh:eb04fc80f652b5c92f76822f0fec1697581543806244068506aed69e1bb9b2af", - "zh:f5638a533cf9444f7d02b5527446cdbc3b2eab8bcc4ec4b0ca32035fe6f479d3", - ] -} - -provider "registry.terraform.io/hashicorp/null" { - version = "3.1.0" - hashes = [ - "h1:vpC6bgUQoJ0znqIKVFevOdq+YQw42bRq0u+H3nto8nA=", - "zh:02a1675fd8de126a00460942aaae242e65ca3380b5bb192e8773ef3da9073fd2", - "zh:53e30545ff8926a8e30ad30648991ca8b93b6fa496272cd23b26763c8ee84515", - "zh:5f9200bf708913621d0f6514179d89700e9aa3097c77dac730e8ba6e5901d521", - "zh:9ebf4d9704faba06b3ec7242c773c0fbfe12d62db7d00356d4f55385fc69bfb2", - "zh:a6576c81adc70326e4e1c999c04ad9ca37113a6e925aefab4765e5a5198efa7e", - "zh:a8a42d13346347aff6c63a37cda9b2c6aa5cc384a55b2fe6d6adfa390e609c53", - "zh:c797744d08a5307d50210e0454f91ca4d1c7621c68740441cf4579390452321d", - "zh:cecb6a304046df34c11229f20a80b24b1603960b794d68361a67c5efe58e62b8", - "zh:e1371aa1e502000d9974cfaff5be4cfa02f47b17400005a16f14d2ef30dc2a70", - "zh:fc39cc1fe71234a0b0369d5c5c7f876c71b956d23d7d6f518289737a001ba69b", - "zh:fea4227271ebf7d9e2b61b89ce2328c7262acd9fd190e1fd6d15a591abfa848e", - ] -} - -provider "registry.terraform.io/hashicorp/tls" { - version = "3.1.0" - hashes = [ - "h1:fUJX8Zxx38e2kBln+zWr1Tl41X+OuiE++REjrEyiOM4=", - "zh:3d46616b41fea215566f4a957b6d3a1aa43f1f75c26776d72a98bdba79439db6", - "zh:623a203817a6dafa86f1b4141b645159e07ec418c82fe40acd4d2a27543cbaa2", - "zh:668217e78b210a6572e7b0ecb4134a6781cc4d738f4f5d09eb756085b082592e", - "zh:95354df03710691773c8f50a32e31fca25f124b7f3d6078265fdf3c4e1384dca", - "zh:9f97ab190380430d57392303e3f36f4f7835c74ea83276baa98d6b9a997c3698", - "zh:a16f0bab665f8d933e95ca055b9c8d5707f1a0dd8c8ecca6c13091f40dc1e99d", - "zh:be274d5008c24dc0d6540c19e22dbb31ee6bfdd0b2cddd4d97f3cd8a8d657841", - "zh:d5faa9dce0a5fc9d26b2463cea5be35f8586ab75030e7fa4d4920cd73ee26989", - "zh:e9b672210b7fb410780e7b429975adcc76dd557738ecc7c890ea18942eb321a5", - "zh:eb1f8368573d2370605d6dbf60f9aaa5b64e55741d96b5fb026dbfe91de67c0d", - "zh:fc1e12b713837b85daf6c3bb703d7795eaf1c5177aebae1afcf811dd7009f4b0", - ] -} diff --git a/examples/basic/README.md b/examples/basic/README.md index 61a43c2..cc2e4fe 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -7,14 +7,13 @@ module "loadtest-distribuited" { source = "../../" #source = "marcosborges/loadtest-distribuited/aws" - #version = "0.0.8-alpha" name = "nome-da-implantacao" executor = "jmeter" loadtest_dir_source = "../plan/" nodes_size = 2 - loadtest_entrypoint = "jmeter -n -t jmeter/*.jmx -R \"{NODES_IPS}\" -l /var/logs/loadtest -e -o /var/www/html -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true " + loadtest_entrypoint = "jmeter -n -t jmeter/basic.jmx -R \"{NODES_IPS}\" -l /var/logs/loadtest -e -o /var/www/html -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true " subnet_id = data.aws_subnet.current.id } diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 1756464..1eb0ae8 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -9,8 +9,8 @@ module "loadtest" { loadtest_dir_source = "../plan/" nodes_size = 2 - loadtest_entrypoint = "jmeter -n -t jmeter/*.jmx -R \"{NODES_IPS}\" -l /loadtest/logs -e -o /var/www/html/jmeter -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true " + loadtest_entrypoint = "jmeter -n -t jmeter/basic.jmx -R \"{NODES_IPS}\" -l /loadtest/logs -e -o /var/www/html/jmeter -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true " - ssh_export_pem = true + ssh_export_pem = false subnet_id = data.aws_subnet.current.id } \ No newline at end of file diff --git a/examples/k6/README.md b/examples/k6/README.md index 53343a0..2efb34d 100644 --- a/examples/k6/README.md +++ b/examples/k6/README.md @@ -1,2 +1,2 @@ -# ManAtWork +# MenAtWork diff --git a/examples/plan/data/data.csv b/examples/plan/data/users.csv similarity index 100% rename from examples/plan/data/data.csv rename to examples/plan/data/users.csv diff --git a/examples/plan/jmeter/basic-with-data.jmx b/examples/plan/jmeter/basic-with-data.jmx new file mode 100644 index 0000000..d316a9f --- /dev/null +++ b/examples/plan/jmeter/basic-with-data.jmx @@ -0,0 +1,182 @@ + + + + + + false + true + false + + + + + + + + , + + /loadtest/data/users.csv + false + true + true + shareMode.all + false + name,email,password + + + + continue + + false + 1 + + 20 + 10 + true + 30 + 5 + true + true + + + + + + + google.com + 443 + https + + ?email=${email} + GET + false + true + true + false + true + true + + 1000 + 6000 + + + + + + + microsoft.com + 443 + https + + + GET + false + true + true + false + true + true + + 1000 + 6000 + + + + + + + facebook.com + 443 + https + + + GET + false + true + true + false + true + true + + 1000 + 6000 + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + diff --git a/examples/plan/jmeter/jmeter.log b/examples/plan/jmeter/jmeter.log deleted file mode 100644 index a2eb54a..0000000 --- a/examples/plan/jmeter/jmeter.log +++ /dev/null @@ -1,153 +0,0 @@ -2021-11-02 01:40:50,037 INFO o.a.j.u.JMeterUtils: Setting Locale to en_EN -2021-11-02 01:40:50,112 INFO o.a.j.JMeter: Loading user properties from: /opt/apache-jmeter-5.4.1/bin/user.properties -2021-11-02 01:40:50,113 INFO o.a.j.JMeter: Loading system properties from: /opt/apache-jmeter-5.4.1/bin/system.properties -2021-11-02 01:40:50,121 INFO o.a.j.JMeter: Copyright (c) 1998-2021 The Apache Software Foundation -2021-11-02 01:40:50,121 INFO o.a.j.JMeter: Version 5.4.1 -2021-11-02 01:40:50,121 INFO o.a.j.JMeter: java.version=14.0.2 -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: os.name=Linux -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: os.arch=amd64 -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: os.version=5.4.0-89-generic -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: file.encoding=UTF-8 -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: java.awt.headless=null -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: Max memory =8589934592 -2021-11-02 01:40:50,122 INFO o.a.j.JMeter: Available Processors =8 -2021-11-02 01:40:50,137 INFO o.a.j.JMeter: Default Locale=English (EN) -2021-11-02 01:40:50,137 INFO o.a.j.JMeter: JMeter Locale=English (EN) -2021-11-02 01:40:50,138 INFO o.a.j.JMeter: JMeterHome=/opt/apache-jmeter-5.4.1 -2021-11-02 01:40:50,138 INFO o.a.j.JMeter: user.dir =/home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter -2021-11-02 01:40:50,138 INFO o.a.j.JMeter: PWD =/home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter -2021-11-02 01:40:50,138 INFO o.a.j.JMeter: IP: 127.0.1.1 Name: marcosborges FullName: marcosborges -2021-11-02 01:40:50,608 INFO o.a.j.JMeter: Setting LAF to: com.github.weisj.darklaf.DarkLaf:com.github.weisj.darklaf.theme.DarculaTheme -2021-11-02 01:40:51,694 INFO o.a.j.JMeter: Loaded icon properties from org/apache/jmeter/images/icon.properties -2021-11-02 01:40:54,107 INFO o.a.j.JMeter: Loading file: basic.jmx -2021-11-02 01:40:54,110 INFO o.a.j.s.FileServer: Default base='/home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter' -2021-11-02 01:40:54,111 INFO o.a.j.s.FileServer: Set new base='/home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter' -2021-11-02 01:40:54,305 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 -2021-11-02 01:40:54,326 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0 -2021-11-02 01:40:54,328 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8 -2021-11-02 01:40:54,329 INFO o.a.j.s.SaveService: Loading file: basic.jmx -2021-11-02 01:40:54,358 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser -2021-11-02 01:40:54,358 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser -2021-11-02 01:40:54,359 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser -2021-11-02 01:40:54,359 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser -2021-11-02 01:40:54,359 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser -2021-11-02 01:40:54,359 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser -2021-11-02 01:40:54,386 INFO o.a.j.s.FileServer: Set new base='/home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter' -2021-11-02 01:41:40,188 ERROR o.a.j.g.a.Save: Failed to backup file: /home/marcosborges/s9c_jmeter_terraform_loadtest_provisioner/examples/plan/jmeter/basic.jmx -java.nio.file.AccessDeniedException: /opt/apache-jmeter-5.4.1/backups/basic-000001.jmx - at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?] - at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?] - at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?] - at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:246) ~[?:?] - at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:601) ~[?:?] - at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258) ~[?:?] - at java.nio.file.Files.copy(Files.java:1299) ~[?:?] - at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:1392) ~[commons-io-2.8.0.jar:2.8.0] - at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:885) ~[commons-io-2.8.0.jar:2.8.0] - at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:835) ~[commons-io-2.8.0.jar:2.8.0] - at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:802) ~[commons-io-2.8.0.jar:2.8.0] - at org.apache.jmeter.gui.action.Save.createBackupFile(Save.java:381) ~[ApacheJMeter_core.jar:5.4.1] - at org.apache.jmeter.gui.action.Save.backupAndSave(Save.java:244) ~[ApacheJMeter_core.jar:5.4.1] - at org.apache.jmeter.gui.action.Save.doAction(Save.java:173) ~[ApacheJMeter_core.jar:5.4.1] - at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:87) ~[ApacheJMeter_core.jar:5.4.1] - at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:69) ~[ApacheJMeter_core.jar:5.4.1] - at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) ~[?:?] - at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) ~[?:?] - at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?] - at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?] - at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?] - at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?] - at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) [?:?] - at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?] - at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?] - at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?] - at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?] - at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?] - at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?] -2021-11-02 01:42:11,478 INFO o.a.j.e.StandardJMeterEngine: Running the test! -2021-11-02 01:42:11,479 INFO o.a.j.s.SampleEvent: List of sample_variables: [] -2021-11-02 01:42:11,479 INFO o.a.j.s.SampleEvent: List of sample_variables: [] -2021-11-02 01:42:11,481 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must contain the string: '.functions.' -2021-11-02 01:42:11,482 INFO o.a.j.e.u.CompoundVariable: Note: Function class names must not contain the string: '.gui.' -2021-11-02 01:42:11,808 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*) -2021-11-02 01:42:11,861 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group -2021-11-02 01:42:11,862 INFO o.a.j.e.StandardJMeterEngine: Starting 20 threads for group Thread Group. -2021-11-02 01:42:11,862 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error -2021-11-02 01:42:11,862 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=20 ramp-up=10 delayedStart=true -2021-11-02 01:42:11,863 INFO o.a.j.t.ThreadGroup: Started thread group number 1 -2021-11-02 01:42:11,863 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started -2021-11-02 01:42:16,876 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1 -2021-11-02 01:42:16,905 INFO o.a.j.p.h.s.HTTPHCAbstractImpl: Local host = marcosborges -2021-11-02 01:42:16,913 INFO o.a.j.p.h.s.HTTPHC4Impl: HTTP request retry count = 0 -2021-11-02 01:42:16,915 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times -2021-11-02 01:42:16,915 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1 -2021-11-02 01:42:16,915 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true -2021-11-02 01:42:16,915 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000 -2021-11-02 01:42:17,261 INFO o.a.j.p.h.s.h.LazyLayeredConnectionSocketFactory: Setting up HTTPS TrustAll Socket Factory -2021-11-02 01:42:17,265 INFO o.a.j.u.JsseSSLManager: Using default SSL protocol: TLS -2021-11-02 01:42:17,265 INFO o.a.j.u.JsseSSLManager: SSL session context: per-thread -2021-11-02 01:42:17,399 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-2 -2021-11-02 01:42:17,765 INFO o.a.j.u.SSLManager: JmeterKeyStore Location: type JKS -2021-11-02 01:42:17,768 INFO o.a.j.u.SSLManager: KeyStore created OK -2021-11-02 01:42:17,768 WARN o.a.j.u.SSLManager: Keystore file not found, loading empty keystore -2021-11-02 01:42:17,926 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-3 -2021-11-02 01:42:18,456 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-4 -2021-11-02 01:42:18,982 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-5 -2021-11-02 01:42:19,507 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-6 -2021-11-02 01:42:20,034 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-7 -2021-11-02 01:42:20,559 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-8 -2021-11-02 01:42:21,086 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-9 -2021-11-02 01:42:21,611 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-10 -2021-11-02 01:42:22,138 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-11 -2021-11-02 01:42:22,664 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-12 -2021-11-02 01:42:23,189 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-13 -2021-11-02 01:42:23,715 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-14 -2021-11-02 01:42:24,242 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-15 -2021-11-02 01:42:24,766 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-16 -2021-11-02 01:42:25,060 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-5 -2021-11-02 01:42:25,060 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-5 -2021-11-02 01:42:25,185 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-2 -2021-11-02 01:42:25,185 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-2 -2021-11-02 01:42:25,291 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-17 -2021-11-02 01:42:25,577 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-6 -2021-11-02 01:42:25,577 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1 -2021-11-02 01:42:25,577 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-6 -2021-11-02 01:42:25,578 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1 -2021-11-02 01:42:25,585 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-7 -2021-11-02 01:42:25,585 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-7 -2021-11-02 01:42:25,700 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-4 -2021-11-02 01:42:25,700 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-4 -2021-11-02 01:42:25,737 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-8 -2021-11-02 01:42:25,737 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-8 -2021-11-02 01:42:25,799 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-3 -2021-11-02 01:42:25,799 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-3 -2021-11-02 01:42:25,815 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-18 -2021-11-02 01:42:25,855 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-9 -2021-11-02 01:42:25,855 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-9 -2021-11-02 01:42:26,341 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-19 -2021-11-02 01:42:26,343 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-10 -2021-11-02 01:42:26,343 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-10 -2021-11-02 01:42:26,748 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-11 -2021-11-02 01:42:26,748 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-11 -2021-11-02 01:42:26,865 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-20 -2021-11-02 01:42:27,290 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-13 -2021-11-02 01:42:27,290 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-13 -2021-11-02 01:42:27,304 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-14 -2021-11-02 01:42:27,304 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-14 -2021-11-02 01:42:27,413 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-12 -2021-11-02 01:42:27,413 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-12 -2021-11-02 01:42:27,810 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-16 -2021-11-02 01:42:27,810 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-16 -2021-11-02 01:42:28,116 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-17 -2021-11-02 01:42:28,116 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-17 -2021-11-02 01:42:28,454 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-15 -2021-11-02 01:42:28,454 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-15 -2021-11-02 01:42:28,503 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-18 -2021-11-02 01:42:28,504 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-18 -2021-11-02 01:42:28,952 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-19 -2021-11-02 01:42:28,952 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-19 -2021-11-02 01:42:29,640 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-20 -2021-11-02 01:42:29,640 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-20 -2021-11-02 01:42:29,644 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test -2021-11-02 01:42:29,646 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*) diff --git a/examples/split-data/README.md b/examples/split-data/README.md new file mode 100644 index 0000000..06cd5d6 --- /dev/null +++ b/examples/split-data/README.md @@ -0,0 +1,55 @@ +# Split data between nodes + +The implementation for dividing the data mass file between the load executing nodes aims to uncomplicate this existing friction in the execution of distributed load tests; + +Is very simple to activate this option. + +Just set the `split_data_mass_between_nodes` variable by activating the feature and informing your mass data files to be distributed. + +See the example below... + +## Example + +```hcl +module "loadtest" { + + source = "marcosborges/loadtest-distribuited/aws" + + name = "nome-da-implantacao" + executor = "jmeter" + loadtest_dir_source = "../plan/" + nodes_size = 2 + + loadtest_entrypoint = "jmeter -n -t jmeter/basic-with-data.jmx -R \"{NODES_IPS}\" -l /loadtest/logs -e -o /var/www/html/jmeter -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true -LDEBUG " + + split_data_mass_between_nodes = { + enable = true + data_mass_filenames = [ + "data/users.csv" + ] + } + + subnet_id = data.aws_subnet.current.id +} +``` +--- + +## Behind the scene: + +1. sends all data mass files to the leader. + +![split](https://github.com/marcosborges/terraform-aws-loadtest-distribuited/raw/master/assets/split-cmd.png) + +2. After submission, the files are divided by the leader into fragments by us for each nodes. + +![split-result](https://github.com/marcosborges/terraform-aws-loadtest-distribuited/raw/master/assets/split-cmd-result.png) + +3. The last action is to send each fragment to its respective node. + +![split-result](https://github.com/marcosborges/terraform-aws-loadtest-distribuited/raw/master/assets/split-transfer.png) + +*Splitting the files uses the linux `split` command and splits the main file into 1 fragment for each node.* + +More info: [Split doc](https://man7.org/linux/man-pages/man1/split.1.html) + +--- \ No newline at end of file diff --git a/examples/split-data/data.tf b/examples/split-data/data.tf new file mode 100644 index 0000000..9ad876f --- /dev/null +++ b/examples/split-data/data.tf @@ -0,0 +1,7 @@ + +data "aws_subnet" "current" { + filter { + name = "tag:Name" + values = ["subnet-prd-a"] + } +} \ No newline at end of file diff --git a/examples/split-data/main.tf b/examples/split-data/main.tf new file mode 100644 index 0000000..d8752a0 --- /dev/null +++ b/examples/split-data/main.tf @@ -0,0 +1,24 @@ +module "loadtest" { + + source = "../../" + #source = "marcosborges/loadtest-distribuited/aws" + + name = "nome-da-implantacao" + executor = "jmeter" + loadtest_dir_source = "../plan/" + nodes_size = 2 + + loadtest_entrypoint = "jmeter -n -t jmeter/basic-with-data.jmx -R \"{NODES_IPS}\" -l /loadtest/logs -e -o /var/www/html/jmeter -Dnashorn.args=--no-deprecation-warning -Dserver.rmi.ssl.disable=true -LDEBUG " + + split_data_mass_between_nodes = { + enable = true + data_mass_filenames = [ + "data/users.csv" + ] + } + + subnet_id = data.aws_subnet.current.id + + ssh_export_pem = true +} + diff --git a/examples/split-data/output.tf b/examples/split-data/output.tf new file mode 100644 index 0000000..8c7dc97 --- /dev/null +++ b/examples/split-data/output.tf @@ -0,0 +1,24 @@ +output "leader_public_ip" { + value = module.loadtest.leader_public_ip + description = "The public IP address of the leader server instance." +} + +output "leader_private_ip" { + value = module.loadtest.leader_private_ip + description = "The private IP address of the leader server instance." +} + +output "nodes_public_ip" { + value = module.loadtest.nodes_public_ip + description = "The public IP address of the nodes instances." +} + +output "nodes_private_ip" { + value = module.loadtest.nodes_private_ip + description = "The private IP address of the nodes instances." +} + +output "dashboard_url" { + value = "http://${coalesce(module.loadtest.leader_public_ip, module.loadtest.leader_private_ip)}/${var.executor}" + description = "The URL of the loadtest dashboard." +} \ No newline at end of file diff --git a/examples/split-data/provider.tf b/examples/split-data/provider.tf new file mode 100644 index 0000000..521cb84 --- /dev/null +++ b/examples/split-data/provider.tf @@ -0,0 +1,3 @@ +provider "aws" { + region = "us-east-1" +} \ No newline at end of file diff --git a/examples/split-data/variables.tf b/examples/split-data/variables.tf new file mode 100644 index 0000000..c8d1955 --- /dev/null +++ b/examples/split-data/variables.tf @@ -0,0 +1,4 @@ +variable "executor" { + description = "Executor name" + default = "jmeter" +} \ No newline at end of file diff --git a/executor.tf b/executor.tf index a1a92f0..ce4a099 100644 --- a/executor.tf +++ b/executor.tf @@ -24,6 +24,16 @@ locals { waiting_command = "while [ ! -f /tmp/finished-setup ]; do echo 'waiting setup to be instaled'; sleep 5; done" nodes_ips = local.executor.nodes_ips + entrypoint = replace( + replace( + var.loadtest_entrypoint, + "{NODES_IPS}", + local.nodes_ips + ), + "{LEADER_IP}", + local.leader_private_ip + ) + } resource "null_resource" "executor" { @@ -31,8 +41,9 @@ resource "null_resource" "executor" { count = local.auto_execute ? 1 : 0 depends_on = [ - aws_instance.leader, - aws_instance.nodes + null_resource.spliter_execute_command, + aws_instance.nodes, + aws_instance.leader ] connection { @@ -42,7 +53,7 @@ resource "null_resource" "executor" { private_key = tls_private_key.loadtest.private_key_pem } - #EXECUTE SCRIPTS + #WAITING FOR INSTANCE FINISHING SETUP provisioner "remote-exec" { inline = [ "echo 'START EXECUTION'", @@ -50,22 +61,27 @@ resource "null_resource" "executor" { ] } + #CLEANING UP provisioner "remote-exec" { inline = [ - "echo DIR: ${var.loadtest_dir_destination}", - "cd ${var.loadtest_dir_destination}", - "echo PATH: $PATH", - "echo JVM_ARGS: $JVM_ARGS", "sudo chmod 777 /var/www/html -Rf", "sudo rm -rf /var/www/html/*", "sudo rm -rf /loadtest/logs", - "echo ${replace(var.loadtest_entrypoint, "{NODES_IPS}", local.nodes_ips)}", - replace(var.loadtest_entrypoint, "{NODES_IPS}", local.nodes_ips) ] } - # triggers = { - # always_run = timestamp() - # } + #EXECUTING LOAD TEST + provisioner "remote-exec" { + inline = [ + "echo DIR: ${var.loadtest_dir_destination}", + "cd ${var.loadtest_dir_destination}", + "echo ${local.entrypoint}", + local.entrypoint + ] + } + + triggers = { + always_run = timestamp() + } } diff --git a/leader.tf b/leader.tf index 3e1b4cb..e5801e5 100644 --- a/leader.tf +++ b/leader.tf @@ -24,10 +24,13 @@ resource "aws_instance" "leader" { provisioner "remote-exec" { inline = [ + "echo '${tls_private_key.loadtest.private_key_pem}' > ~/.ssh/id_rsa", + "chmod 600 ~/.ssh/id_rsa", "sudo mkdir -p ${var.loadtest_dir_destination} || true", "sudo chown ${var.ssh_user}:${var.ssh_user} ${var.loadtest_dir_destination} || true" ] } + #-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null provisioner "file" { destination = var.loadtest_dir_destination @@ -42,3 +45,9 @@ resource "aws_instance" "leader" { } ) } + + +resource "null_resource" "push_key_pair_to_leader" { + + +} \ No newline at end of file diff --git a/nodes.tf b/nodes.tf index c6d9583..2f038e2 100644 --- a/nodes.tf +++ b/nodes.tf @@ -14,7 +14,7 @@ resource "aws_instance" "nodes" { iam_instance_profile = aws_iam_instance_profile.loadtest.name user_data_base64 = local.nodes_user_data_base64 - #PUBLISHING SCRIPTS AND DATA + key_name = aws_key_pair.loadtest.key_name connection { host = coalesce(self.public_ip, self.private_ip) @@ -23,18 +23,24 @@ resource "aws_instance" "nodes" { private_key = tls_private_key.loadtest.private_key_pem } + + # CONFIG FILESYSTEM AND PERMITIONS provisioner "remote-exec" { inline = [ + "echo '${tls_private_key.loadtest.private_key_pem}' > ~/.ssh/id_rsa", + "chmod 600 ~/.ssh/id_rsa", "sudo mkdir -p ${var.loadtest_dir_destination} || true", "sudo chown ${var.ssh_user}:${var.ssh_user} ${var.loadtest_dir_destination} || true" ] } + # PUBLISH ALL FILES provisioner "file" { destination = var.loadtest_dir_destination source = var.loadtest_dir_source } + # WAITING FOR NODES TO BE READY provisioner "remote-exec" { inline = [ "echo 'START EXECUTION'", diff --git a/scripts/entrypoint.leader.full.sh.tpl b/scripts/entrypoint.leader.full.sh.tpl index e1a4a1a..db8eb53 100644 --- a/scripts/entrypoint.leader.full.sh.tpl +++ b/scripts/entrypoint.leader.full.sh.tpl @@ -1,7 +1,7 @@ #!/bin/bash sudo yum update -y -sudo yum install -y pcre2-devel.x86_64 python gcc python3-devel tzdata curl unzip bash java-11-amazon-corretto htop httpd +sudo yum install -y pcre2-devel.x86_64 python gcc python3-devel tzdata curl unzip bash java-11-amazon-corretto htop httpd k6 # APACHE sudo systemctl enable httpd @@ -13,6 +13,10 @@ sudo rm -rf /var/www/html/* export BZT_VERSION="1.16.0" sudo pip3 install bzt==$BZT_VERSION +# LOCUST +export LOCUST_VERSION="2.4.3" +sudo pip3 install locust==$LOCUST_VERSION + # JMETER export MIRROR_HOST=https://archive.apache.org/dist/jmeter export JMETER_VERSION="5.4.1" @@ -56,4 +60,8 @@ sudo curl -L --silent https://search.maven.org/remotecontent?filepath=kg/apc/jme sudo curl -L --silent https://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-tst/2.5/jmeter-plugins-tst-2.5.jar -o $JMETER_PLUGINS_FOLDER/jmeter-plugins-tst-2.5.jar +mkdir -p ~/.ssh +echo 'Host *' > ~/.ssh/config +echo 'StrictHostKeyChecking no' >> ~/.ssh/config + touch /tmp/finished-setup diff --git a/scripts/entrypoint.node.full.sh.tpl b/scripts/entrypoint.node.full.sh.tpl index 3555112..fe82a43 100644 --- a/scripts/entrypoint.node.full.sh.tpl +++ b/scripts/entrypoint.node.full.sh.tpl @@ -1,12 +1,17 @@ #!/bin/bash sudo yum update -y -sudo yum install -y pcre2-devel.x86_64 python gcc python3-devel tzdata curl unzip bash java-11-amazon-corretto htop +sudo yum install -y pcre2-devel.x86_64 python gcc python3-devel tzdata curl unzip bash java-11-amazon-corretto htop k6 # TAURUS export BZT_VERSION="1.16.0" sudo pip3 install bzt==$BZT_VERSION +# LOCUST +export LOCUST_VERSION="2.4.3" +sudo pip3 install locust==$LOCUST_VERSION + + # JMETER export MIRROR_HOST=https://archive.apache.org/dist/jmeter export JMETER_VERSION="5.4.1" @@ -51,6 +56,10 @@ sudo curl -L --silent https://search.maven.org/remotecontent?filepath=kg/apc/jme source ~/.bashrc +mkdir -p ~/.ssh +echo 'Host *' > ~/.ssh/config +echo 'StrictHostKeyChecking no' >> ~/.ssh/config + touch /tmp/finished-setup # START JMETER NODE diff --git a/security.tf b/security.tf index 2e18808..d714e0e 100644 --- a/security.tf +++ b/security.tf @@ -114,3 +114,6 @@ resource "null_resource" "key_pair_exporter" { } + + + diff --git a/slipter.tf b/slipter.tf index 5217d65..68dd580 100644 --- a/slipter.tf +++ b/slipter.tf @@ -1,49 +1,79 @@ locals { - split_enable = var.split_data_mass_between_nodes.enable - split_data_mass_filename = var.split_data_mass_between_nodes.data_mass_filename + spliter_enable = var.split_data_mass_between_nodes.enable split_size = var.nodes_size - split_cmd = local.split_enable ? "split -a 3 -d -nr/${local.split_size} ${local.split_data_mass_filename} ${local.split_data_mass_filename}" : "echo 'auto split disabled'" -} + split_data_mass_filenames = local.spliter_enable ? var.split_data_mass_between_nodes.data_mass_filenames : [] -resource "null_resource" "split_data" { - provisioner "local-exec" { - command = local.split_cmd - } -} + # SPLIT COMMAND TEMPLATE + split_cmd_tpl = "split -a 3 -d -nr/${local.split_size} ${var.loadtest_dir_destination}/{FILENAME} ${var.loadtest_dir_destination}/{FILENAME}" + # RENDERIZATION COMMAND TEMPLATE + leader_split_cmds = [for file in local.split_data_mass_filenames : replace(local.split_cmd_tpl, "{FILENAME}", file)] + # SKIP SSH/SCP HOST VERIFICATION + ssh_skip_hosts_verification = " -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null " + # TRANSFER SCP COMMAND TEMPLATE + scp_cmd_tpl = "scp ${local.ssh_skip_hosts_verification} ${var.loadtest_dir_destination}/{FILE_IN} ${var.ssh_user}@{HOST}:${var.loadtest_dir_destination}/{FILE_OUT}" + # RENDERIZATION CLEANUP SCP COMMAND + leader_scp_cmds = flatten([ + for file in local.split_data_mass_filenames : [ + for index, host in aws_instance.nodes : [ + replace( + replace( + replace( + local.scp_cmd_tpl, + "{FILE_IN}", + "${file}${format("%03d", index)}" + ), + "{FILE_OUT}", + file + ), + "{HOST}", + host.private_ip + ) + ] + ] + ]) -resource "null_resource" "publish_split_data" { + # CLEANUP SSH COMMAND TEMPLATE OF INTO NODES BY LEADER + leader_ssh_nodes_cleanup_cmd_tpl = "ssh ${local.ssh_skip_hosts_verification} ${var.ssh_user}@{HOST} -c \"rm -rf ${var.loadtest_dir_destination}/{FILE}\" || true" + # RENDERIZATION CLEANUP SSH COMMAND + leader_ssh_nodes_cleanup_cmds = flatten([ + for file in local.split_data_mass_filenames : [ + for host in aws_instance.nodes : [ + replace( + replace( + local.leader_ssh_nodes_cleanup_cmd_tpl, + "{FILE}", + file + ), + "{HOST}", + host.private_ip + ) + ] + ] + ]) - count = local.split_enable ? var.nodes_size : 0 + # JOIN COMMANDS TO BE EXECUTED BY LEADER + leader_cmds = concat( + local.leader_split_cmds, + local.leader_ssh_nodes_cleanup_cmds, + local.leader_scp_cmds + ) +} - depends_on = [ - null_resource.split_data, - aws_instance.nodes - ] +resource "null_resource" "spliter_execute_command" { + + # CONNECT TO LEADER connection { - host = coalesce(aws_instance.nodes[count.index].public_ip, aws_instance.nodes[count.index].private_ip) + host = coalesce(aws_instance.leader.public_ip, aws_instance.leader.private_ip) type = "ssh" user = var.ssh_user private_key = tls_private_key.loadtest.private_key_pem } + # EXECUTION OF ALL COMMANDS DEFINED INTO local.leader_cmds provisioner "remote-exec" { - inline = [ - "sudo mkdir -p ${var.loadtest_dir_destination}|| true", - "sudo chown ${var.ssh_user}:${var.ssh_user} ${var.loadtest_dir_destination} || true" - ] - } - - provisioner "remote-exec" { - inline = [ - #"while [ ! -f /var/lib/apache-jmeter-5.3/bin/jmeter ]; do sleep 10; done", - "echo ${var.loadtest_dir_destination} ${format("%03d", count.index)}" - ] + inline = local.leader_cmds } - - #provisioner "file" { - # source = "${var.loadtest_dir_source}${format("%03d", count.index)}" - # destination = "${var.loadtest_dir_destination}/${var.loadtest_dir_source}" - #} + } diff --git a/variables.tf b/variables.tf index 268949e..b1157a1 100644 --- a/variables.tf +++ b/variables.tf @@ -26,11 +26,11 @@ variable "loadtest_dir_destination" { variable "split_data_mass_between_nodes" { type = object({ enable = bool - data_mass_filename = string + data_mass_filenames = list(string) }) default = { enable = false - data_mass_filename = "../plan/data/data.csv" + data_mass_filenames = ["../plan/data/data.csv"] } description = "Split data mass between nodes" }