evennia.server.profiling package

Submodules

evennia.server.profiling.dummyrunner module

Dummy client runner

This module implements a stand-alone launcher for stress-testing an Evennia game. It will launch any number of fake clients. These clients will log into the server and start doing random operations. Customizing and weighing these operations differently depends on which type of game is tested. The module contains a testing module for plain Evennia.

Please note that you shouldn’t run this on a production server! Launch the program without any arguments or options to see a full step-by-step setup help.

Basically (for testing default Evennia):

  • Use an empty/testing database.

  • set PERMISSION_ACCOUNT_DEFAULT = “Builder”

  • start server, eventually with profiling active

  • launch this client runner

If you want to customize the runner’s client actions (because you changed the cmdset or needs to better match your use cases or add more actions), you can change which actions by adding a path to

DUMMYRUNNER_ACTIONS_MODULE = <path.to.your.module>

in your settings. See utils.dummyrunner_actions.py for instructions on how to define this module.

class evennia.server.profiling.dummyrunner.DummyClient[source]

Bases: twisted.conch.telnet.StatefulTelnetProtocol

Handles connection to a running Evennia server, mimicking a real account by sending commands on a timer.

connectionLost(reason)[source]

Called when loosing the connection.

Parameters

reason (str) – Reason for loosing connection.

connectionMade()[source]

Called when connection is first established.

counter()[source]

Produces a unique id, also between clients.

Returns

A unique counter.

Return type

counter (int)

dataReceived(data)[source]

Called when data comes in over the protocol. We wait to start stepping until the server actually responds

Parameters

data (str) – Incoming data.

error(err)[source]

Error callback.

Parameters

err (Failure) – Error instance.

logout()[source]

Causes the client to log out of the server. Triggered by ctrl-c signal.

step()[source]

Perform a step. This is called repeatedly by the runner and causes the client to issue commands to the server. This holds all “intelligence” of the dummy client.

class evennia.server.profiling.dummyrunner.DummyFactory(actions)[source]

Bases: twisted.internet.protocol.ClientFactory

__init__(actions)[source]

Setup the factory base (shared by all clients)

protocol

alias of DummyClient

evennia.server.profiling.dummyrunner.gidcounter()[source]

Makes globally unique ids.

Returns

count (int); A globally unique counter.

evennia.server.profiling.dummyrunner.idcounter()[source]

Makes unique ids.

Returns

A globally unique counter.

Return type

count (int)

evennia.server.profiling.dummyrunner.makeiter(obj)[source]

Makes everything iterable.

Parameters

obj (any) – Object to turn iterable.

Returns

An iterable object.

Return type

iterable (iterable)

evennia.server.profiling.dummyrunner.start_all_dummy_clients(nclients)[source]

Initialize all clients, connect them and start to step them

Parameters

nclients (int) – Number of dummy clients to connect.

evennia.server.profiling.dummyrunner_settings module

Settings and actions for the dummyrunner

This module defines dummyrunner settings and sets up the actions available to dummy accounts.

The settings are global variables:

TIMESTEP - time in seconds between each ‘tick’ CHANCE_OF_ACTION - chance 0-1 of action happening CHANCE_OF_LOGIN - chance 0-1 of login happening TELNET_PORT - port to use, defaults to settings.TELNET_PORT ACTIONS - see below

ACTIONS is a tuple

(login_func, logout_func, (0.3, func1), (0.1, func2) … )

where the first entry is the function to call on first connect, with a chance of occurring given by CHANCE_OF_LOGIN. This function is usually responsible for logging in the account. The second entry is always called when the dummyrunner disconnects from the server and should thus issue a logout command. The other entries are tuples (chance, func). They are picked randomly, their commonality based on the cumulative chance given (the chance is normalized between all options so if will still work also if the given chances don’t add up to 1). Since each function can return a list of game-command strings, each function may result in multiple operations.

An action-function is called with a “client” argument which is a reference to the dummy client currently performing the action. It returns a string or a list of command strings to execute. Use the client object for optionally saving data between actions.

The client object has the following relevant properties and methods:
key - an optional client key. This is only used for dummyrunner output.

Default is “Dummy-<cid>”

cid - client id gid - globally unique id, hashed with time stamp istep - the current step exits - an empty list. Can be used to store exit names objs - an empty list. Can be used to store object names counter() - returns a unique increasing id, hashed with time stamp

