コード例 #1
0
def ethernet_commissioning(test: BaseTestHelper, discriminator: int,
                           setup_pin: int, address_override: str,
                           device_nodeid: int):
    logger.info("Testing discovery")
    address = test.TestDiscovery(discriminator=discriminator)
    FailIfNot(address, "Failed to discover any devices.")

    # FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
    #           "Failed to finish network commissioning")

    if address_override:
        address = address_override
    else:
        address = address.decode("utf-8")

    logger.info("Testing key exchange")
    FailIfNot(
        test.TestKeyExchange(ip=address,
                             setuppin=setup_pin,
                             nodeid=device_nodeid),
        "Failed to finish key exchange")

    ok = asyncio.run(
        test.TestMultiFabric(ip=address, setuppin=20202021, nodeid=1))
    FailIfNot(ok, "Failed to commission multi-fabric")
コード例 #2
0
def do_tests(controller_nodeid, device_nodeid, address, timeout, discriminator,
             setup_pin):
    timeoutTicker = TestTimeout(timeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=controller_nodeid)

    chip.logging.RedirectToPythonLogging()

    ethernet_commissioning(test, discriminator, setup_pin, address,
                           device_nodeid)

    logger.info("Testing resolve")
    FailIfNot(test.TestResolve(nodeid=device_nodeid),
              "Failed to resolve nodeid")

    # Still test network commissioning
    FailIfNot(
        asyncio.run(
            NetworkCommissioningTests(devCtrl=test.devCtrl,
                                      nodeid=device_nodeid).run()),
        "Failed to finish network commissioning")

    TestDatamodel(test, device_nodeid)

    logger.info("Testing non-controller APIs")
    FailIfNot(test.TestNonControllerAPIs(), "Non controller API test failed")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #3
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress",
        default='',
        type='str',
        help="Address of the device",
        metavar="<device-addr>",
    )

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233)

    FailIfNot(
        test.TestKeyExchange(ip=options.deviceAddress,
                             setuppin=20202021,
                             nodeid=1), "Failed to finish key exchange")

    FailIfNot(
        test.TestNetworkCommissioning(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID,
                                      dataset=TEST_THREAD_NETWORK_DATASET_TLV,
                                      network_id=TEST_THREAD_NETWORK_ID),
        "Failed to finish network commissioning")

    FailIfNot(
        test.TestOnOffCluster(nodeid=1, endpoint=ENDPOINT_ID, group=GROUP_ID),
        "Failed to test on off cluster")

    FailIfNot(
        test.TestReadBasicAttribiutes(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID),
        "Failed to test Read Basic Attributes")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #4
0
def TestDatamodel(test: BaseTestHelper, device_nodeid: int):
    logger.info("Testing datamodel functions")

    logger.info("Testing on off cluster")
    FailIfNot(test.TestOnOffCluster(nodeid=device_nodeid,
                                    endpoint=LIGHTING_ENDPOINT_ID,
                                    group=GROUP_ID), "Failed to test on off cluster")

    logger.info("Testing level control cluster")
    FailIfNot(test.TestLevelControlCluster(nodeid=device_nodeid,
                                           endpoint=LIGHTING_ENDPOINT_ID,
                                           group=GROUP_ID),
              "Failed to test level control cluster")

    logger.info("Testing sending commands to non exist endpoint")
    FailIfNot(not test.TestOnOffCluster(nodeid=device_nodeid,
                                        endpoint=233,
                                        group=GROUP_ID), "Failed to test on off cluster on non-exist endpoint")

    # Test experimental Python cluster objects API
    logger.info("Testing cluster objects API")
    FailIfNot(asyncio.run(ClusterObjectTests.RunTest(test.devCtrl)),
              "Failed when testing Python Cluster Object APIs")

    logger.info("Testing attribute reading")
    FailIfNot(test.TestReadBasicAttributes(nodeid=device_nodeid,
                                           endpoint=ENDPOINT_ID,
                                           group=GROUP_ID),
              "Failed to test Read Basic Attributes")

    logger.info("Testing attribute writing")
    FailIfNot(test.TestWriteBasicAttributes(nodeid=device_nodeid,
                                            endpoint=ENDPOINT_ID,
                                            group=GROUP_ID),
              "Failed to test Write Basic Attributes")

    logger.info("Testing attribute reading basic again")
    FailIfNot(test.TestReadBasicAttributes(nodeid=1,
                                           endpoint=ENDPOINT_ID,
                                           group=GROUP_ID),
              "Failed to test Read Basic Attributes")

    logger.info("Testing subscription")
    FailIfNot(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID),
              "Failed to subscribe attributes.")

    logger.info("Testing another subscription that kills previous subscriptions")
    FailIfNot(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID),
              "Failed to subscribe attributes.")

    logger.info("Testing on off cluster over resolved connection")
    FailIfNot(test.TestOnOffCluster(nodeid=device_nodeid,
                                    endpoint=LIGHTING_ENDPOINT_ID,
                                    group=GROUP_ID), "Failed to test on off cluster")

    logger.info("Testing writing/reading fabric sensitive data")
    asyncio.run(test.TestFabricSensitive(nodeid=device_nodeid))
