Skip to content

Commit

Permalink
Add full regression testing framework from SpikeSource/Augmentim
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskl committed Dec 16, 2005
1 parent 8a5460d commit ef11894
Show file tree
Hide file tree
Showing 53 changed files with 7,254 additions and 0 deletions.
149 changes: 149 additions & 0 deletions tests/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@


README




Document History
Version
Date
Author
Comments
0.1
06/07/05
Augmentum SpikeSource Team
Initial Draft
1.0
06/10/05
Augmentum SpikeSource Team
Promote to release

























Summary:

This test archive contains the automated test suite for phpPgAdmin, a web-based database management tool for PostgreSQL. The package also contains the related documents, including the test plan, test setup documents, as well as the test case specification and issue reports.


Folder Structure:

----build
|
------data
|
------testcase
|
-------Public
|
-------Common
|
-------Server
|
-------Databases
|
-------Schemas
|
-------Tables
|
-------Lang

1. The "data" folder contains the resources needed in the testing cases

2. The testing work is divided into 5 parts according to the function areas of phpPgAdmin
a. "Public" sets the global env for the testing
b. "Common" tests the common functionalities of phpPgAdmin
c. "Server" tests the server level functionalities
d. "Database" tests the database level functionalities
e. "Schema" tests the schema level functionalities
f. "Table" tests the table level functionalities
g. �Lang� contains the phpPgAdmin language package

The test suite is implemented based on the SimpleTest Framework (v1.0). The phpPgAdmin (3.5.3) application is tested using Apache2 application server and PostgreSQL 8.0.3 database server. The code coverage is measured using spikePhpCoverage (0.6.2).


Run the Test:

To run the test suite, measure code coverage using spikephpcoverage:

To run the test suite, run the following commands assuming that the PHP command line executable is in your path. The following alose assumes that your web server deploy directory is "/usr/local/apache2/htdocs" (Linux), �C:\apache2\htdocs�, simpletest deploy directory is
"/usr/local/apache2/htdocs/simpletest" (Linux), �C:\apache2\htdocs\simpletest�

Linux:
# Depoly application
$ export PHPCOVERAGE_HOME=/usr/local/apache2/htdocs/phpcoverage/src
$ cp -rp TestphpPgAdmin /usr/local/apache2/htdocs
# Instrument
$ php ${PHPCOVERAGE_HOME}/cli/instrument.php -b
/usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/
/usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/
# Execute
$ php coveragephpPgAdminMain.php
PHPCOVERAGE_APPBASE_PATH=/usr/local/apache2/htdocs/TestphpPgAdmin/phpPgAdmin/
PHP_SIMPLETEST_HOME=/usr/local/apache2/htdocs/

Windows:
Open a command window, issue the following commands:
C:\> set PHPCOVERAGE_HOME= C:\apache2\htdocs\phpcoverage\src
# Instrument
C:\> php ${PHPCOVERAGE_HOME}\cli\instrument.php -b C:\apache2\htdocs\phpPgAdmin\
C:\apache2\htdocs\phpPgAdmin\
# Execute
C:\> php coveragephpPgAdminMain.php PHPCOVERAGE_APPBASE_PATH=C:\apache2\htdocs\phpPgAdmin\
PHP_SIMPLETEST_HOME=C:\apache2\htdocs\


Test Results Summary and Analysis:

Test Summary:
There are a total of 1166 assertions in this test suite, 1162 passes, 4 fails and 6 exceptions.

Fails Analysis:
1. One failed case is related to the dropping of databases
For detailed information, refer to "phpPgAdmin Issue Report"
2. Three failed cases are related to upload files (import data and run sql script file).
Currently, SimpleTest1.0 does not support upload files.
For detailed information, refer to "SimpleTest Issue Report".

Exception Analysis:
1. All six exceptions are related to the Tables module. SimpleTest1.0 cannot handle non-
submit button. For detailed information, refer to "SimpleTest Issue Report".

Other issues:
1. It is possible that one test case may fail in the Schema/ConversionTest.
Typically there should be conversions in the schema pg_catalog in template1, but if
there are no conversions, the assertion in our test will fail. We implemented our test
based on the normal case.
2. Occasionally, if the web server is overloaded, there may be latency, which could cause
some assertions to fail
3. In addition, PostgreSQL has some limitations. For example, if you already have a psql
session running, you cannot create database in another session. If you try, you will get
the following message:
"ERROR: source database "template1" is being accessed by other users"
4. It is possible that one test case may fail in the Database/ProcessesTest.
Typically there should be no processes in the process list page, but if there are many
database accesses, there will be processes in the list. The assertion in our test will
fail. We implemented our test based on the normal case.

