# ERP5: id-store-interval must be big enough to avoid conflicts (e.g. 1000)

[buildout]
extends = test-fluentd-common.cfg

[template-erp5-patched]
extra =
  {%- for family_name, zope_section_id_list in zope_family_dict.items() %}
  {%-   for zope_section_id in zope_section_id_list %}
  [{{zope_section_id}}]
  config-family = {{family_name}}
  {%-   endfor %}
  {%- endfor %}

[template-zope]
recipe =
target = ${template-zope-patched:location}

[template-zope-base]
<= template-zope
recipe = slapos.recipe.build:download

[template-zope-patched]
<= template-fluentd
base = ${template-zope-base:target}
tags =
  {%- if slapparameter_dict['family'] == 'fluentd' %}
  {%- for i, zope in enumerate(publish_list) %}
  {%-   do tags.__setitem__(
      node_id_base ~ (node_id_index_format % i) ~ '-stream', zope[0]) %}
  {%- endfor %}
  {%- endif %}

[feeder]
feeder =
  # Same algorithm as ERP5Site_simulateFluentdIngestion
    import os, struct
    from random import lognormvariate
    pack = struct.Struct('!d').pack
    size = 65536
    data = os.urandom(size - 8)
    while True:
      emit('',
        ''.join((pack(time.time()) + data[:int(lognormvariate(10, 1))]
                ).ljust(size, '\0') for i in xrange(16)))
      time.sleep(interval)