コード例 #5
0
def ethernet_commissioning(test: BaseTestHelper, discriminator: int,
                           setup_pin: int, address_override: str,
                           device_nodeid: int):
    logger.info("Testing discovery")
    address = test.TestDiscovery(discriminator=discriminator)
    FailIfNot(address, "Failed to discover any devices.")

    # FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
    #           "Failed to finish network commissioning")

    if address_override:
        address = address_override

    logger.info("Testing commissioning")
    FailIfNot(
        test.TestCommissioning(ip=address,
                               setuppin=setup_pin,
                               nodeid=device_nodeid),
        "Failed to finish key exchange")

    ok = asyncio.run(
        test.TestMultiFabric(ip=address, setuppin=20202021, nodeid=1))
    FailIfNot(ok, "Failed to commission multi-fabric")

    FailIfNot(
        asyncio.run(test.TestAddUpdateRemoveFabric(nodeid=device_nodeid)),
        "Failed AddUpdateRemoveFabric test")

    logger.info("Testing CASE Eviction")
    FailIfNot(asyncio.run(test.TestCaseEviction(device_nodeid)),
              "Failed TestCaseEviction")

    logger.info("Testing closing sessions")
    FailIfNot(test.TestCloseSession(nodeid=device_nodeid),
              "Failed to close sessions")
コード例 #6
0
def ethernet_commissioning(test: BaseTestHelper, discriminator: int, setup_pin: int, address_override: str, device_nodeid: int):
    logger.info("Testing discovery")
    address = test.TestDiscovery(discriminator=discriminator)
    FailIfNot(address, "Failed to discover any devices.")

    # FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
    #           "Failed to finish network commissioning")

    if address_override:
        address = address_override
    else:
        address = address.decode("utf-8")

    logger.info("Testing commissioning")
    FailIfNot(test.TestCommissioning(ip=address,
                                     setuppin=setup_pin,
                                     nodeid=device_nodeid),
              "Failed to finish key exchange")

    #
    # Run this before the MultiFabric test, since it will result in the resultant CASE session
    # on fabric2 to be evicted (due to the stressful nature of that test) on the target.
    #
    # It doesn't actually evict the CASE session for fabric2 on the client, since we prioritize
    # defunct sessions for eviction first, which means our CASE session on fabric2 remains preserved
    # throughout the stress test. This results in a mis-match later.
    #
    # TODO: Once we implement fabric-adjusted LRU, we should see if this issue remains (it shouldn't)
    #
    logger.info("Testing CASE Eviction")
    FailIfNot(asyncio.run(test.TestCaseEviction(device_nodeid)), "Failed TestCaseEviction")

    ok = asyncio.run(test.TestMultiFabric(ip=address,
                                          setuppin=20202021,
                                          nodeid=1))
    FailIfNot(ok, "Failed to commission multi-fabric")

    logger.info("Testing closing sessions")
    FailIfNot(test.TestCloseSession(nodeid=device_nodeid), "Failed to close sessions")
