Coder Social home page Coder Social logo

ejabberd_tests's Introduction

Test suite for ESL's branch of ejabberd

This repository contains test code for ejabberd/MongooseIM. It's used mainly for ESL's branch of ejabberd, but one that may be reused in other projects.

How to run tests

There are 2 ways of running the tests:

By default both commands are using the default.spec file where options like suites to run, config file(s) and log dir are specified. To use custom .spec file (for example to add other suites or remove the existing ones) one must add it to one of the mentioned commands:

make quicktest TESTSPEC=full.spec

Additional erlang binaries required by custom suites can be added to the path by providing ADD_OPTS parameter to the make command. For example:

make quicktest ADD_OPTS="-pa /full/path/to/erlcloud/ebin"

Of course TESTSPEC and ADD_OPTS can be specified at the same time:

make quicktest TESTSPEC=custom.spec ADD_OPTS="-pa /full/path/to/erlcloud/ebin"

Testing various server configurations

It is possible to run tests for various ejabberd configurations.
In order to do this define configuration variables in test.config file, for example:

{ejabberd_configs, [
    {internal_mnesia,
        [{sm_backend, "{mnesia, []}"},
        {auth_method, "internal"}]},
    {internal_redis,
        [{sm_backend, "{redis, [{pool_size, 3}, {worker_config, [{host, \"localhost\"}, {port, 6379}]}]}"},
        {auth_method, "internal"}]}
    ]}.

For each configuration the given variables merged with values from node1_vars.config will be overlaid with the original ejabberd.cfg file and ejabberd will be restarted.

If there is no ejabberd_configs entry in the config file the test will run ordinarily with running ejabberd configuration.

Changing server configuration in suites

Sometimes it is required to change server configuration for a particular test or test suite. ejabberd_node_utils module introduces a set of functions allowing such server manipulation.

For example to make server require starttls and utilize given certificate, use the module as follows:

init_per_suite(Config) ->
    setup_ejabberd_node(Config).

end_per_suite(Config) ->
    restore_ejabberd_node(Config).

...

setup_ejabberd_node(Config0) ->
    Config1 = ejabberd_node_utils:init(Config0),
    ejabberd_node_utils:backup_config_file(Config1),
    assert_cert_file_exists(),
    make_ejabberd_node_require_starttls(Config1),
    ejabberd_node_utils:restart_application(ejabberd),
    Config1.

restore_ejabberd_node(Config) ->
    ejabberd_node_utils:restore_config_file(Config),
    ejabberd_node_utils:restart_application(ejabberd).

assert_cert_file_exists() ->
    ejabberd_node_utils:file_exists(?CERT_FILE) orelse
        ct:fail("cert file ~s not exists", [?CERT_FILE]).

make_ejabberd_node_require_starttls(Config) ->
    ejabberd_node_utils:modify_config_file([mk_value_for_tls_config_pattern()],
                                           Config).

mk_value_for_tls_config_pattern() ->
    {tls_config, "{certfile, \"" ++ ?CERT_FILE ++ "\"}, starttls_required,"}.

The above snippet backups current server's config file, asserts that the expected certificate files exists and then produces new config file. At the end it restart the server so that the new configuration can be applied. In the end_per_suite previously backuped config file is restored and the server is restarted again. See ejabberd_node_utils for more information.

ejabberd_tests's People

Contributors

alipiec avatar arcusfelis avatar aszlig avatar bpuzon avatar chrzaszcz avatar erszcz avatar fenek avatar goj avatar konradkaplita avatar legoscia avatar michalwski avatar paulgray avatar paulsd avatar pianiel avatar ppikula avatar rolios avatar shambhuprasad58 avatar studzien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ejabberd_tests's Issues

Broken end_per_suites

Some suites try to use output of escalus:delete_users as new Config but this function returns just ok. It is difficult to notice, because CT doesn't scream about failed end_per_suites and does not stop testing. Example of such suite is sm_SUITE, there can be more of them.

init_per_suite skipped during 'make test' run

When running the test suites, via 'make test', against ESL ejabberd init_per_suite is always skipped for each suite - a sample of my logs are below. I am new to erlang/ejabberd and escalus so I'm having trouble investigating the cause. Is there documentation available for ejabberd_tests? Thanks in advance.

Testing ejabberd_tests.tests.login_SUITE: Starting test, 6 test cases
Testing ejabberd_tests.tests.login_SUITE: *** SKIPPED *** init_per_suite
Testing ejabberd_tests.tests.login_SUITE: TEST COMPLETE, 0 ok, 0 failed, 6 skipped of 6 test cases

add tests for pep/geoloc

Are there any plans for writing pep/geoloc tests? We are having some people reporting problems with pep on our network, and it would be nice to prove whether it's the client or server's fault ;-)

Bosh and reconnects

Kate (with jid carol@localhost) sometimes receives this:

     {xmlel,<<"presence">>,
         [{<<"type">>,<<"unavailable">>},
          {<<"to">>,<<"carol@localhost/res1">>},
          {<<"from">>,<<"carol@localhost/res1">>}],
         [{xmlel,<<"status">>,[],
              [{xmlcdata,<<"Replaced by new connection">>}]}]}

Garbidge left after moderator_voice_list

Presence stanzas from Carol can be received in next tests.
There are two ways to solve this:

  1. split group "moderator" into two: with and without Carol.
  2. wait for an empty room in init_per_testcase.

patch up the tests after exml's API cleanup

exml's xmlelement record's body attribute is called children now.
Fix the tests to use the new name.

The exml_query:path function doesn't accept elements as a path component any more. Use the new exml_query:paths instead.

The new exml code is to be found in api_cleanup branch

Add test to ensure features are available after STARTTLS

This is an addendum to #131, which actually got me to that issue.

Now, escalus seems to just authenticate with the server, regardless of whether the server advertises auth mechanisms or not, so it might be a very good idea to have a check for that either in escalus directly or here.

failed quicktest

Hi, After running make quicktest it fails due to error reaching a dependency. Explicitly the error is below. Not sure if it is an error in the way dependency is being pulled or if I am doing anything incorrect.

Operating system: Ubuntu 14.04
erlang 18.1

Cloning into 'mochijson3'...
Pulling lhttpc from {git,"git://github.com/waisbrot/lhttpc.git", "824a89316d59353181990f5a461157751ca67907"}
Cloning into 'lhttpc'... fatal: reference is not a tree: 824a89316d59353181990f5a461157751ca67907
ERROR: git checkout -q 824a89316d59353181990f5a461157751ca67907 failed with error: 128 and output: fatal: reference is not a tree: 824a89316d59353181990f5a461157751ca67907
ERROR: 'get-deps' failed while processing /home/ejabberd_tests/deps/katt: rebar_abort make: *** [get-deps] Error 1

Break up muc_SUITE to smaller suites

I think each group or at least groups: moderator, admin (including admin_membersonly), occupant and owner should be moved to their own suites. Current muc_SUITE.erl file is far to big... ~4k lines of code...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.