mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
Merge pull request #7768 from wenottingham/add-some-nozzles
Create marginally more realistic event data with firehose Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -26,9 +26,11 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
|
import itertools
|
||||||
import json
|
import json
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
import random
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
@@ -58,40 +60,52 @@ u = str(uuid4())
|
|||||||
|
|
||||||
STATUS_OPTIONS = ('successful', 'failed', 'error', 'canceled')
|
STATUS_OPTIONS = ('successful', 'failed', 'error', 'canceled')
|
||||||
|
|
||||||
|
EVENT_OPTIONS = ('runner_on_ok', 'runner_on_failed', 'runner_on_changed', 'runner_on_skipped', 'runner_on_unreachable')
|
||||||
|
|
||||||
|
MODULE_OPTIONS = ('yup', 'stonchronize', 'templotz', 'deboog')
|
||||||
|
|
||||||
|
|
||||||
class YieldedRows(StringIO):
|
class YieldedRows(StringIO):
|
||||||
|
|
||||||
def __init__(self, job_id, rows, created_stamp, modified_stamp, *args, **kwargs):
|
def __init__(self, job_id, rows, created_stamp, modified_stamp, *args, **kwargs):
|
||||||
self.rows = rows
|
self.rows = rows
|
||||||
self.row = "\t".join([
|
self.rowlist = []
|
||||||
f"{created_stamp}",
|
for (event, module) in itertools.product(EVENT_OPTIONS, MODULE_OPTIONS):
|
||||||
f"{modified_stamp}",
|
event_data_json = {
|
||||||
"playbook_on_start",
|
"task_action": module,
|
||||||
"{}",
|
"name": "Do a {} thing".format(module),
|
||||||
'false',
|
"task": "Do a {} thing".format(module)
|
||||||
'false',
|
}
|
||||||
"localhost",
|
row = "\t".join([
|
||||||
"Example Play",
|
f"{created_stamp}",
|
||||||
"Hello World",
|
f"{modified_stamp}",
|
||||||
"",
|
event,
|
||||||
"0",
|
json.dumps(event_data_json),
|
||||||
"1",
|
str(event in ('runner_on_failed', 'runner_on_unreachable')),
|
||||||
job_id,
|
str(event == 'runner_on_changed'),
|
||||||
u,
|
"localhost",
|
||||||
"",
|
"Example Play",
|
||||||
"1",
|
"Hello World",
|
||||||
"hello_world.yml",
|
"",
|
||||||
"0",
|
"0",
|
||||||
"X",
|
"1",
|
||||||
"1",
|
job_id,
|
||||||
]) + '\n'
|
u,
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"hello_world.yml",
|
||||||
|
"0",
|
||||||
|
"X",
|
||||||
|
"1",
|
||||||
|
]) + '\n'
|
||||||
|
self.rowlist.append(row)
|
||||||
|
|
||||||
def read(self, x):
|
def read(self, x):
|
||||||
if self.rows <= 0:
|
if self.rows <= 0:
|
||||||
self.close()
|
self.close()
|
||||||
return ''
|
return ''
|
||||||
self.rows -= 10000
|
self.rows -= 1000
|
||||||
return self.row * 10000
|
return self.rowlist[random.randrange(len(self.rowlist))] * 1000
|
||||||
|
|
||||||
|
|
||||||
def firehose(job, count, created_stamp, modified_stamp):
|
def firehose(job, count, created_stamp, modified_stamp):
|
||||||
|
|||||||
Reference in New Issue
Block a user