Created
July 24, 2020 22:07
-
-
Save visualzhou/e05faeabd6c152e4d6f5baed630d24fe to your computer and use it in GitHub Desktop.
Jinja2 template to generate genny workload YAML file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jinja2 | |
templateLoader = jinja2.FileSystemLoader(searchpath="./") | |
templateEnv = jinja2.Environment(loader=templateLoader, extensions=["jinja2.ext.loopcontrols"]) | |
TEMPLATE_FILE = "template.yml.j2" | |
template = templateEnv.get_template(TEMPLATE_FILE) | |
threads = [1, 16, 32, 64, 128, 256, 512, 768, 1024] | |
s = template.render(threads = threads, total_phase = len(threads) * 8) | |
print(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SchemaVersion: 2018-07-01 | |
Owner: "@mongodb/repl" | |
Clients: | |
Default: | |
QueryOptions: | |
maxPoolSize: 10000 | |
Actors: | |
- Name: ParallelInsert-1 | |
Type: RunCommand | |
Threads: 1 | |
Phases: | |
- &Insert_WMajority | |
MetricsName: Insert_WMajority | |
Duration: 30 seconds | |
Database: test | |
Operations: | |
- OperationName: RunCommand | |
OperationIsQuiet: true | |
OperationCommand: | |
insert: myCollection | |
documents: &Doc [{a: {^FastRandomString: {length: 1000}}}] | |
writeConcern: {w: majority} | |
- &Nop {Nop: true} | |
- &Insert_W1_JTrue | |
MetricsName: Insert_W1_JTrue | |
Duration: 30 seconds | |
Database: test | |
Operations: | |
- OperationName: RunCommand | |
OperationIsQuiet: true | |
OperationCommand: | |
insert: myCollection | |
documents: *Doc | |
writeConcern: {w: 1, j: true} | |
- *Nop | |
- &Insert_WMajority_JFalse | |
MetricsName: Insert_WMajority_JFalse | |
Duration: 30 seconds | |
Database: test | |
Operations: | |
- OperationName: RunCommand | |
OperationIsQuiet: true | |
OperationCommand: | |
insert: myCollection | |
documents: *Doc | |
writeConcern: {w: majority, j: false} | |
- *Nop | |
- &Insert_W1 | |
MetricsName: Insert_W1 | |
Duration: 30 seconds | |
Database: test | |
Operations: | |
- OperationName: RunCommand | |
OperationIsQuiet: true | |
OperationCommand: | |
insert: myCollection | |
documents: *Doc | |
writeConcern: {w: 1} | |
- *Nop | |
- Phase: 8..{{ total_phase - 1 }} | |
Nop: true | |
{%- set ns = namespace(phase = 8) %} | |
{% for t in threads -%} | |
{%- if t == 1 %}{% continue %}{% endif %} | |
- Name: ParallelInsert-{{ t }} | |
Type: RunCommand | |
Threads: {{ t }} | |
Phases: | |
- Phase: 0..{{ ns.phase - 1}} | |
Nop: true | |
- *Insert_WMajority | |
- *Nop | |
- *Insert_W1_JTrue | |
- *Nop | |
- *Insert_WMajority_JFalse | |
- *Nop | |
- *Insert_W1 | |
- *Nop | |
{%- if ns.phase + 8 < total_phase %} | |
- Phase: {{ ns.phase + 8 }}..{{ total_phase - 1 }} | |
Nop: true | |
{%- endif %} | |
{%- set ns.phase = ns.phase + 8 %} | |
{% endfor %} | |
- Name: CleanUp | |
Type: RunCommand | |
Threads: 1 | |
Phases: | |
- *Nop | |
- &DropCollection | |
Repeat: 1 | |
Database: test | |
Operations: | |
- OperationName: RunCommand | |
OperationCommand: | |
drop: myCollection | |
writeConcern: {w: majority} | |
{%- for i in range((total_phase - 2) // 2) %} | |
- *Nop | |
- *DropCollection | |
{%- endfor %} | |
AutoRun: | |
Requires: | |
mongodb_setup: | |
- replica | |
- replica-noflowcontrol | |
PrepareEnvironmentWith: | |
mongodb_setup: | |
- replica-delay-mixed | |
- replica |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment