Example #1
0
    def test_wmi_connection(self):
        """
        Establish a WMI connection to the specified host/namespace, with the right credentials.
        """
        wmi_sampler = WMISampler(
            "Win32_PerfRawData_PerfOS_System",
            ["ProcessorQueueLength"],
            host="myhost",
            namespace="some/namespace",
            username="******",
            password="******"
        )
        wmi_sampler._get_connection()

        # WMI connection is cached
        self.assertIn('myhost:some/namespace:datadog', wmi_sampler._wmi_connections)

        # Connection was established with the right parameters
        self.assertWMIConnWith(wmi_sampler, "myhost")
        self.assertWMIConnWith(wmi_sampler, "some/namespace")