def setUp(self): config = export_agent.ExportAgentConfiguration( doc_id = 'test-config', notification_period = 1) dbtools.initial_data(config) self.override_config('export_agent', config) return common.SimulationTest.setUp(self)
def setUp(self): config = everything.shard_agent.ShardAgentConfiguration( doc_id = u'test-config', hosts_per_shard = 2) dbtools.initial_data(config) self.override_config('shard_agent', config) return common.SimulationTest.setUp(self)
def testRevertingDocuments(self): old = dbtools.get_current_initials() dbtools.initial_data(SomeDocument) current = dbtools.get_current_initials() self.assertEqual(len(old) + 1, len(current)) dbtools.reset_documents(old) current = dbtools.get_current_initials() self.assertEqual(len(old), len(current))
def setUp(self): config = export_agent.ExportAgentConfiguration(doc_id="test-export-config", notification_period=1) dbtools.initial_data(config) self.override_config("export_agent", config) config = shard_agent.ShardAgentConfiguration(doc_id="test-shard-config", hosts_per_shard=1) dbtools.initial_data(config) self.override_config("shard_agent", config) return common.SimulationTest.setUp(self)
def setUp(self): # override the configuration of connection agent # we do this here only to demonstrate this is possibility # keep in mind that it needs to be done before the setUp of # SimulationTest, which creates the simulation driver. config = everything.connection_agent.ConnectionAgentConfiguration( doc_id = 'test-connection-config', connections_limit = 2) dbtools.initial_data(config) self.override_config('connection_agent', config) return common.SimulationTest.setUp(self)
def setUp(self): config = export_agent.ExportAgentConfiguration( doc_id = 'test-export-config', sitename = 'testing_site', notification_period = 1) dbtools.initial_data(config) self.override_config('export_agent', config) config = shard_agent.ShardAgentConfiguration( doc_id = 'test-shard-config', hosts_per_shard = 2) dbtools.initial_data(config) self.override_config('shard_agent', config) return common.SimulationTest.setUp(self)
def testDefiningDocument(self): dbtools.initial_data(SomeDocument) dbtools.initial_data( SomeDocument(doc_id=u'special_id', field1=u'special')) yield dbtools.push_initial_data(self.connection) # 3 = 2 (registered documents) + 1 (design document) self.assertEqual(3, len(self.db._documents)) special = yield self.connection.get_document('special_id') self.assertIsInstance(special, SomeDocument) self.assertEqual('special', special.field1) ids = self.db._documents.keys() other_id = filter(lambda x: x not in ('special_id', "_design/feat"), ids)[0] normal = yield self.connection.get_document(other_id) self.assertEqual('default', normal.field1)
state.steps = [x for x in state.steps if not (x.strategy == Migratability.locally and x.recipient.shard == shard)] return self ### private ### @replay.immutable def _ensure_analyzed(self, state, method): if not state.analyzed: raise ValueError('Before calling %s you should call analyze()' % method) @replay.side_effect def _generate_ident(self): return str(uuid.uuid1()) @document.register class ExportAgentConfiguration(document.Document): document_type = 'export_agent_conf' document.field('doc_id', u'export_agent_conf', '_id') document.field('notification_period', 12) document.field('default_host_cmd', '/bin/true') document.field('sitename', 'local') document.field('version', 1) dbtools.initial_data(ExportAgentConfiguration)
class MonitorAgentConfiguration(document.Document): document_type = 'monitor_agent_conf' document.field('doc_id', u'monitor_agent_conf', '_id') document.field('heartbeat_period', DEFAULT_HEARTBEAT_PERIOD) document.field('heartbeat_death_skips', DEFAULT_DEATH_SKIPS) document.field('heartbeat_dying_skips', DEFAULT_DYING_SKIPS) document.field('control_period', DEFAULT_CONTROL_PERIOD) document.field('notification_period', DEFAULT_NOTIFICATION_PERIOD) document.field('enable_quarantine', True) document.field('host_quarantine_length', DEFAULT_HOST_QUARANTINE_LENGTH) document.field('self_quarantine_length', DEFAULT_SELF_QUARANTINE_LENGTH) document.field('neighbours_check_period', DEFAULT_NEIGHBOURS_CHECK_PERIOD) dbtools.initial_data(MonitorAgentConfiguration) Descriptor = monitor.Descriptor @agent.register('monitor_agent') class MonitorAgent(agent.BaseAgent, sender.AgentMixin, host.SpecialHostPartnerMixin): implements(shard.IShardNotificationHandler, IAssistant, ICoroner) partners_class = Partners restart_strategy = RestartStrategy.monitor
def setUp(self): dbtools.initial_data(SomeDocument) return SimulationTest.setUp(self)
king - a shard being the entry point (lobby binding) peasant - normal shard ''' (king, peasant, ) = range(2) @document.register class ShardAgentConfiguration(document.Document): document_type = 'shard_agent_conf' document.field('doc_id', u'shard_agent_conf', '_id') document.field('hosts_per_shard', 10) document.field('neighbours', 3) dbtools.initial_data(ShardAgentConfiguration) @agent.register('shard_agent') class ShardAgent(agent.BaseAgent, notifier.AgentMixin, resource.AgentMixin, host.SpecialHostPartnerMixin): partners_class = Partners restart_strategy = monitor.RestartStrategy.local migratability = export.Migratability.locally @replay.mutable def initiate(self, state): config = state.medium.get_configuration()
@replay.journaled def granted(self, state, grant): payload = state.agent.generate_join_url(state.allocation_id) report = message.FinalReport(payload=payload) state.medium.finalize(report) @document.register class ConnectionAgentConfiguration(document.Document): document_type = 'connection_agent_conf' document.field('doc_id', u'connection_agent_conf', '_id') document.field('connections_limit', 10) document.field('authorization_timeout', 10) dbtools.initial_data(ConnectionAgentConfiguration) class RoomPoster(poster.BasePoster): @replay.mutable def initiate(self, state): state.own_key = state.agent.get_own_address().key @replay.immutable def pack_payload(self, state, body): resp = dict() resp['key'] = state.own_key resp['body'] = body return resp
@document.register class DNSAgentConfiguration(document.Document): document_type = 'dns_agent_conf' document.field('doc_id', u'dns_agent_conf', '_id') document.field('port', DEFAULT_PORT) document.field('ns_ttl', DEFAULT_NS_TTL) document.field('aa_ttl', DEFAULT_AA_TTL) document.field('ns', unicode()) document.field('suffix', unicode()) document.field('notify', NotifyConfiguration()) dbtools.initial_data(DNSAgentConfiguration) @descriptor.register("dns_agent") class Descriptor(descriptor.Descriptor): pass @agent.register('dns_agent') class DNSAgent(agent.BaseAgent): categories = {"address": Address.fixed} dependency.register(IDNSServerLabourFactory, production.Labour, ExecMode.production) dependency.register(IDNSServerLabourFactory,
formatable.field('monitor', u'monitor01.bcn.fluendo.net') formatable.field('config_file', u'/etc/nagios/send_nsca.cfg') formatable.field('send_nsca', u'/usr/sbin/send_nsca') formatable.field('svc_descr', u'FLTSERVICE') formatable.field('host', u'flt1.livetranscoding.net') @document.register class AlertAgentConfiguration(document.Document): document_type = 'alert_agent_conf' document.field('doc_id', u'alert_agent_conf', '_id') document.field('mail_config', AlertMailConfiguration()) document.field('nagios_config', AlertNagiosConfiguration()) dbtools.initial_data(AlertAgentConfiguration) @agent.register('alert_agent') class AlertAgent(agent.BaseAgent, alert.AgentMixin): dependency.register(IEmailSenderLabourFactory, mail.Labour, ExecMode.production) dependency.register(IEmailSenderLabourFactory, simulation.MailLabour, ExecMode.test) dependency.register(IEmailSenderLabourFactory, simulation.MailLabour, ExecMode.simulation) dependency.register(INagiosSenderLabourFactory, nagios.Labour, ExecMode.production) dependency.register(INagiosSenderLabourFactory,
from featchat.agents.api.interface import IWebAgent, IServerFactory from featchat.agents.common import room DEFAULT_PORT = 8880 DEFAULT_DNS_PREFIX = u'api' @document.register class ApiAgentConfiguration(document.Document): document_type = 'api_agent_conf' document.field('doc_id', u'api_agent_conf', '_id') document.field('dns_prefix', DEFAULT_DNS_PREFIX) document.field('port', DEFAULT_PORT) dbtools.initial_data(ApiAgentConfiguration) @agent.register('api_agent') class ApiAgent(agent.BaseAgent, alert.AgentMixin): implements(IWebAgent) restart_strategy = monitor.RestartStrategy.wherever dependency.register(IServerFactory, 'featchat.agents.api.web.ServerDummy', ExecMode.test) dependency.register(IServerFactory, 'featchat.agents.api.web.ServerDummy', ExecMode.simulation) dependency.register(IServerFactory,