def test_loadPopulationParameters(self):
        """
        Client weights and profiles are loaded from the [clients]
        section of the configuration file specified.
        """
        config = FilePath(self.mktemp())
        config.setContent(writePlistToString({
                    "clients": [{
                            "software": "contrib.performance.loadtest.ical.OS_X_10_6",
                            "params": {"foo": "bar"},
                            "profiles": [{
                                    "params": {
                                        "interval": 25,
                                        "eventStartDistribution": {
                                            "type": "contrib.performance.stats.NormalDistribution",
                                            "params": {
                                                "mu": 123,
                                                "sigma": 456,
                                                }}},
                                    "class": "contrib.performance.loadtest.profiles.Eventer"}],
                            "weight": 3,
                            }]}))

        sim = LoadSimulator.fromCommandLine(
            ['--config', config.path, '--clients', config.path]
        )
        expectedParameters = PopulationParameters()
        expectedParameters.addClient(
            3, ClientType(OS_X_10_6, {"foo": "bar"}, [ProfileType(Eventer, {
                            "interval": 25,
                            "eventStartDistribution": NormalDistribution(123, 456)})]))
        self.assertEquals(sim.parameters, expectedParameters)
Example #2
0
    def test_loadPopulationParameters(self):
        """
        Client weights and profiles are loaded from the [clients]
        section of the configuration file specified.
        """
        config = FilePath(self.mktemp())
        config.setContent(
            writePlistToString(
                {
                    "clients": [
                        {
                            "software": "contrib.performance.loadtest.ical.OS_X_10_6",
                            "params": {
                                "foo": "bar"
                            },
                            "profiles": [
                                {
                                    "params": {
                                        "interval": 25,
                                        "eventStartDistribution": {
                                            "type": "contrib.performance.stats.NormalDistribution",
                                            "params": {
                                                "mu": 123,
                                                "sigma": 456,
                                            }
                                        }
                                    },
                                    "class": "contrib.performance.loadtest.profiles.Eventer"
                                }
                            ],
                            "weight": 3,
                        }
                    ]
                }
            )
        )

        sim = LoadSimulator.fromCommandLine(
            ['--config', config.path, '--clients', config.path]
        )
        expectedParameters = PopulationParameters()
        expectedParameters.addClient(
            3,
            ClientType(
                OS_X_10_6,
                {"foo": "bar"},
                [
                    ProfileType(
                        Eventer, {
                            "interval": 25,
                            "eventStartDistribution": NormalDistribution(123, 456)
                        }
                    )
                ]
            )
        )
        self.assertEquals(sim.parameters, expectedParameters)
Example #3
0
    def test_stop(self):
        """
        After L{CalendarClientSimulator.stop} is called, failed clients and
        profiles are not logged.
        """
        class BrokenClient(object):
            def __init__(self, reactor, serverAddress, principalPathTemplate,
                         serializationPath, userInfo, auth, instanceNumber,
                         runResult):
                self._runResult = runResult

            def run(self):
                return self._runResult

            def stop(self):
                return succeed(None)

        class BrokenProfile(object):
            def __init__(self, reactor, simulator, client, userNumber,
                         runResult):
                self._runResult = runResult
                self.enabled = True

            def initialize(self):
                return succeed(None)

            def run(self):
                return self._runResult

        clientRunResult = Deferred()
        profileRunResult = Deferred()

        params = PopulationParameters()
        params.addClient(
            1,
            ClientType(
                BrokenClient, {'runResult': clientRunResult},
                [ProfileType(BrokenProfile, {'runResult': profileRunResult})]))
        sim = CalendarClientSimulator(
            [self._user('alice')], Populator(None), None, params, None, {
                "PodA": {
                    "enabled": True,
                    "uri": 'http://example.org:1234/',
                    "stats": {
                        "enabled": False
                    },
                },
            }, None, None)
        sim.add(1, 1)
        sim.stop()
        clientRunResult.errback(RuntimeError("Some fictional client problem"))
        profileRunResult.errback(
            RuntimeError("Some fictional profile problem"))

        self.assertEqual([], self.flushLoggedErrors())
Example #4
0
 def test_requireClient(self):
     """
     At least one client is required, so if a configuration with an
     empty clients array is specified, a single default client type
     is used.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({"clients": []}))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     expectedParameters = PopulationParameters()
     expectedParameters.addClient(
         1, ClientType(OS_X_10_6, {}, [Eventer, Inviter, Accepter]))
     self.assertEquals(sim.parameters, expectedParameters)
Example #5
0
 def test_requireClient(self):
     """
     At least one client is required, so if a configuration with an
     empty clients array is specified, a single default client type
     is used.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({"clients": []}))
     sim = LoadSimulator.fromCommandLine(
         ['--config', config.path, '--clients', config.path])
     expectedParameters = PopulationParameters()
     expectedParameters.addClient(
         1, ClientType(OS_X_10_6, {}, [Eventer, Inviter, Accepter]))
     self.assertEquals(sim.parameters, expectedParameters)
Example #6
0
    def test_stop(self):
        """
        After L{CalendarClientSimulator.stop} is called, failed clients and
        profiles are not logged.
        """

        class BrokenClient(object):
            def __init__(self, reactor, serverAddress, principalPathTemplate,
                         serializationPath, userInfo, auth, runResult):
                self._runResult = runResult

            def run(self):
                return self._runResult

            def stop(self):
                return succeed(None)

        class BrokenProfile(object):
            def __init__(self, reactor, simulator, client, userNumber,
                         runResult):
                self._runResult = runResult
                self.enabled = True

            def run(self):
                return self._runResult

        clientRunResult = Deferred()
        profileRunResult = Deferred()

        params = PopulationParameters()
        params.addClient(
            1,
            ClientType(
                BrokenClient, {'runResult': clientRunResult},
                [ProfileType(BrokenProfile, {'runResult': profileRunResult})]))
        sim = CalendarClientSimulator([self._user('alice')], Populator(None),
                                      params, None, 'http://example.com:1234/',
                                      None, None)
        sim.add(1, 1)
        sim.stop()
        clientRunResult.errback(RuntimeError("Some fictional client problem"))
        profileRunResult.errback(
            RuntimeError("Some fictional profile problem"))

        self.assertEqual([], self.flushLoggedErrors())