<commit_before>#!/usr/bin/env python

"""
@package ion.services.sa.observatory.test.test_platform_instrument
@file    ion/services/sa/observatory/test/test_platform_instrument.py
@author  <NAME>, <NAME>
@brief   Tests involving some more detailed platform-instrument interations
"""

__author__ = '<NAME>, <NAME>'
__license__ = 'Apache 2.0'

#
# Base preparations and construction of the platform topology are provided by
# the base class BaseTestPlatform.
#

# developer conveniences:
# bin/nosetests -sv ion/services/sa/observatory/test/test_platform_instrument.py:Test.test_platform_with_instrument_streaming

from pyon.public import log, OT, RT

from ion.agents.platform.test.base_test_platform_agent_with_rsn import BaseIntTestPlatform

from pyon.agent.agent import ResourceAgentClient
from ion.agents.platform.test.base_test_platform_agent_with_rsn import FakeProcess
from pyon.agent.agent import ResourceAgentState
from pyon.event.event import EventSubscriber

from ion.services.dm.utility.granule_utils import time_series_domain
from ion.services.sa.test.helpers import any_old, AgentProcessStateGate
from pyon.public import RT, PRED, IonObject

from interface.services.coi.iresource_registry_service import ResourceRegistryServiceClient
from interface.services.dm.ipubsub_management_service import PubsubManagementServiceClient
from interface.services.dm.idataset_management_service import DatasetManagementServiceClient
from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient
from interface.services.cei.iprocess_dispatcher_service import ProcessDispatcherServiceClient
from interface.services.sa.idata_product_management_service import DataProductManagementServiceClient
from interface.services.sa.idata_acquisition_management_service import DataAcquisitionManagementServiceClient
from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient
from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient

from ion.agents.platform.rsn.oms_client_factory import CIOMSClientFactory
from pyon.util.containers import DotDict

from interface.objects import AgentCommand, StreamConfiguration, ProcessStateEnum, PortTypeEnum
from ion.agents.port.port_agent_process import PortAgentProcessType, PortAgentType

from ion.agents.platform.platform_agent import PlatformAgentState, PlatformAgentEvent
from ion.agents.port.port_agent_process import PortAgentProcess

from ion.services.cei.process_dispatcher_service import ProcessStateGate

from ion.agents.platform.rsn.test.oms_test_mixin import OmsTestMixin

import unittest
import pprint
import time
import calendar
import gevent
from gevent.event import AsyncResult

from mock import patch
from pyon.public import CFG

# -------------------------------- MI ----------------------------
# the following adapted from test_instrument_agent to be able to import from
# the MI repo, using egg directly.

import sys
from ion.agents.instrument.driver_process import ZMQEggDriverProcess

# EVENT_TIMEOUT: timeout for reception of event
EVENT_TIMEOUT = 25

# initialization of the driver configuration.
OMS_URI = 'http://alice:1234@10.180.80.10:9021/'
PLTFRM_DVR_CONFIG = {
    'oms_uri': OMS_URI
}

PLTFRM_DVR_MOD = 'ion.agents.platform.rsn.rsn_platform_driver'
PLTFRM_DVR_CLS = 'RSNPlatformDriver'

# A VEL3D driver.
DRV_URI = 'http://sddevrepo.oceanobservatories.org/releases/nobska_mavs4_ooicore-0.0.7-py2.7.egg'
DRV_MOD = 'mi.instrument.nobska.mavs4.ooicore.driver'
DRV_CLS = 'mavs4InstrumentDriver'

WORK_DIR = '/tmp/'

DVR_CONFIG = {
    'dvr_egg' : DRV_URI,
    'dvr_mod' : DRV_MOD,
    'dvr_cls' : DRV_CLS,
    'workdir' : WORK_DIR,
    'process_type' : None
}

RSN_VEL3D_01 = {
                    'DEV_ADDR'  : "10.180.80.6",
                    'DEV_PORT'  : 2101,
                    'DATA_PORT' : 1026,
                    'CMD_PORT'  : 1025,
                    'PA_BINARY' : "port_agent"
                },


# Dynamically load the egg into the test path
launcher = ZMQEggDriverProcess(DVR_CONFIG)
egg = launcher._get_egg(DRV_URI)
if not egg in sys.path:
    sys.path.insert(0, egg)


@patch.dict(CFG, {'endpoint': {'receive': {'timeout': 300}}})
class TestPlatformInstrument(BaseIntTestPlatform):

    def setUp(self):
        self._start_container()

        self._pp = pprint.PrettyPrinter()

        log.debug("oms_uri = %s", OMS_URI)
        self.oms = CIOMSClientFactory.create_instance(OMS_URI)

        #url = OmsTestMixin.start_http_server()
        #log.debug("TestPlatformInstrument:setup http url %s", url)
        #
        #result = self.oms.event.register_event_listener(url)
        #log.debug("TestPlatformInstrument:setup register_event_listener result %s", result)


        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        # Now create client to DataProductManagementService<commit_msg>mark test_platform_instrument as obsolete (with a skip): this will need a good revision after several recent changes including configuration handling for platforms<commit_after>#!/usr/bin/env python