コード例 #7
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress",
        default='',
        type='str',
        help="Address of the device",
        metavar="<device-addr>",
    )

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233)

    logger.info("Testing discovery")
    FailIfNot(test.TestDiscovery(discriminator=TEST_DISCRIMINATOR),
              "Failed to discover any devices.")

    logger.info("Testing key exchange")
    FailIfNot(
        test.TestKeyExchange(ip=options.deviceAddress,
                             setuppin=20202021,
                             nodeid=1), "Failed to finish key exchange")

    logger.info("Testing network commissioning")
    FailIfNot(
        test.TestNetworkCommissioning(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID,
                                      dataset=TEST_THREAD_NETWORK_DATASET_TLV,
                                      network_id=TEST_THREAD_NETWORK_ID),
        "Failed to finish network commissioning")

    logger.info("Testing on off cluster")
    FailIfNot(
        test.TestOnOffCluster(nodeid=1,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID), "Failed to test on off cluster")

    logger.info("Testing sending commands to non exist endpoint")
    FailIfNot(
        not test.TestOnOffCluster(nodeid=1, endpoint=233, group=GROUP_ID),
        "Failed to test on off cluster on non-exist endpoint")

    logger.info("Testing attribute reading")
    FailIfNot(
        test.TestReadBasicAttribiutes(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID),
        "Failed to test Read Basic Attributes")

    logger.info("Testing attribute writing")
    FailIfNot(
        test.TestWriteBasicAttributes(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID),
        "Failed to test Write Basic Attributes")

    logger.info("Testing subscription")
    FailIfNot(test.TestSubscription(nodeid=1, endpoint=LIGHTING_ENDPOINT_ID),
              "Failed to subscribe attributes.")

    logger.info("Testing closing sessions")
    FailIfNot(test.TestCloseSession(nodeid=1), "Failed to close sessions")

    logger.info("Testing resolve")
    FailIfNot(test.TestResolve(nodeid=1), "Failed to resolve nodeid")

    logger.info("Testing on off cluster over resolved connection")
    FailIfNot(
        test.TestOnOffCluster(nodeid=1,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID), "Failed to test on off cluster")

    logger.info("Testing non-controller APIs")
    FailIfNot(test.TestNonControllerAPIs(), "Non controller API test failed")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #8
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress",
        default='',
        type='str',
        help="Address of the device",
        metavar="<device-addr>",
    )
    optParser.add_option(
        "--setup-payload",
        action="store",
        dest="setupPayload",
        default='',
        type='str',
        help="Setup Payload (manual pairing code or QR code content)",
        metavar="<setup-payload>"
    )
    optParser.add_option(
        "--nodeid",
        action="store",
        dest="nodeid",
        default=1,
        type=int,
        help="The Node ID issued to the device",
        metavar="<nodeid>"
    )
    optParser.add_option(
        "--discriminator",
        action="store",
        dest="discriminator",
        default=TEST_DISCRIMINATOR,
        type=int,
        help="Discriminator of the device",
        metavar="<nodeid>"
    )
    optParser.add_option(
        "-p",
        "--paa-trust-store-path",
        action="store",
        dest="paaTrustStorePath",
        default='',
        type='str',
        help="Path that contains valid and trusted PAA Root Certificates.",
        metavar="<paa-trust-store-path>"
    )

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(
        nodeid=112233, paaTrustStorePath=options.paaTrustStorePath, testCommissioner=True)

    logger.info("Testing discovery")
    FailIfNot(test.TestDiscovery(discriminator=options.discriminator),
              "Failed to discover any devices.")

    FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
              "Failed to finish network commissioning")

    if options.deviceAddress:
        logger.info("Testing commissioning (IP)")
        FailIfNot(test.TestCommissioning(ip=options.deviceAddress,
                                         setuppin=20202021,
                                         nodeid=options.nodeid),
                  "Failed to finish commissioning")
    elif options.setupPayload:
        logger.info("Testing commissioning (w/ Setup Payload)")
        FailIfNot(test.TestCommissioningWithSetupPayload(setupPayload=options.setupPayload,
                                                         nodeid=options.nodeid),
                  "Failed to finish commissioning")
    else:
        TestFail("Must provide device address or setup payload to commissioning the device")

    logger.info("Testing on off cluster")
    FailIfNot(test.TestOnOffCluster(nodeid=options.nodeid,
                                    endpoint=LIGHTING_ENDPOINT_ID,
                                    group=GROUP_ID), "Failed to test on off cluster")

    FailIfNot(test.TestUsedTestCommissioner(),
              "Test commissioner check failed")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #9
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress",
        default='',
        type='str',
        help="Address of the device",
        metavar="<device-addr>",
    )
    optParser.add_option(
        "-p",
        "--paa-trust-store-path",
        action="store",
        dest="paaTrustStorePath",
        default='',
        type='str',
        help="Path that contains valid and trusted PAA Root Certificates.",
        metavar="<paa-trust-store-path>")

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233,
                          paaTrustStorePath=options.paaTrustStorePath,
                          testCommissioner=False)

    logger.info("Testing discovery")
    FailIfNot(test.TestDiscovery(discriminator=TEST_DISCRIMINATOR),
              "Failed to discover any devices.")

    FailIfNot(
        test.SetNetworkCommissioningParameters(
            dataset=TEST_THREAD_NETWORK_DATASET_TLV),
        "Failed to finish network commissioning")

    logger.info("Testing commissioning")
    FailIfNot(
        test.TestCommissioning(ip=options.deviceAddress,
                               setuppin=20202021,
                               nodeid=1), "Failed to finish key exchange")

    FailIfNot(test.TestFailsafe(nodeid=1), "Failed failsafe test")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #10
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress1",
        default='',
        type='str',
        help="Address of the first device",
    )
    optParser.add_option(
        '--paa-trust-store-path',
        dest="paaPath",
        default='',
        type='str',
        help="Path that contains valid and trusted PAA Root Certificates."
    )
    optParser.add_option(
        '--fail-on-report',
        action="store_true",
        dest="report",
        default=False,
        help='Use this flag to simulate a failure handling the report. Without this flag, failure is simulated on the stage'
    )

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233, testCommissioner=True,
                          paaTrustStorePath=options.paaPath)

    FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
              "Failed to set network commissioning parameters")

    logger.info("Testing PASE connection to device")

    # TODO: Start at stage 2 once handling for arming failsafe on pase is done.
    if options.report:
        for testFailureStage in range(3, 18):
            FailIfNot(test.TestPaseOnly(ip=options.deviceAddress1,
                                        setuppin=20202021,
                                        nodeid=1),
                      "Failed to establish PASE connection with device")
            FailIfNot(test.TestCommissionFailureOnReport(1, testFailureStage),
                      "Commissioning failure tests failed for simulated report failure on stage {}".format(testFailureStage))

    else:
        for testFailureStage in range(3, 18):
            FailIfNot(test.TestPaseOnly(ip=options.deviceAddress1,
                                        setuppin=20202021,
                                        nodeid=1),
                      "Failed to establish PASE connection with device")
            FailIfNot(test.TestCommissionFailure(1, testFailureStage),
                      "Commissioning failure tests failed for simulated stage failure on stage {}".format(testFailureStage))

    # Ensure we can still commission for real
    FailIfNot(test.TestPaseOnly(ip=options.deviceAddress1,
                                setuppin=20202021,
                                nodeid=1),
              "Failed to establish PASE connection with device")
    FailIfNot(test.TestCommissionFailure(1, 0), "Failed to commission device")

    logger.info("Testing on off cluster")
    FailIfNot(test.TestOnOffCluster(nodeid=1,
                                    endpoint=LIGHTING_ENDPOINT_ID,
                                    group=GROUP_ID), "Failed to test on off cluster")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #11
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "-a",
        "--address",
        action="store",
        dest="deviceAddress",
        default='',
        type='str',
        help="Address of the device",
        metavar="<device-addr>",
    )

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233)

    logger.info("Testing discovery")
    FailIfNot(test.TestDiscovery(discriminator=TEST_DISCRIMINATOR),
              "Failed to discover any devices.")

    # FailIfNot(test.SetNetworkCommissioningParameters(dataset=TEST_THREAD_NETWORK_DATASET_TLV),
    #           "Failed to finish network commissioning")

    logger.info("Testing key exchange")
    FailIfNot(
        test.TestKeyExchange(ip=options.deviceAddress,
                             setuppin=20202021,
                             nodeid=1), "Failed to finish key exchange")

    #
    # Disable this test for now since it's exposing some bugs
    # in the underlying minimal mDNS component on Linux and triggering crashes.
    #
    # Issue: #15688
    #
    # asyncio.run(test.TestMultiFabric(ip=options.deviceAddress,
    #                                  setuppin=20202021,
    #                                  nodeid=1))
    #
    # logger.info("Testing writing/reading fabric sensitive data")
    # asyncio.run(test.TestFabricSensitive(nodeid=1))

    logger.info("Testing closing sessions")
    FailIfNot(test.TestCloseSession(nodeid=1), "Failed to close sessions")

    logger.info("Testing resolve")
    FailIfNot(test.TestResolve(nodeid=1), "Failed to resolve nodeid")

    # Still test network commissioning
    logger.info("Testing network commissioning")
    FailIfNot(
        asyncio.run(
            NetworkCommissioningTests(devCtrl=test.devCtrl, nodeid=1).run()),
        "Failed to finish network commissioning")

    logger.info("Testing on off cluster")
    FailIfNot(
        test.TestOnOffCluster(nodeid=1,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID), "Failed to test on off cluster")

    logger.info("Testing level control cluster")
    FailIfNot(
        test.TestLevelControlCluster(nodeid=1,
                                     endpoint=LIGHTING_ENDPOINT_ID,
                                     group=GROUP_ID),
        "Failed to test level control cluster")

    logger.info("Testing sending commands to non exist endpoint")
    FailIfNot(
        not test.TestOnOffCluster(nodeid=1, endpoint=233, group=GROUP_ID),
        "Failed to test on off cluster on non-exist endpoint")

    # Test experimental Python cluster objects API
    logger.info("Testing cluster objects API")
    FailIfNot(asyncio.run(ClusterObjectTests.RunTest(test.devCtrl)),
              "Failed when testing Python Cluster Object APIs")

    logger.info("Testing attribute reading")
    FailIfNot(
        test.TestReadBasicAttributes(nodeid=1,
                                     endpoint=ENDPOINT_ID,
                                     group=GROUP_ID),
        "Failed to test Read Basic Attributes")

    logger.info("Testing attribute writing")
    FailIfNot(
        test.TestWriteBasicAttributes(nodeid=1,
                                      endpoint=ENDPOINT_ID,
                                      group=GROUP_ID),
        "Failed to test Write Basic Attributes")

    logger.info("Testing attribute reading basic again")
    FailIfNot(
        test.TestReadBasicAttributes(nodeid=1,
                                     endpoint=ENDPOINT_ID,
                                     group=GROUP_ID),
        "Failed to test Read Basic Attributes")

    logger.info("Testing subscription")
    FailIfNot(test.TestSubscription(nodeid=1, endpoint=LIGHTING_ENDPOINT_ID),
              "Failed to subscribe attributes.")

    logger.info(
        "Testing another subscription that kills previous subscriptions")
    FailIfNot(test.TestSubscription(nodeid=1, endpoint=LIGHTING_ENDPOINT_ID),
              "Failed to subscribe attributes.")

    logger.info("Testing on off cluster over resolved connection")
    FailIfNot(
        test.TestOnOffCluster(nodeid=1,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID), "Failed to test on off cluster")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)