to make it unique also between dummyrunner instances.

The return should either be a single command string or a tuple of command strings. This list of commands will always be executed every TIMESTEP with a chance given by CHANCE_OF_ACTION by in the order given (no randomness) and allows for setting up a more complex chain of commands (such as creating an account and logging in).

evennia.server.profiling.dummyrunner_settings.c_creates_button(client)[source]

creates example button, storing name on client

evennia.server.profiling.dummyrunner_settings.c_creates_obj(client)[source]

creates normal objects, storing their name on client

evennia.server.profiling.dummyrunner_settings.c_digs(client)[source]

digs a new room, storing exit names on client

evennia.server.profiling.dummyrunner_settings.c_examines(client)[source]

examines various objects

evennia.server.profiling.dummyrunner_settings.c_help(client)[source]

reads help files

evennia.server.profiling.dummyrunner_settings.c_idles(client)[source]

idles

evennia.server.profiling.dummyrunner_settings.c_login(client)[source]

logins to the game

evennia.server.profiling.dummyrunner_settings.c_login_nodig(client)[source]

logins, don’t dig its own room

evennia.server.profiling.dummyrunner_settings.c_logout(client)[source]

logouts of the game

evennia.server.profiling.dummyrunner_settings.c_looks(client)[source]

looks at various objects

evennia.server.profiling.dummyrunner_settings.c_moves(client)[source]

moves to a previously created room, using the stored exits

evennia.server.profiling.dummyrunner_settings.c_moves_n(client)[source]

move through north exit if available

evennia.server.profiling.dummyrunner_settings.c_moves_s(client)[source]

move through south exit if available

evennia.server.profiling.dummyrunner_settings.c_socialize(client)[source]

socializechats on channel

evennia.server.profiling.memplot module

Script that saves memory and idmapper data over time.

Data will be saved to game/logs/memoryusage.log. Note that the script will append to this file if it already exists.

Call this module directly to plot the log (requires matplotlib and numpy).

class evennia.server.profiling.memplot.Memplot(*args, **kwargs)[source]

Bases: evennia.scripts.scripts.DefaultScript

Describes a memory plotting action.

exception DoesNotExist

Bases: evennia.scripts.scripts.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.scripts.scripts.MultipleObjectsReturned

_meta = <Options for Memplot>
at_repeat()[source]

Regularly save memory statistics.

at_script_creation()[source]

Called at script creation

path = 'evennia.server.profiling.memplot.Memplot'
typename = 'Memplot'

evennia.server.profiling.settings_mixin module

Dummyrunner mixin. Add this at the end of the settings file before running dummyrunner, like this:

from evennia.server.profiling.settings_mixin import *

Note that these mixin-settings are not suitable for production servers!

evennia.server.profiling.test_queries module

This is a little routine for viewing the sql queries that are executed by a given query as well as count them for optimization testing.

evennia.server.profiling.test_queries.count_queries(exec_string, setup_string)[source]

Display queries done by exec_string. Use setup_string to setup the environment to test.

evennia.server.profiling.tests module

class evennia.server.profiling.tests.TestDummyrunnerSettings(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

clear_client_lists()[source]
perception_method_tests(func, verb, alone_suffix='')[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_c_creates_button()[source]
test_c_creates_obj()[source]
test_c_digs()[source]
test_c_examines()[source]
test_c_help()[source]
test_c_login()[source]
test_c_login_no_dig()[source]
test_c_logout()[source]
test_c_looks()[source]
test_c_move_n()[source]
test_c_move_s()[source]
test_c_moves()[source]
test_c_socialize()[source]
test_idles()[source]
class evennia.server.profiling.tests.TestMemPlot(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

test_memplot(mock_time, mocked_open, mocked_os, mocked_idmapper)[source]

evennia.server.profiling.timetrace module

Trace a message through the messaging system

evennia.server.profiling.timetrace.timetrace(message, idstring, tracemessage='TEST_MESSAGE', final=False)[source]

Trace a message with time stamps.

Parameters
  • message (str) – The actual message coming through

  • idstring (str) – An identifier string specifying where this trace is happening.

  • tracemessage (str) – The start of the message to tag. This message will get attached time stamp.

  • final (bool) – This is the final leg in the path - include total time in message