<s> """<STR_LIT>""" <EOL> from cafe . drivers . unittest . fixtures import BaseTestFixture <EOL> from cafe . engine . clients . elasticsearch import BaseElasticSearchClient <EOL> from cafe . resources . rsyslog . client import RSyslogClient <EOL> from cloudcafe . meniscus . common . cleanup_client import MeniscusDbClient <EOL> from cloudcafe . meniscus . version_api . client import VersionClient <EOL> from cloudcafe . meniscus . tenant_api . client import TenantClient , ProducerClient <EOL> from cloudcafe . meniscus . config import ( MarshallingConfig , MeniscusConfig , <EOL> TenantConfig , CorrelationConfig , <EOL> StorageConfig ) <EOL> from cloudcafe . meniscus . tenant_api . behaviors import ( TenantBehaviors , <EOL> ProducerBehaviors ) <EOL> from cloudcafe . meniscus . correlator_api . client import PublishingClient <EOL> from cloudcafe . meniscus . correlator_api . behaviors import PublishingBehaviors <EOL> from cloudcafe . meniscus . status_api . client import WorkerStatusClient <EOL> class MeniscusFixture ( BaseTestFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( MeniscusFixture , cls ) . setUpClass ( ) <EOL> cls . marshalling = MarshallingConfig ( ) <EOL> cls . meniscus_config = MeniscusConfig ( ) <EOL> cls . storage_config = StorageConfig ( ) <EOL> cls . cleanup_client = MeniscusDbClient ( cls . meniscus_config . db_host , <EOL> cls . meniscus_config . db_name , <EOL> cls . meniscus_config . db_username , <EOL> cls . meniscus_config . db_password ) <EOL> es_servers = [ cls . storage_config . address ] <EOL> cls . es_client = BaseElasticSearchClient ( servers = es_servers ) <EOL> class VersionFixture ( MeniscusFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( VersionFixture , cls ) . setUpClass ( ) <EOL> cls . client = VersionClient ( <EOL> url = cls . meniscus_config . base_url , <EOL> serialize_format = cls . marshalling . serializer , <EOL> deserialize_format = cls . marshalling . deserializer ) <EOL> class TenantFixture ( MeniscusFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TenantFixture , cls ) . setUpClass ( ) <EOL> cls . tenant_config = TenantConfig ( ) <EOL> cls . tenant_client = TenantClient ( <EOL> url = cls . meniscus_config . base_url , <EOL> api_version = cls . meniscus_config . api_version , <EOL> serialize_format = cls . marshalling . serializer , <EOL> deserialize_format = cls . marshalling . deserializer ) <EOL> cls . tenant_behaviors = TenantBehaviors ( cls . tenant_client , <EOL> cls . cleanup_client , <EOL> cls . tenant_config , <EOL> cls . es_client ) <EOL> cls . tenant_id , resp = cls . tenant_behaviors . create_tenant ( ) <EOL> cls . es_client . index = [ cls . tenant_id ] <EOL> cls . es_client . connect ( bulk_size = <NUM_LIT:1> ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> cls . tenant_behaviors . remove_created_tenants ( ) <EOL> super ( TenantFixture , cls ) . tearDownClass ( ) <EOL> class ProducerFixture ( TenantFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( ProducerFixture , cls ) . setUpClass ( ) <EOL> cls . producer_client = ProducerClient ( <EOL> url = cls . meniscus_config . base_url , <EOL> api_version = cls . meniscus_config . api_version , <EOL> tenant_id = cls . tenant_id , <EOL> use_alternate = False , <EOL> serialize_format = cls . marshalling . serializer , <EOL> deserialize_format = cls . marshalling . deserializer ) <EOL> cls . producer_behaviors = ProducerBehaviors ( <EOL> tenant_client = cls . tenant_client , <EOL> producer_client = cls . producer_client , <EOL> db_client = cls . cleanup_client , <EOL> tenant_config = cls . tenant_config , <EOL> es_client = cls . es_client ) <EOL> def tearDown ( self ) : <EOL> for producer_id in self . producer_behaviors . producers_created : <EOL> self . producer_behaviors . delete_producer ( producer_id , False ) <EOL> self . producer_behaviors . producers_created = [ ] <EOL> super ( ProducerFixture , self ) . tearDown ( ) <EOL> class StatusFixture ( VersionFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( StatusFixture , cls ) . setUpClass ( ) <EOL> cls . status_client = WorkerStatusClient ( <EOL> url = cls . meniscus_config . base_url , <EOL> api_version = cls . meniscus_config . api_version , <EOL> serialize_format = cls . marshalling . serializer , <EOL> deserialize_format = cls . marshalling . deserializer ) <EOL> class PublishingFixture ( ProducerFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( PublishingFixture , cls ) . setUpClass ( ) <EOL> cls . correlate_config = CorrelationConfig ( ) <EOL> cls . publish_client = PublishingClient ( <EOL> url = cls . correlate_config . correlator_base_url , <EOL> api_version = cls . meniscus_config . api_version , <EOL> serialize_format = cls . marshalling . serializer , <EOL> deserialize_format = cls . marshalling . deserializer ) <EOL> cls . publish_behaviors = PublishingBehaviors ( <EOL> publish_client = cls . publish_client , <EOL> correlation_config = cls . correlate_config , <EOL> storage_client = cls . es_client ) <EOL> def setUp ( self ) : <EOL> super ( PublishingFixture , self ) . setUp ( ) <EOL> resp = self . tenant_client . get_tenant ( self . tenant_id ) <EOL> self . assertEqual ( resp . status_code , <NUM_LIT:200> ) <EOL> self . tenant_token = str ( resp . entity [ <NUM_LIT:0> ] . token . valid ) <EOL> self . publish_behaviors . tenant_id = self . tenant_id <EOL> self . publish_behaviors . tenant_token = self . tenant_token <EOL> class RSyslogPublishingFixture ( PublishingFixture ) : <EOL> def setUp ( self ) : <EOL> super ( RSyslogPublishingFixture , self ) . setUp ( ) <EOL> syslog_endpoint = self . correlate_config . syslog_endpoint <EOL> tenant_info = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : self . tenant_token , '<STR_LIT>' : self . tenant_id <EOL> } <EOL> } <EOL> self . rsyslog_client = RSyslogClient ( host = syslog_endpoint , <EOL> default_sd = tenant_info ) <EOL> self . rsyslog_client . connect ( ) <EOL> def tearDown ( self ) : <EOL> self . rsyslog_client . close ( ) </s>
