def test_observatory(self): self._load_stage = 0 self._resources = {} passing = True self.assertTrue(True) # LOAD STEP 1 self.preload_ooi(stage=STAGE_LOAD_ORGS) passing &= self.orguserrole_assertions() # LOAD STEP 2 self.preload_ooi(stage=STAGE_LOAD_PARAMS) passing &= self.parameter_assertions() # LOAD STEP 3 self.preload_ooi(stage=STAGE_LOAD_AGENTS) passing &= self.agent_assertions() # LOAD STEP 4 self.preload_ooi(stage=STAGE_LOAD_ASSETS) # Check OOI preloaded resources to see if they match needs for this test and for correctness passing &= self.sites_assertions() passing &= self.device_assertions() passing &= self.deployment_assertions() # Extensive tests on select RSN nodes passing &= self.rsn_node_checks() # Extensive tests on select RSN instruments passing &= self.check_rsn_instrument() passing &= self.check_rsn_instrument_data_product() # Extensive tests on a glider #passing &= self.check_glider() # Extensive tests on a CG assembly #passing &= self.check_cg_assembly() # Add a new instrument agent # Add a new instrument agent instance # Check DataProducts # Check Provenance IonIntegrationTestCase.assertTrue(self, passing)
def tearDown(self): try: IonIntegrationTestCase.tearDown(self) finally: TrhphTestCase.tearDown(self)
def addCleanup(self, f): IonIntegrationTestCase.addCleanup(self, f)
import unittest from mock import Mock, patch from pyon.util.int_test import IonIntegrationTestCase from nose.plugins.attrib import attr from pyon.core.exception import BadRequest, Conflict, Inconsistent, NotFound from pyon.public import PRED, RT, IonObject, OT from interface.objects import PolicyTypeEnum from ion.service.policy_management_service import PolicyManagementService from interface.services.core.ipolicy_management_service import PolicyManagementServiceClient @attr('INT', group='coi') @patch.dict('pyon.core.governance.governance_controller.CFG', IonIntegrationTestCase._get_alt_cfg({'interceptor': {'interceptors': {'governance': {'config': {'enabled': False}}}}})) class TestPolicyManagementServiceInt(IonIntegrationTestCase): def setUp(self): # Start container self._start_container() self.container.start_rel_from_url('res/deploy/basic.yml') self.container.governance_controller.policy_event_callback = Mock() self.policy_management_service = PolicyManagementServiceClient() def test_policy(self): self._do_test_policy_crud() def _do_test_policy_crud(self):
def assertTrue(self, *args, **kwargs): IonIntegrationTestCase.assertTrue(self, *args, **kwargs)
def assertEquals(self, *args, **kwargs): IonIntegrationTestCase.assertEquals(self, *args, **kwargs)
from pyon.util.int_test import IonIntegrationTestCase from pyon.ion import exchange from pyon.net.transport import BaseTransport from pyon.public import PRED, RT, CFG, log, BadRequest, Conflict, Inconsistent, NotFound from pyon.util.containers import DotDict from ion.service.exchange_management_service import ExchangeManagementService from interface.objects import ExchangeSpace, ExchangePoint, ExchangeName from interface.services.core.iresource_registry_service import ResourceRegistryServiceClient from interface.services.core.iexchange_management_service import ExchangeManagementServiceClient @attr('INT', group='coi') @patch.dict('pyon.ion.exchange.CFG', IonIntegrationTestCase._get_alt_cfg({'container':{'messaging':{'auto_register': True}}})) class TestExchangeManagementServiceInt(IonIntegrationTestCase): def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/basic.yml') self.ems = ExchangeManagementServiceClient() self.rr = ResourceRegistryServiceClient() orglist, _ = self.rr.find_resources(RT.Org) self.org_id = orglist[0]._id # we test actual exchange interaction in pyon, so it's fine to mock the broker interaction here self._clear_mocks()
from pyon.ion import exchange from pyon.net.transport import BaseTransport from pyon.public import PRED, RT, CFG, log, BadRequest, Conflict, Inconsistent, NotFound from pyon.util.containers import DotDict from ion.service.exchange_management_service import ExchangeManagementService from interface.objects import ExchangeSpace, ExchangePoint, ExchangeName from interface.services.core.iresource_registry_service import ResourceRegistryServiceClient from interface.services.core.iexchange_management_service import ExchangeManagementServiceClient @attr('INT', group='coi') @patch.dict('pyon.ion.exchange.CFG', IonIntegrationTestCase._get_alt_cfg( {'container': { 'messaging': { 'auto_register': True } }})) class TestExchangeManagementServiceInt(IonIntegrationTestCase): def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/basic.yml') self.ems = ExchangeManagementServiceClient() self.rr = ResourceRegistryServiceClient() orglist, _ = self.rr.find_resources(RT.Org) self.org_id = orglist[0]._id # we test actual exchange interaction in pyon, so it's fine to mock the broker interaction here self._clear_mocks()
def begin(self): """Called before any tests are collected or run. Use this to perform any setup needed before testing begins. """ # Make sure we initialize pyon before anything in this plugin executes from pyon.core import bootstrap if not bootstrap.pyon_initialized: bootstrap.bootstrap_pyon() try: from pyon.public import get_sys_name, CFG self.sysname = get_sys_name() # Clean exchanges and system queues out there try: connect_str = '-H %s -P 55672 -u %s -p %s -V %s' % (CFG.server.amqp.host, CFG.server.amqp.username, CFG.server.amqp.password, CFG.server.amqp.vhost) deleted_exchanges, deleted_queues = clean_by_sysname(connect_str, self.sysname) debug.write('Deleted exchanges:\n%s \n' % '\n'.join(deleted_exchanges)) debug.write('Deleted queues:\n%s \n' % '\n'.join(deleted_queues)) except Exception as e: pass # Force datastore loader to use the same sysname from pyon.datastore.datastore_admin import DatastoreAdmin from pyon.datastore.datastore_common import DatastoreFactory self.datastore_admin = DatastoreAdmin(config=CFG) # Clean datastore and file system before pycc container starts from pyon.util.int_test import IonIntegrationTestCase IonIntegrationTestCase._force_clean(False) def die(signum, frame): # For whatever reason, the parent doesn't die some times # when getting KeyboardInterrupt. Hence this signal # handler. # Signal is pass through. The child pycc gets # its own KeyboardInterrupt and will shut down accordingly. debug.write('Received Keyboard Interrupt. Exiting now.\n') os._exit(9) signal.signal(signal.SIGINT, die) def no_zombie(signum, frame): # Debug to figure out who's dying debug.write('SIGCHLD received\n') stack = [] while frame: stack.append(frame) frame =frame.f_back stack.reverse() for frame in stack: debug.write('Frame %s in %s at line %s\n' % (frame.f_code.co_name, frame.f_code.co_filename, frame.f_lineno)) debug.write('Child is dead...Clean up now so there is no zombie\n') (pid, status) = os.wait() exitstatus, signum = status & 0xff, (status & 0xff00) >> 8 debug.write('Child pid %d with exit status %d and signum %d\n' % (pid, exitstatus, signum)) # Could be dangerous. Comment this out. # signal.signal(signal.SIGCHLD, no_zombie) def container_started_cb(signum, frame): """Callback when child pycc service is ready""" self.container_started = True signal.signal(signal.SIGUSR1, container_started_cb) # Make sure the pycc process has the same sysname as the nose ccargs = ['bin/pycc', '-o', '--noshell', '-sp', '--sysname=%s' % self.sysname, '--logcfg=res/config/logging.pycc.yml', '--rel=%s' % self.rel, "--config={'system': {'auto_bootstrap': True}}"] if self.enablegb: ccargs.insert(1, '-egb') debug.write('Starting pycc process: %s\n' % ' '.join(ccargs)) # Set PYCC env var in case CEI needs to skip tests in pycc mode os.environ['PYCC_MODE'] = '1' # Enable CEI mode for the tests os.environ['CEI_LAUNCH_TEST'] = '1' newenv = os.environ.copy() po = subprocess.Popen(ccargs, env=newenv, close_fds=True) self.ccs.append(po) # Wait for container to be ready while not self.container_started: time.sleep(0.2) debug.write('Child container is ready...\n') # Dump datastore self.datastore_admin.dump_datastore(path='res/dd') debug.write('Dump child container state to file...\n') # Clean again to make sure the first nosetest starts on a clean # slate self.datastore_admin.clear_datastore(prefix=self.sysname) debug.write('Start nose tests now...\n') except Exception as e: self.container_shutdown() raise e
from pyon.public import PRED, RT, IonObject, OT from interface.objects import PolicyTypeEnum from ion.service.policy_management_service import PolicyManagementService from interface.services.core.ipolicy_management_service import PolicyManagementServiceClient @attr('INT', group='coi') @patch.dict('pyon.core.governance.governance_controller.CFG', IonIntegrationTestCase._get_alt_cfg({ 'interceptor': { 'interceptors': { 'governance': { 'config': { 'enabled': False } } } } })) class TestPolicyManagementServiceInt(IonIntegrationTestCase): def setUp(self): # Start container self._start_container() self.container.start_rel_from_url('res/deploy/basic.yml') self.container.governance_controller.policy_event_callback = Mock() self.policy_management_service = PolicyManagementServiceClient()
import unittest from mock import Mock, patch from pyon.util.int_test import IonIntegrationTestCase from nose.plugins.attrib import attr from pyon.core.exception import BadRequest, Conflict, Inconsistent, NotFound from pyon.public import PRED, RT, IonObject, OT from interface.objects import PolicyTypeEnum from ion.services.policy_management_service import PolicyManagementService from interface.services.core.ipolicy_management_service import PolicyManagementServiceClient @attr('INT', group='coi') @patch.dict('pyon.core.governance.governance_controller.CFG', IonIntegrationTestCase._get_alt_cfg({'interceptor': {'interceptors': {'governance': {'config': {'enabled': False}}}}})) class TestPolicyManagementServiceInt(IonIntegrationTestCase): def setUp(self): # Start container self._start_container() self.container.start_rel_from_url('res/deploy/basic.yml') self.container.governance_controller.policy_event_callback = Mock() self.policy_management_service = PolicyManagementServiceClient() def test_policy(self): self._do_test_policy_crud() def _do_test_policy_crud(self):