Exemple #1
0
    def startNetTest(self, net_test_loader, report_filename,
                     collector_client=None, no_yamloo=False):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        test_details = net_test_loader.getTestDetails()
        test_cases = net_test_loader.getTestCases()

        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap or config.global_options.get('pcapfile', None):
            self.startSniffing(test_details)
        report = Report(test_details, report_filename,
                        self.reportEntryManager,
                        collector_client,
                        no_yamloo)

        yield report.open()
        net_test = NetTest(test_cases, test_details, report)
        net_test.director = self

        yield net_test.initialize()
        try:
            self.activeNetTests.append(net_test)
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            self.netTestDone(net_test)
Exemple #2
0
    def startNetTest(self, net_test_loader, report_filename,
                     collector_address=None):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap:
            self.startSniffing(net_test_loader.testDetails)

        report = Report(net_test_loader.testDetails, report_filename,
                        self.reportEntryManager, collector_address)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        yield net_test.initializeInputProcessor()
        try:
            self.activeNetTests.append(net_test)
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            self.netTestDone(net_test)
Exemple #3
0
    def startNetTest(self, net_test_loader, reporters):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """

        if config.privacy.includepcap:
            if not config.reports.pcap:
                config.reports.pcap = config.generatePcapFilename(net_test_loader.testDetails)
            self.startSniffing()

        report = Report(reporters, self.reportEntryManager)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        yield net_test.initializeInputProcessor()
        self.measurementManager.schedule(net_test.generateMeasurements())

        self.activeNetTests.append(net_test)

        yield net_test.done
        yield report.close()

        self.netTestDone(net_test)
Exemple #4
0
    def startNetTest(self,
                     net_test_loader,
                     report_filename,
                     collector_address=None):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap:
            self.startSniffing(net_test_loader.testDetails)

        report = Report(net_test_loader.testDetails, report_filename,
                        self.reportEntryManager, collector_address)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        yield net_test.initializeInputProcessor()
        try:
            self.activeNetTests.append(net_test)
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            self.netTestDone(net_test)
Exemple #5
0
 def test_fail_to_open_single_report_with_multiple_reporter(self):
     report = Report([MockOReporterThatFailsOpen(), MockOReporter(),
             MockOReporter()], ReportEntryManager())
     d = report.open()
     def f(x):
         self.assertEquals(len(report.reporters),2)
     d.addCallback(f)
     return d
Exemple #6
0
 def test_write_report_with_multiple_reporter_and_fail_all_reporter(self):
     report = Report([MockOReporterThatFailsWrite() for x in xrange(3)], ReportEntryManager())
     report.open()
     d = report.write(MockMeasurement(MockNetTest()))
     def f(err):
         self.assertEquals(len(report.reporters),0)
     d.addErrback(f)
     return d
Exemple #7
0
 def test_fail_to_open_all_reports_with_multiple_reporter(self):
     report = Report([MockOReporterThatFailsOpen() for x in xrange(3)],
             ReportEntryManager())
     d = report.open()
     def f(x):
         self.assertEquals(len(report.reporters),0)
     d.addCallback(f)
     return d
Exemple #8
0
 def test_write_report_with_single_reporter_and_fail_after_timeout(self):
     report = Report([MockOReporterThatFailsWrite()], ReportEntryManager())
     report.open()
     d = report.write(MockMeasurement(MockNetTest()))
     def f(err):
         self.assertEquals(len(report.reporters),0)
     d.addBoth(f)
     return d
Exemple #9
0
    def test_write_report_with_multiple_reporter_and_fail_a_single_reporter(self):
        report = Report([MockOReporter(), MockOReporter(), MockOReporterThatFailsWrite()], ReportEntryManager())
        d = report.open()

        self.assertEquals(len(report.reporters),3)
        d = report.write(MockMeasurement(MockNetTest()))

        def f(x):
            # one of the reporters should have been removed
            self.assertEquals(len(report.reporters), 2)
        d.addBoth(f)
        return d
Exemple #10
0
    def startNetTest(self, _, net_test_loader, reporters):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader

            _: #XXX very dirty hack
        """

        if config.privacy.includepcap:
            log.msg("Starting")
            if not config.reports.pcap:
                config.reports.pcap = config.generatePcapFilename(
                    net_test_loader.testDetails)
            self.startSniffing()

        report = Report(reporters, self.reportEntryManager)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        self.measurementManager.schedule(net_test.generateMeasurements())

        self.activeNetTests.append(net_test)

        net_test.done.addBoth(report.close)
        net_test.done.addBoth(self.netTestDone, net_test)

        yield net_test.done