180 changes: 180 additions & 0 deletions tests/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
- Copyright(c) 2004, SpikeSource Inc. All Rights Reserved.
- Licensed under the Open Source License version 2.1
- (See http://www.spikesource.com/license.html)
-->

<project name="phpPgAdminTest">

<!--
These two lines are necessary in order to inherit the environment and
resolve the properties in the top-level project.properties properly
-->
<property environment="env"/>
<property file="${spike.parent.dir}/project.properties"/>

<property name="deploy.dir" value="${spike.httpd.docroot}/phpPgAdmin"/>

<!-- General targets, required -->

<target name="spike:versions-dependency"
description="Return the SpikeSource stack version required by the application and tests.">
<echo>SpikeSource Core Stack 1.4</echo>
</target>

<target name="spike:interface-version"
description="Return the interface version implemented by this build script.">
<echo>1.0</echo>
</target>

<target name="spike:clean">
<!--
The deploy and class file directories are recreated here.
This is for deleting all the class files created during
previous test runs....
-->

<delete dir="classes"/>
<delete dir="${deploy.dir}"/>
</target>


<target name="spike:install">
<mkdir dir="${deploy.dir}"/>
<chmod dir="${deploy.dir}" type="dir" perm="777" />
<chmod dir="${basedir}/data" type="dir" perm="777" />
<chmod dir="${basedir}/data/TableSpace" type="dir" perm="777" />
<copy todir="${deploy.dir}" preservelastmodified="true">
<fileset dir="${basedir}/phpPgAdmin" includes="**/*.*" excludes=""/>
</copy>
<chmod type="file" perm="777">
<fileset dir="${deploy.dir}">
<include name="**/*.*"/>
</fileset>
</chmod>
<echo>Replace spike_bin_dir in /conf/config.inc.php with '${spike.bin.dir}'</echo>
<replace file="${deploy.dir}/conf/config.inc.php" token="spike_bin_dir" value="${spike.bin.dir}"/>
</target>

<target name="spike:compile">
<echo>Do nothing</echo>
</target>

<target name="spike:pre-test-configure">
<!--command for bringing up any dependent components can be written here-->
<exec executable="maven" dir="${spike.parent.dir}">
<arg line="-b -E"/>
<arg value="spike:startup-httpd"/>
<arg value="spike:startup-postgresql"/>
</exec>
<exec dir="${deploy.dir}/sql" executable="${spike.bin.dir}/psql">
<arg line="-f test.sql -d template1 -U '${spike.postgresql.adminuser}'"/>
</exec>
<exec dir="${deploy.dir}/sql" executable="${spike.bin.dir}/psql">
<arg line="-f reports-pgsql.sql -d template1 -U '${spike.postgresql.adminuser}'"/>
</exec>
</target>

<target name="spike:test"
description="phpPgAdmin simpletests">
<!--The simpletest testcases are executed here-->
<echo>--------------------------------------------------------------</echo>
<echo>Starting phpPgAdmin SimpleTest Tests</echo>
<echo>--------------------------------------------------------------</echo>

<exec dir="${basedir}/testcase" executable="${spike.bin.dir}/php"
failonerror="false">
<!-- The name of the testcase/testsuite(if the testcases are grouped) should be mentioned as the first
argument . For eg testNewsletterApp.php is the sample test case that is to be executed.
The second and third arguments would be PHP_SIMPLETEST_HOME and the PHP_SIMPLETEST_REPORT_PATH (which is a must).
-->
<arg line="testphpPgAdminMain.php PHP_SIMPLETEST_HOME='${spike.simpletest.home}' PHP_SIMPLETEST_REPORT_PATH='${spike.report.dir}/index.html'"/>
</exec>

</target>

<target name="spike:post-test-configure">
<!-- command for shutting down the dependent components can be given here-->
<exec executable="maven" dir="${spike.parent.dir}">
<arg line="-b -E"/>
<arg value="spike:shutdown-httpd"/>
<arg value="spike:shutdown-postgresql"/>
</exec>
<delete dir="${deploy.dir}"/>
</target>

<target name="spike:test-report">
<echo>"Do nothing"</echo>
</target>

<!--
Goals required for code coverage
-->
<target name="spike:coverage-compile">
<echo>Do nothing</echo>
</target>

<target name="spike:coverage-install">
<mkdir dir="${deploy.dir}"/>
<chmod dir="${deploy.dir}" type="dir" perm="777" />
<chmod dir="${basedir}/data" type="dir" perm="777" />
<chmod dir="${basedir}/data/TableSpace" type="dir" perm="777" />
<copy todir="${deploy.dir}" preservelastmodified="true">
<fileset dir="${basedir}/phpPgAdmin" includes="**/*.*"
excludes=""/>
</copy>
<chmod type="file" perm="777">
<fileset dir="${deploy.dir}">
<include name="**/*.*"/>
</fileset>
</chmod>

<replace file="${deploy.dir}/conf/config.inc.php" token="spike_bin_dir" value="${spike.bin.dir}"/>
<!-- instrument the source code -->
<exec dir="${deploy.dir}" executable="${spike.bin.dir}/php"
failonerror="true">
<arg line="${spike.phpcoverage.home}/cli/instrument.php"/>
<arg line="-b . -p ${spike.phpcoverage.home} ."/>
</exec>
</target>

<target name="spike:pre-test-coverage-configure">
<!--command for bringing up any dependent components can be written here-->
<exec executable="maven" dir="${spike.parent.dir}">
<arg line="-b -E"/>
<arg value="spike:startup-httpd"/>
<arg value="spike:startup-postgresql"/>
</exec>
</target>

<target name="spike:test-coverage"
description="phpPgAdmin Coverage using PHPCoverage">
<!--The command for running simpletest testcases can be given here-->
<echo>--------------------------------------------------------------</echo>
<echo>Starting Coverage</echo>
<echo>--------------------------------------------------------------</echo>

<exec dir="${basedir}/testcase" executable="${spike.bin.dir}/php">
<arg line="coveragephpPgAdminMain.php PHPCOVERAGE_REPORT_DIR='${spike.report.dir}'"/>
<arg line="PHPCOVERAGE_APPBASE_PATH='${deploy.dir}'"/>
<arg line="PHP_SIMPLETEST_HOME='${spike.simpletest.home}'"/>
</exec>

</target>

<target name="spike:post-test-coverage-configure">
<!-- command for shutting down the dependent components can be given here-->
<exec executable="maven" dir="${spike.parent.dir}">
<arg line="-b -E"/>
<arg value="spike:shutdown-httpd"/>
<arg value="spike:shutdown-postgresql"/>
</exec>
<delete dir="${deploy.dir}"/>
</target>

<target name="spike:coverage-report">
<echo> "Do nothing"</echo>
</target>

</project>
Binary file added tests/data/CFunction/euc_jp_and_sjis.so
Binary file not shown.
1 change: 1 addition & 0 deletions tests/data/TableSpace/.cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions tests/data/select.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select Id from student;
2 changes: 2 additions & 0 deletions tests/data/student.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"id","name","birthday","resume"
"2","testname","2005-05-31","test resume."
2 changes: 2 additions & 0 deletions tests/data/student.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"id" "name" "birthday" "resume"
"2" "testname" "2005-05-31" "test resume."
17 changes: 17 additions & 0 deletions tests/data/student.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<data>
<header>
<column name="id" type="int4" />
<column name="name" type="varchar" />
<column name="birthday" type="date" />
<column name="resume" type="text" />
</header>
<records>
<row>
<column name="id">2</column>
<column name="name">testname</column>
<column name="birthday">2005-05-31</column>
<column name="resume">test resume.</column>
</row>
</records>
</data>
28 changes: 28 additions & 0 deletions tests/testcase/Common/CommonGroupTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Function area: Common manipulation
*
* @author Augmentum SpikeSource Team
* @copyright 2005 by Augmentum, Inc.
*/

// Import the test cases.
require_once('SecurityTest.php');
require_once('ExportTest.php');
require_once('ImportTest.php');

/**
* This class is to test the whole common manipulation function area.
* It includes security/export/import manipulation.
*/
class CommonGroupTest extends GroupTest
{
function CommonGroupTest()
{
$this->GroupTest('Common manipulation group test.');
$this->addTestClass(new SecurityTest());
$this->addTestClass(new ExportTest());
$this->addTestClass(new ImportTest());
}
}
?>
Loading

0 comments on commit ef11894

Please sign in to comment.