Code Monkey home page Code Monkey logo

log2test's Introduction

log2test

Monthly Downloads Build Status SensioLabsInsight

Log2Test is a PHP application that allows you to transform your Production Log into test.
You can export your log to the following stack:

  • Curl: Php Multi Curl Test => A good solution if you have huge apache2 log file or if you don't need to run JavaScript or Ajax calls
  • PhpunitCurl: Phpunit Curl test
  • PhpunitSelenium: Allows you to open all your log file urls' on defined browsers you need to test

Why exporting your production log files to tests?

  • Be able to find broken links
  • Detect Blank/Empty web pages (When a 500 error occurs and no error redirection page is enabled)
  • Before deploying new features to production, you can easily launch real tests on your pre-production environment
  • Launching all your access log on different browsers with Selenium allows you to validate Cross Browser Compatibility

Install

git clone https://github.com/ousamabenyounes/log2test 
composer install

How to use

Let's now see how Log2Test works step by step as seen on the screencast gif file bellow

  • At the beginning, there are no existing tests in the "generated/Curl" directory
  • Given this context:
    • A configuration file (Yaml File) -> config/parameters-log2test.yml
    • An Apache2 Access Log file -> log/test.log
  • Running ./bin/log2test command will generate and run all your tests

Configuration

Open configuration file:

config/parameters-log2test.yml 

Here are all the configuration file's properties:

Property Type Description Default
hostConfig String Array List of hosts to parse see samples here
logFile String Path to your access log file log/test.log
testStack String Available test stack: "PhpunitSelenium" or "Curl" or "PhpunitCurl Curl
beginLine Int Begin parsing at line X 0
numberOfLine Int Number of lines to parse 300
logParserClass String Your log parsing class \Log2Test\Parser\Log\Apache2LogParser
logFormat String Detail the log format of your acces log file '%h %l %u %t "%r" %>s %b'
extensions_allowed Array Only parse files matching these extentions [php, html]
browsers Array List of browsers -> only for phpunit_selenium stack chrome
removeDuplicateUrl Boolean If you want to remove duplicate urls true
pauseBetweenTests Int Add a pause between all generated tests 0
encodedUrls Boolean Allows you to encode all parsed urls true
enabledScreenshot Boolean Take a screenshot on each test false
testResultFormat string Test result format "xml" or "json" xml

Requirements

Phpunit
Selenium Server (only needed if you choose phpunit_selenium as your test stack)

Test

Log2test is tested with PHPUNIT & Behat

./bin/phpunit 

./bin/behat

On each commit, a complete build is launched on http://travis-ci.org/ousamabenyounes/log2test/

Host Sample

You can provide a simple strings like this:

"www.shop2tout.com"

You can also provide an array with source / destination value

    ["www.shop2tout.com", "www.shop2tout.local"],

The first case is the source host you will be searching on your apache logs
The second case is the destination host which will be used on generated tests
We recommend using the second format, so your production website is not affected by the heavy tests you'll launch'

Todo

Add Global Reporting
Add YellowLabTools option on parsing

Contributors

log2test's People

Contributors

gmetais avatar ousamabenyounes avatar youvalteboul 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  avatar

Watchers

 avatar  avatar  avatar

log2test's Issues

installation du package ousamabenyounes/log2test en erreur

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for ousamabenyounes/log2test dev-master -> satisfiable by ousamabenyounes/log2test[dev-master].
- Can only install one of: ousamabenyounes/log2test[1.1, dev-master].
- Installation request for ousamabenyounes/log2test 1.1 -> satisfiable by ousamabenyounes/log2test[1.1].

Allow curl on page who need authentication

If we launch curl test on a webpage who needs authentication, we get a redirection.
We must think about a way to give login / pwd to authenticate on the application and store session during all tests....

Do not regenerate test if 0 files created

When parsing is finished, if i run log2test binary, it will prompt:

[OK] All curl tests were generated. 0 files created.

So, we must had a check to be sure that it won't regenerate existing classes...

[Insight] Usage of a function in loops should be avoided - in lib/LogParser.php, line 175

in lib/LogParser.php, line 175

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

        $file = $this->getSplFileObject();
        foreach ($hosts as $host) {
            $testConfiguration = $this->getTestConfiguration();
            $testConfiguration[$host] = (!isset($testConfiguration[$host]) ? [] : $testConfiguration[$host]);
            $this->setTestConfiguration($testConfiguration);
            for ($i = 0; $i < $this->getNumberOfLine(); $i++) {
                $line = $file->current();
                if ('' !== trim($line)) {
                    $this->parseOneLine($line);
                }
                $file->next();

Posted from SensioLabsInsight

Memory leak on V1.4 test generation

When I generate tests with log2test v1.4, generated test are getting greater and greater...
Memory leak was identified
Fix is in progress

testSuite Result Isolation

Keep old testSuite results
Define the number of old testSuite we want to keep
Then isolate each new testSuite execution / results

Add test execution time

Adding the execution time on each json test results and the on our global xml result may be usefull.

Parse XML or JSON response

I want to test if the response is a vaild XML or JSON and check if some nodes are missing or not

Example of XML Response Valid :

<result> <_connexion_db>OK</_connexion_db> <_erreurs/> <_data/> </result>

node _connexion_db : OK or KO if the connection is up
node _erreurs : empty if there is no error
node _data : datas

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.