コード例 #12
0
def main():
    optParser = OptionParser()
    optParser.add_option(
        "-t",
        "--timeout",
        action="store",
        dest="testTimeout",
        default=75,
        type='int',
        help="The program will return with timeout after specified seconds.",
        metavar="<timeout-second>",
    )
    optParser.add_option(
        "--address1",
        action="store",
        dest="deviceAddress1",
        default='',
        type='str',
        help="Address of the first device",
    )
    optParser.add_option(
        "--address2",
        action="store",
        dest="deviceAddress2",
        default='',
        type='str',
        help="Address of the second device",
    )
    optParser.add_option(
        "-p",
        "--paa-trust-store-path",
        action="store",
        dest="paaTrustStorePath",
        default='',
        type='str',
        help="Path that contains valid and trusted PAA Root Certificates.",
        metavar="<paa-trust-store-path>")

    (options, remainingArgs) = optParser.parse_args(sys.argv[1:])

    timeoutTicker = TestTimeout(options.testTimeout)
    timeoutTicker.start()

    test = BaseTestHelper(nodeid=112233,
                          paaTrustStorePath=options.paaTrustStorePath,
                          testCommissioner=False)

    FailIfNot(
        test.SetNetworkCommissioningParameters(
            dataset=TEST_THREAD_NETWORK_DATASET_TLV),
        "Failed to finish network commissioning")

    logger.info("Testing PASE connection to device 1")
    FailIfNot(
        test.TestPaseOnly(ip=options.deviceAddress1,
                          setuppin=20202021,
                          nodeid=1),
        "Failed to establish PASE connection with device 1")

    logger.info("Testing PASE connection to device 2")
    FailIfNot(
        test.TestPaseOnly(ip=options.deviceAddress2,
                          setuppin=20202021,
                          nodeid=2),
        "Failed to establish PASE connection with device 2")

    FailIfNot(test.TestCommissionOnly(nodeid=1),
              "Failed to commission device 1")

    FailIfNot(test.TestCommissionOnly(nodeid=2),
              "Failed to commission device 2")

    logger.info("Testing on off cluster on device 1")
    FailIfNot(
        test.TestOnOffCluster(nodeid=1,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID),
        "Failed to test on off cluster on device 1")

    logger.info("Testing on off cluster on device 2")
    FailIfNot(
        test.TestOnOffCluster(nodeid=2,
                              endpoint=LIGHTING_ENDPOINT_ID,
                              group=GROUP_ID),
        "Failed to test on off cluster on device 2")

    timeoutTicker.stop()

    logger.info("Test finished")

    # TODO: Python device controller cannot be shutdown clean sometimes and will block on AsyncDNSResolverSockets shutdown.
    # Call os._exit(0) to force close it.
    os._exit(0)