"""
@package ion.services.sa.observatory.test.test_platform_instrument
@file    ion/services/sa/observatory/test/test_platform_instrument.py
@author  <NAME>, <NAME>
@brief   Tests involving some more detailed platform-instrument interations
"""

__author__ = '<NAME>, <NAME>'
__license__ = 'Apache 2.0'

#
# Base preparations and construction of the platform topology are provided by
# the base class BaseTestPlatform.
#

# developer conveniences:
# bin/nosetests -sv ion/services/sa/observatory/test/test_platform_instrument.py:Test.test_platform_with_instrument_streaming

from pyon.public import log, OT, RT

from ion.agents.platform.test.base_test_platform_agent_with_rsn import BaseIntTestPlatform

from pyon.agent.agent import ResourceAgentClient
from ion.agents.platform.test.base_test_platform_agent_with_rsn import FakeProcess
from pyon.agent.agent import ResourceAgentState
from pyon.event.event import EventSubscriber

from ion.services.dm.utility.granule_utils import time_series_domain
from ion.services.sa.test.helpers import any_old, AgentProcessStateGate
from pyon.public import RT, PRED, IonObject

from interface.services.coi.iresource_registry_service import ResourceRegistryServiceClient
from interface.services.dm.ipubsub_management_service import PubsubManagementServiceClient
from interface.services.dm.idataset_management_service import DatasetManagementServiceClient
from interface.services.sa.iinstrument_management_service import InstrumentManagementServiceClient
from interface.services.cei.iprocess_dispatcher_service import ProcessDispatcherServiceClient
from interface.services.sa.idata_product_management_service import DataProductManagementServiceClient
from interface.services.sa.idata_acquisition_management_service import DataAcquisitionManagementServiceClient
from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient
from ion.util.enhanced_resource_registry_client import EnhancedResourceRegistryClient

from ion.agents.platform.rsn.oms_client_factory import CIOMSClientFactory
from pyon.util.containers import DotDict

from interface.objects import AgentCommand, StreamConfiguration, ProcessStateEnum, PortTypeEnum
from ion.agents.port.port_agent_process import PortAgentProcessType, PortAgentType

from ion.agents.platform.platform_agent import PlatformAgentState, PlatformAgentEvent
from ion.agents.port.port_agent_process import PortAgentProcess

from ion.services.cei.process_dispatcher_service import ProcessStateGate

from ion.agents.platform.rsn.test.oms_test_mixin import OmsTestMixin

import unittest
import pprint
import time
import calendar
import gevent
from gevent.event import AsyncResult

from mock import patch
from pyon.public import CFG

# -------------------------------- MI ----------------------------
# the following adapted from test_instrument_agent to be able to import from
# the MI repo, using egg directly.

import sys
from ion.agents.instrument.driver_process import ZMQEggDriverProcess

# EVENT_TIMEOUT: timeout for reception of event
EVENT_TIMEOUT = 25

# initialization of the driver configuration.
OMS_URI = 'http://alice:1234@10.180.80.10:9021/'
PLTFRM_DVR_CONFIG = {
    'oms_uri': OMS_URI
}

PLTFRM_DVR_MOD = 'ion.agents.platform.rsn.rsn_platform_driver'
PLTFRM_DVR_CLS = 'RSNPlatformDriver'

# A VEL3D driver.
DRV_URI = 'http://sddevrepo.oceanobservatories.org/releases/nobska_mavs4_ooicore-0.0.7-py2.7.egg'
DRV_MOD = 'mi.instrument.nobska.mavs4.ooicore.driver'
DRV_CLS = 'mavs4InstrumentDriver'

WORK_DIR = '/tmp/'

DVR_CONFIG = {
    'dvr_egg' : DRV_URI,
    'dvr_mod' : DRV_MOD,
    'dvr_cls' : DRV_CLS,
    'workdir' : WORK_DIR,
    'process_type' : None
}

RSN_VEL3D_01 = {
                    'DEV_ADDR'  : "10.180.80.6",
                    'DEV_PORT'  : 2101,
                    'DATA_PORT' : 1026,
                    'CMD_PORT'  : 1025,
                    'PA_BINARY' : "port_agent"
                },


# Dynamically load the egg into the test path
launcher = ZMQEggDriverProcess(DVR_CONFIG)
egg = launcher._get_egg(DRV_URI)
if not egg in sys.path:
    sys.path.insert(0, egg)


@unittest.skip('becoming obsolete')
@patch.dict(CFG, {'endpoint': {'receive': {'timeout': 300}}})
class TestPlatformInstrument(BaseIntTestPlatform):

    def setUp(self):
        self._start_container()

        self._pp = pprint.PrettyPrinter()

        log.debug("oms_uri = %s", OMS_URI)
        self.oms = CIOMSClientFactory.create_instance(OMS_URI)

        #url = OmsTestMixin.start_http_server()
        #log.debug("TestPlatformInstrument:setup http url %s", url)
        #
        #result = self.oms.event.register_event_listener(url)
        #log.debug("TestPlatformInstrument:setup register_event_listener result %s", result)


        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        # Now create client to DataProductManagementService
{'fraction_non_alphanumeric': 0.08958667736757625, 'fraction_numerical': 0.011637239165329053, 'mean_word_length': 4.64176570458404, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014312', 'n_tokens_mistral': 3142, 'n_tokens_neox': 2967, 'n_words': 650}