Exemplo n.º 1
0
    def check_delayed_activation(self, activationTime, activationType):
        active = Active()
        active.unrouteAll()
        preActivationState = active.buildJSONObject()

        outputList = getOutputList()
        testRouteAction = outputList[0].findAcceptableTestRoute()
        activation = Activation()
        activation.addAction(testRouteAction)
        activation.type = activationType
        activation.activationTimestamp = activationTime
        try:
            activation.fireActivation()
        except NMOSTestException as e:
            time.sleep(2)
            raise e

        pendingState = active.buildJSONObject()
        if not compare_json(preActivationState, pendingState):
            msg = globalConfig.test.FAIL("Scheduled Activation completed immediately")
            raise NMOSTestException(msg)

        time.sleep(2)

        active.assertActionCompleted(testRouteAction, retries=5)

        time.sleep(1)
Exemplo n.º 2
0
    def test_06_locking_response(self, test):
        """Attempting to change a locked route results in a 423 response"""
        globalConfig.test = test

        outputList = getOutputList()
        testRouteAction = outputList[0].findAcceptableTestRoute()
        activation = Activation()
        activation.addAction(testRouteAction)
        activation.type = SCHEDULED_RELATIVE_ACTIVATION
        activation.activationTimestamp = "5:0"
        activation.fireActivation()
        activation.checkLock()

        return test.PASS()
Exemplo n.º 3
0
    def test_01_version_increment(self, test):
        """ Activations result in a Device version number increment"""
        globalConfig.test = test

        devicesWithAdvertisements = self.find_device_advertisement()

        versionNumbersBeforeActivation = []
        for device in devicesWithAdvertisements:
            versionNumbersBeforeActivation.append(device['version'])

        output = getOutputList()[0]
        action = output.findAcceptableTestRoute()
        activation = Activation()
        activation.addAction(action)
        activation.fireActivation()

        versionIncremented = False

        counter = 0

        devicesWithAdvertisements = self.find_device_advertisement()

        for device in devicesWithAdvertisements:
            if device['version'] != versionNumbersBeforeActivation[counter]:
                versionIncremented = True

        if versionIncremented:
            return test.PASS()
        else:
            return test.FAIL(
                "No devices in the Node API incremented version number on activation."
            )
Exemplo n.º 4
0
    def test_15_block_constraint(self, test):
        """It is not possible to make an out-of-block route when block_size
        is anything other than 1"""
        globalConfig.test = test

        inputList = getInputList()
        constraintSet = False
        constrainedInputs = []
        for inputInstance in inputList:
            if inputInstance.getBlockSize() > 1:
                constraintSet = True
                constrainedInputs.append(inputInstance)

        if not constraintSet:
            return test.NA("No inputs constrain by block.")

        chosenInput = constrainedInputs[0]
        output = chosenInput.getRoutableOutputs()
        action = Action(
            chosenInput.id,
            output.id
        )
        activation = Activation()
        activation.addAction(action)
        try:
            activation.fireActivation()
        except NMOSTestException:
            return test.PASS()

        return test.FAIL("Was able to break block size routing constraint")
Exemplo n.º 5
0
    def test_05_delete_activations(self, test):
        """Activations can be deleted once created"""
        globalConfig.test = test

        Active().unrouteAll()
        outputList = getOutputList()
        testRouteAction = outputList[0].findAcceptableTestRoute()
        activation = Activation()
        activation.addAction(testRouteAction)
        activation.type = SCHEDULED_RELATIVE_ACTIVATION
        activation.activationTimestamp = "2:0"
        try:
            activation.fireActivation()
        except NMOSTestException as e:
            time.sleep(2)
            raise e

        time.sleep(1)

        activation.delete()

        return test.PASS()
Exemplo n.º 6
0
 def unrouteAll(self):
     outputList = getOutputList()
     activation = Activation()
     for outputInstance in outputList:
         for channelID in range(0, len(outputInstance.getChannelList())):
             action = Action(None, outputInstance.id, None, channelID)
             activation.addAction(action)
     activation.fireActivation()
