当前位置: 首页>>代码示例>>Python>>正文


Python sim.LoadSimulator类代码示例

本文整理汇总了Python中contrib.performance.loadtest.sim.LoadSimulator的典型用法代码示例。如果您正苦于以下问题:Python LoadSimulator类的具体用法?Python LoadSimulator怎么用?Python LoadSimulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LoadSimulator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_createArrivalPolicy

    def test_createArrivalPolicy(self):
        """
        L{LoadSimulator.createArrivalPolicy} creates an arrival
        policy based on the L{Arrival} passed to its initializer.
        """

        class FakeArrival(object):
            def __init__(self, reactor, x, y):
                self.reactor = reactor
                self.x = x
                self.y = y

        reactor = object()
        sim = LoadSimulator(
            None,
            None,
            None,
            None,
            None,
            Arrival(FakeArrival, {
                'x': 3,
                'y': 2
            }),
            None,
            reactor=reactor)
        arrival = sim.createArrivalPolicy()
        self.assertIsInstance(arrival, FakeArrival)
        self.assertIdentical(arrival.reactor, sim.reactor)
        self.assertEquals(arrival.x, 3)
        self.assertEquals(arrival.y, 2)
开发者ID:redtailtech,项目名称:calendarserver,代码行数:30,代码来源:test_sim.py

示例2: test_createSimulator

 def test_createSimulator(self):
     """
     L{LoadSimulator.createSimulator} creates a L{CalendarClientSimulator}
     with its own reactor and host and port information from the
     configuration file.
     """
     server = 'http://127.0.0.7:1243/'
     reactor = object()
     sim = LoadSimulator(server, None, None, None, None, None, None, reactor=reactor)
     calsim = sim.createSimulator()
     self.assertIsInstance(calsim, CalendarClientSimulator)
     self.assertIsInstance(calsim.reactor, LagTrackingReactor)
     self.assertIdentical(calsim.reactor._reactor, reactor)
     self.assertEquals(calsim.server, server)
开发者ID:nunb,项目名称:calendarserver,代码行数:14,代码来源:test_sim.py

