Skip to content

Failed

OmeroPy.test.integration.gatewaytest.test_connection.TestConnectionMethods.testSecureWithUsername[False] (from pytest)

Failing for the past 3 builds (Since #37 )
Took 88 ms.

Error Message

omero.ClientError: Session already active. Create a new omero.client or closeSession()

Stacktrace

self = <omero.gateway._BlitzGateway object at 0x7fc787500850>, sUuid = None
raiseOnError = True

    def connect(self, sUuid=None, raiseOnError=False):
        """
        Creates or retrieves connection for the given sessionUuid.
        Returns True if connected.
    
        :param sUuid:   omero_model_SessionI
        :param raiseOnError: Boolean
        :return:        Boolean
        """
    
        logger.debug("Connect attempt, sUuid=%s, group=%s, self.sUuid=%s" % (
            str(sUuid), str(self.group), self._sessionUuid))
        if not self.c:  # pragma: no cover
            self._connected = False
            logger.debug("Ooops. no self._c")
            if raiseOnError:
                raise Exception('No self.c')
            return False
        try:
            try:
                sid = self.c.getSessionId()
                # we have a session already from the client
                if sUuid is None or sid == sUuid:
                    logger.debug('connected via client')
                    return True
            except omero.ClientError: # no session available
                pass
    
            if self._sessionUuid is None and sUuid:
                self._sessionUuid = sUuid
            if self._sessionUuid is not None:
                try:
                    logger.debug('connected? %s' % str(self._connected))
                    if self._connected:
                        self._connected = False
                        logger.debug(
                            "was connected, creating new omero.client")
                        self._resetOmeroClient()
                    # timeout to allow this is $ omero config set
                    # omero.sessions.timeout 3600000
                    s = self.c.joinSession(self._sessionUuid)
                    s.detachOnDestroy()
                    self.SERVICE_OPTS = self.createServiceOptsDict()
                    logger.debug(
                        'Joined Session OK with Uuid: %s'
                        % (self._sessionUuid,))
                    self._was_join = True
                except Ice.SyscallException:  # pragma: no cover
                    raise
                except Exception as x:  # pragma: no cover
                    logger.debug("Error: " + str(x))
                    if raiseOnError:
                        raise
                    self._sessionUuid = None
                    if sUuid:
                        return False
            if self._sessionUuid is None:
                if sUuid:  # pragma: no cover
                    logger.debug("Uncaptured sUuid failure!")
                if self._connected:
                    self._connected = False
                    try:
                        logger.debug(
                            "Closing previous connection..."
                            "creating new client")
                        # args = self.c._ic_args
                        # logger.debug(str(args))
                        self._closeSession()
                        self._resetOmeroClient()
                        # self.c = omero.client(*args)
                    # pragma: no cover
                    except Glacier2.SessionNotExistException:
                        pass
                for key, value in list(self._ic_props.items()):
                    if isinstance(value, str):
                        value = value.encode('utf_8')
                    self.c.ic.getProperties().setProperty(key, str(value))
                if self._anonymous:
                    self.c.ic.getImplicitContext().put(
                        omero.constants.EVENT, 'Internal')
                if self.group is not None:
                    self.c.ic.getImplicitContext().put(
                        omero.constants.GROUP, self.group)
                try:
                    logger.debug("Creating Session...")
>                   self._createSession()

../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:2228: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:2082: in _createSession
    self.setSecure(self.secure)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <omero.gateway._BlitzGateway object at 0x7fc787500850>, secure = 'False'

    def setSecure(self, secure=True):
        """
        Switches between SSL and insecure (faster) connections to Blitz.
        The gateway must already be connected.
    
        :param secure:  If False, use an insecure connection
        :type secure:   Boolean
        """
>       if hasattr(self.c, 'createClient') and (secure ^ self.c.isSecure()):
E       TypeError: unsupported operand type(s) for ^: 'str' and 'bool'

../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:2048: TypeError

During handling of the above exception, another exception occurred:

self = <test.integration.gatewaytest.test_connection.TestConnectionMethods object at 0x7fc7eaa52a30>
gatewaywrapper = <omero.gateway.pytest_fixtures.GatewayWrapper object at 0x7fc7b6e614c0>
secure = 'False'

    @pytest.mark.parametrize("secure", [None, "False", "True"])
    def testSecureWithUsername(self, gatewaywrapper, secure):
    
        gatewaywrapper.loginAsAdmin()
        username = "session_test_secure_with_name"
        password = "foobar"
        last_name = "SessionId"
        test_user = dbhelpers.UserEntry(username, password,
                                        firstname='User',
                                        lastname=last_name)
        test_user.create(gatewaywrapper.gateway, dbhelpers.ROOT.passwd)
        gatewaywrapper.doDisconnect()
    
>       with BlitzGateway(username=username,
                          passwd=password,
                          host="localhost",
                          secure=secure) as conn:

test/integration/gatewaytest/test_connection.py:347: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:1602: in __enter__
    self.connect(raiseOnError=True)
../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:2267: in connect
    self._createSession()
../../../../.venv3/lib64/python3.9/site-packages/omero/gateway/__init__.py:2070: in _createSession
    s = self.c.createSession(self._ic_props[omero.constants.USERNAME],
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <omero.clients.BaseClient object at 0x7fc6e4469e80>
username = 'session_test_secure_with_name', password = 'foobar'

    def createSession(self, username=None, password=None):
        """
        Performs the actual logic of logging in, which is done via the
        getRouter(). Disallows an extant ServiceFactoryPrx, and
        tries to re-create a null Ice.Communicator. A null or empty
        username will throw an exception, but an empty password is allowed.
        """
        import omero
    
        self.__lock.acquire()
        try:
    
            # Checking state
    
            if self.__sf:
>               raise omero.ClientError(
                    "Session already active. "
                    "Create a new omero.client or closeSession()")
E                   omero.ClientError: Session already active. Create a new omero.client or closeSession()

../../../../.venv3/lib64/python3.9/site-packages/omero/clients.py:582: ClientError