def example_test_pipeline(self):
     """
     Main test, it pretends we have received claims from the 
     ADSDeploy
     
     For this, you need to have 'db' and 'rabbitmq' containers running.
     :return: no return
     """
     
     # fire up the real queue
     self.TM.start_workers(verbose=True)
     
     # clean the slate (ie: delete stuff that might be laying there from the 
     # previous failed tests); this is just an example 
     with app.session_scope() as session:
         session.query(models.AuthorInfo).filter_by(orcidid='0000-0003-3041-2092').delete()
         session.query(models.ClaimsLog).filter_by(orcidid='0000-0003-3041-2092').delete()
         session.query(models.Records).filter_by(bibcode='2015ASPC..495..401C').delete()
         kv = session.query(models.KeyValue).filter_by(key='last.check').first()
         if kv is None:
             kv = models.KeyValue(key='last.check')
         kv.value = '2051-11-09T22:56:52.518001Z'
             
     # create anonymous worker with access to the exchange        
     test_worker = generic.RabbitMQWorker(params={
                         'publish': 'init-state',
                         'exchange': 'ADSDeploy-test-exchange'
                     })
     test_worker.connect(self.TM.rabbitmq_url)
     
     # send a test claim
     test_worker.publish({'orcidid': '0000-0003-3041-2092', 'bibcode': '2015ASPC..495..401C'})
     time.sleep(1)
     
     # check results
     with app.session_scope() as session:
         r = session.query(models.Records).filter_by(bibcode='2015ASPC..495..401C').first()
         self.assertEquals(json.loads(r.claims)['unverified'],
                           ['0000-0003-3041-2092', '-','-','-','-','-','-','-','-','-', ] 
                           )
Пример #2
0
 def process_payload(self, payload, 
     channel=None, 
     method_frame=None, 
     header_frame=None):
     """Runs the cleanup after the deployment happened."""
     
     # reset the timer
     key = '{0}.{1}.last-used'.format(payload['application'], payload['environment'])
     now = time.time()
     with app.session_scope() as session:
         u = session.query(KeyValue).filter_by(key=key).first()
         if u is not None:
             u.value = now
         u = KeyValue(key=key, value=now)
         session.add(u)
         session.commit()
Пример #3
0
sys.path.append(PROJECT_HOME)
import boto3

from ADSDeploy import app
from ADSDeploy.models import Deployment

app.init_app()
client = boto3.client('elasticbeanstalk')

for app in client.describe_applications()['Applications']:
    app_name = app['ApplicationName']
    
    list_of_services = client.describe_environments(ApplicationName=app_name)
    for service in list_of_services['Environments']:

        name = service['CNAME'].split('.')[0].replace('-{0}'.format(app_name), '')
        version = ':'.join(service['VersionLabel'].split(':')[1:])
    
        with app.session_scope() as session:
            deployment = Deployment(
                application=app_name,
                environment=name,
                deployed=service.get('Health', '') == 'Green',
                tested=False,
                msg='AWS bootstrapped',
                version=version
            )
    
            session.add(deployment)
            session.commit()