示例3: test_generateRecordsNonDefaultPatterns

 def test_generateRecordsNonDefaultPatterns(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to generate user records for use in the
     simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.generateRecords",
         "params": {
             "count": 3,
             "uidPattern": "USER%03d",
             "passwordPattern": "PASSWORD%03d",
             "namePattern": "Test User %03d",
             "emailPattern": "USER%[email protected]",
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(3, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'USER001')
     self.assertEqual(sim.records[0].password, 'PASSWORD001')
     self.assertEqual(sim.records[0].commonName, 'Test User 001')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[2].uid, 'USER003')
     self.assertEqual(sim.records[2].password, 'PASSWORD003')
     self.assertEqual(sim.records[2].commonName, 'Test User 003')
     self.assertEqual(sim.records[2].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:30,代码来源:test_sim.py

示例4: test_generateRecordsDefaultPatterns

 def test_generateRecordsDefaultPatterns(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to generate user records for use in the
     simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.generateRecords",
         "params": {
             "count": 2
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(2, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'user1')
     self.assertEqual(sim.records[0].password, 'user1')
     self.assertEqual(sim.records[0].commonName, 'User 1')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[1].uid, 'user2')
     self.assertEqual(sim.records[1].password, 'user2')
     self.assertEqual(sim.records[1].commonName, 'User 2')
     self.assertEqual(sim.records[1].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:26,代码来源:test_sim.py

示例5: test_loadDefaultAccountsFromFile

 def test_loadDefaultAccountsFromFile(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader (with
     empty path)from the config file and uses it to create user
     records for use in the simulation.
     """
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.recordsFromCSVFile",
         "params": {
             "path": ""
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
                                         StringIO())
     self.assertEqual(99, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'user01')
     self.assertEqual(sim.records[0].password, 'user01')
     self.assertEqual(sim.records[0].commonName, 'User 01')
     self.assertEqual(sim.records[0].email, '[email protected]')
     self.assertEqual(sim.records[98].uid, 'user99')
     self.assertEqual(sim.records[98].password, 'user99')
     self.assertEqual(sim.records[98].commonName, 'User 99')
     self.assertEqual(sim.records[98].email, '[email protected]')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:26,代码来源:test_sim.py

示例6: test_loadAccountsFromFile

 def test_loadAccountsFromFile(self):
     """
     L{LoadSimulator.fromCommandLine} takes an account loader from the
     config file and uses it to create user records for use in the
     simulation.
     """
     accounts = FilePath(self.mktemp())
     accounts.setContent("foo,bar,baz,quux\nfoo2,bar2,baz2,quux2\n")
     config = VALID_CONFIG.copy()
     config["accounts"] = {
         "loader": "contrib.performance.loadtest.sim.recordsFromCSVFile",
         "params": {
             "path": accounts.path
         },
     }
     configpath = FilePath(self.mktemp())
     configpath.setContent(writePlistToString(config))
     io = StringIO()
     sim = LoadSimulator.fromCommandLine(['--config', configpath.path], io)
     self.assertEquals(io.getvalue(), "Loaded 2 accounts.\n")
     self.assertEqual(2, len(sim.records))
     self.assertEqual(sim.records[0].uid, 'foo')
     self.assertEqual(sim.records[0].password, 'bar')
     self.assertEqual(sim.records[0].commonName, 'baz')
     self.assertEqual(sim.records[0].email, 'quux')
     self.assertEqual(sim.records[1].uid, 'foo2')
     self.assertEqual(sim.records[1].password, 'bar2')
     self.assertEqual(sim.records[1].commonName, 'baz2')
     self.assertEqual(sim.records[1].email, 'quux2')
开发者ID:redtailtech,项目名称:calendarserver,代码行数:29,代码来源:test_sim.py

示例7: test_loadPopulationParameters

    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)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:32,代码来源:test_sim.py

示例8: config

 def config(self, plist):
     from sys import stderr
     cfg = readPlistFromString(plist)
     addObserver(self.emit)
     sim = LoadSimulator.fromConfig(cfg)
     sim.records = self.records
     sim.attachServices(stderr)
     return {}
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:8,代码来源:ampsim.py

示例9: test_specifyRuntime

 def test_specifyRuntime(self):
     """
     L{LoadSimulator.fromCommandLine} recognizes the I{--runtime} option to
     specify a limit on how long the simulation will run.
     """
     config = FilePath(self.mktemp())
     config.setContent(VALID_CONFIG_PLIST)
     sim = LoadSimulator.fromCommandLine(['--config', config.path, '--runtime', '123'])
     self.assertEqual(123, sim.runtime)
开发者ID:nunb,项目名称:calendarserver,代码行数:9,代码来源:test_sim.py

示例10: test_loadServerConfig

 def test_loadServerConfig(self):
     """
     The Calendar Server host and port are loaded from the [server]
     section of the configuration file specified.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
                 "server": "https://127.0.0.3:8432/"}))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(sim.server, "https://127.0.0.3:8432/")
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:10,代码来源:test_sim.py

示例11: test_observeRunReport

 def test_observeRunReport(self):
     """
     Each log observer is added to the log publisher before the
     simulation run is started and has its C{report} method called
     after the simulation run completes.
     """
     observers = [Observer()]
     sim = LoadSimulator(
         "http://example.com:123/",
         "/principals/users/%s/",
         None,
         None,
         Arrival(lambda reactor: NullArrival(), {}),
         None, observers, reactor=Reactor())
     io = StringIO()
     sim.run(io)
     self.assertEquals(io.getvalue(), "\n*** PASS\n")
     self.assertTrue(observers[0].reported)
     self.assertEquals(
         observers[0].events[0]['message'], (Reactor.message,))
开发者ID:azbarcea,项目名称:calendarserver,代码行数:20,代码来源:test_sim.py

示例12: test_loadLogObservers

 def test_loadLogObservers(self):
     """
     Log observers specified in the [observers] section of the
     configuration file are added to the logging system.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
         "observers": [{"type":"contrib.performance.loadtest.population.SimpleStatistics", "params":{}, }, ]
     }))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(len(sim.observers), 1)
     self.assertIsInstance(sim.observers[0], SimpleStatistics)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:12,代码来源:test_sim.py

示例13: test_requireClient

 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)
开发者ID:azbarcea,项目名称:calendarserver,代码行数:13,代码来源:test_sim.py

示例14: test_loadArrivalConfig

 def test_loadArrivalConfig(self):
     """
     The arrival policy type and arguments are loaded from the
     [arrival] section of the configuration file specified.
     """
     config = FilePath(self.mktemp())
     config.setContent(writePlistToString({
                 "arrival": {
                     "factory": "contrib.performance.loadtest.population.SmoothRampUp",
                     "params": {
                         "groups": 10,
                         "groupSize": 1,
                         "interval": 3,
                         },
                     },
                 }))
     sim = LoadSimulator.fromCommandLine(['--config', config.path])
     self.assertEquals(
         sim.arrival,
         Arrival(SmoothRampUp, dict(groups=10, groupSize=1, interval=3)))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:20,代码来源:test_sim.py


注:本文中的contrib.performance.loadtest.sim.LoadSimulator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。