Exemplo n.º 7
0
    def test_02_immediate_activation(self, test):
        """Immediate activation can be called on the API"""
        globalConfig.test = test

        outputList = getOutputList()
        testRouteAction = outputList[0].findAcceptableTestRoute()
        activation = Activation()
        activation.addAction(testRouteAction)
        activation.fireActivation()

        activeResource = Active()
        activeResource.assertActionCompleted(testRouteAction)
        return test.PASS()
Exemplo n.º 8
0
    def test_13_violate_routing_constraints_rejected(self, test):
        """Attempting to violate routing constraints results in an HTTP 400 response"""
        globalConfig.test = test

        outputList = getOutputList()
        constrainedOutputList = []
        for outputInstance in outputList:
            constraints = outputInstance.getCaps()
            try:
                routableInputs = constraints['routable_inputs']
            except KeyError:
                pass
            else:
                constrainedOutputList.append({
                    "output": outputInstance,
                    "routableInputs": routableInputs
                })

        if len(constrainedOutputList) == 0:
            return test.NA(
                "Could not test - no outputs have routing constraints set.")

        inputList = getInputList()
        inputIDList = []
        for inputInstance in inputList:
            inputIDList.append(inputInstance.id)

        for constrainedOutput in constrainedOutputList:
            forbiddenRoutes = copy.deepcopy(inputIDList)

            for routableInputID in constrainedOutput['routableInputs']:
                forbiddenRoutes.remove(routableInputID)

            if len(forbiddenRoutes) > 0:

                action = Action(forbiddenRoutes[0],
                                constrainedOutput['output'].id)
                activation = Activation()
                activation.addAction(action)

                try:
                    activation.checkReject()
                    return test.PASS()
                except NMOSTestException:
                    msg = (
                        "Was able to create a forbidden route between input {}"
                        " and output {} despite routing constraint."
                        "".format(forbiddenRoutes[0], outputInstance.id))
                    return test.FAIL(msg)
        return test.NA("Could not test - no route is forbidden.")
Exemplo n.º 9
0
    def test_14_reordering_constraint(self, test):
        """It is not possible to re-order channels when re-ordering is
        set to `false`"""
        globalConfig.test = test

        inputList = getInputList()

        constrainedInputs = []
        constraintSet = False
        for inputInstance in inputList:
            if not inputInstance.getReordering():
                constrainedInputs.append(inputInstance)
                constraintSet = True

        if not constraintSet:
            return test.NA("No inputs prevent re-ordering.")

        # Filter out inputs where the constraint can't be tested because the
        # block size prevents re-ordering anyway
        filteredInputs = []
        for inputInstance in constrainedInputs:
            blockSize = inputInstance.getBlockSize()
            if len(inputInstance.getChannelList) >= blockSize * 2:
                # Constraint makes no sense, can't re-order to to block size
                filteredInputs.append(inputInstance)

        # Filter out inputs where there is no output that channels could be
        # re-ordered into
        targetOutputList = {}
        testableInputs = []
        for inputInstance in filteredInputs:
            routableOutputList = inputInstance.getRoutableOutputs()
            for outputInstance in routableOutputList:
                if len(outputInstance.getChannelList) >= inputInstance.getBlockSize() * 2:
                    targetOutputList[inputInstance.id] = outputInstance
            if inputInstance.id in targetOutputList.keys:
                testableInputs.append(inputInstance)

        # Cross over blocks one and two on an input and output
        # e.g for a block size of 2:
        # IN            OUT
        # 0 ____   ____ 0
        # 1 ___ \ / ___ 1
        #      \ X /
        #       X X
        # 2 ___/ X \___ 2
        # 3 ____/ \____ 3
        activation = Activation()
        for inputInstance in testableInputs:
            for inputChannelIndex in range(0, inputInstance.getBlockSize()):
                outputChannelIndex = inputChannelIndex + blockSize
                blockOneAction = Action(
                    inputInstance.id,
                    targetOutputList[inputInstance.id],
                    inputChannelIndex,
                    outputChannelIndex
                )
                blockTwoAction = Action(
                    inputInstance.id,
                    targetOutputList[inputInstance.id],
                    outputChannelIndex,
                    inputChannelIndex
                )
                activation.addAction(blockOneAction)
                activation.addAction(blockTwoAction)

        try:
            activation.fireActivation()
        except NMOSTestException:
            return test.PASS()

        return test.FAIL("Channels could be re-ordered despite re-ordering constraint.")