Exemple #11
0
    def start_net_test_loader(self,
                              net_test_loader,
                              report_filename,
                              collector_client=None,
                              no_yamloo=False,
                              test_details=None,
                              measurement_id=None):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        if test_details is None:
            test_details = net_test_loader.getTestDetails()
        test_cases = net_test_loader.getTestCases()

        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap or config.global_options.get(
                'pcapfile', None):
            self.start_sniffing(test_details)
        report = Report(test_details, report_filename, self.reportEntryManager,
                        collector_client, no_yamloo, measurement_id)

        yield report.open()
        net_test = NetTest(test_cases, test_details, report)
        net_test.director = self

        yield net_test.initialize()
        try:
            self.activeNetTests.append(net_test)
            if measurement_id:
                self.activeMeasurements[measurement_id] = net_test
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            if measurement_id:
                del self.activeMeasurements[measurement_id]
            self.netTestDone(net_test)
Exemple #12
0
    def startNetTest(self,
                     net_test_loader,
                     report_filename,
                     collector_address=None,
                     no_yamloo=False):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        # Here we set the test details again since the geoip lookups may
        # not have already been done and probe_asn and probe_ip
        # are not set.
        net_test_loader.setTestDetails()

        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap:
            self.startSniffing(net_test_loader.testDetails)
        report = Report(net_test_loader.testDetails, report_filename,
                        self.reportEntryManager, collector_address, no_yamloo)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        yield net_test.initializeInputProcessor()
        try:
            self.activeNetTests.append(net_test)
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            self.netTestDone(net_test)
    def startNetTest(self, net_test_loader, reporters):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        report = Report(reporters, self.reportEntryManager)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        self.measurementManager.schedule(net_test.generateMeasurements())

        self.activeNetTests.append(net_test)

        yield net_test.done
        yield report.close()

        self.netTestDone(net_test)
Exemple #14
0
    def startNetTest(self, net_test_loader, report_filename,
                     collector_address=None, no_yamloo=False):
        """
        Create the Report for the NetTest and start the report NetTest.

        Args:
            net_test_loader:
                an instance of :class:ooni.nettest.NetTestLoader
        """
        # Here we set the test details again since the geoip lookups may
        # not have already been done and probe_asn and probe_ip
        # are not set.
        net_test_loader.setTestDetails()

        if self.allTestsDone.called:
            self.allTestsDone = defer.Deferred()

        if config.privacy.includepcap:
            self.startSniffing(net_test_loader.testDetails)
        report = Report(net_test_loader.testDetails, report_filename,
                        self.reportEntryManager, collector_address,
                        no_yamloo)

        net_test = NetTest(net_test_loader, report)
        net_test.director = self

        yield net_test.report.open()

        yield net_test.initializeInputProcessor()
        try:
            self.activeNetTests.append(net_test)
            self.measurementManager.schedule(net_test.generateMeasurements())

            yield net_test.done
            yield report.close()
        finally:
            self.netTestDone(net_test)
Exemple #15
0
 def test_report_open_with_single_reporter(self):
     report = Report([MockOReporter()],ReportEntryManager())
     d = report.open()
     return d
Exemple #16
0
 def test_report_open_with_multiple_reporter(self):
     report = Report([MockOReporter() for x in xrange(3)],
             ReportEntryManager())
     d = report.open()
     return d
Exemple #17
0
 def test_write_report_with_multiple_reporter_and_succeed(self):
     report = Report([MockOReporter() for x in xrange(3)], ReportEntryManager())
     report.open()
     d = report.write(MockMeasurement(MockNetTest()))
     return d
Exemple #18
0
 def test_write_report_with_single_reporter_and_succeed_after_timeout(self):
     report = Report([MockOReporterThatFailsWriteOnce()], ReportEntryManager())
     report.open()
     d = report.write(MockMeasurement(MockNetTest()))
     return d
Exemple #19
0
 def test_write_report_with_single_reporter_and_succeed(self):
     #XXX: verify that the MockOReporter writeReportEntry succeeds
     report = Report([MockOReporter()], ReportEntryManager())
     report.open()
     d = report.write(MockMeasurement(MockNetTest()))
     return d