Skip to content

Commit

Permalink
Merge #132, #115 into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Apr 1, 2012
2 parents 6e4019f + 54517ee commit 2d05540
Show file tree
Hide file tree
Showing 81 changed files with 3,340 additions and 1,761 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.htaccess
.project
testswarm.ini
scripts/*.pl
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ TestSwarm only supports Apache and MySQL as servers.
4. Copy the ./config/.htaccess-sample to ./htaccess. If needed change the
RewriteBase to match the contextpath configuration.

5. Load the cronjob (changing the URL to point to your site).
`crontab << config/cronjob.txt`
5. Create an entry to your crontab for action=cleanup. This performs various
cleaning duties such as making timed-out runs available again for testing.
`* * * * * curl -s http://path/to/testswarm/index.php?action=cleanup > /dev/null`

6. Currently the server must be run in Apache (it uses a .htaccess file).

Expand All @@ -87,7 +88,7 @@ TestSwarm only supports Apache and MySQL as servers.
Get involved
---------------------

You're welcome to use the Github issue tracker to start discussions.
You're welcome to use the GitHub issue tracker to start discussions.

There is also a mailing list at Google Groups available:

Expand Down
59 changes: 59 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* This is the main front-end entry point for scripts.
* All API responses start here.
* @example ./api.php?format=json&action=info
* @example ./api.php?format=json&action=scores
* @example ./api.php?format=json&action=job&item=1
*
* @author Timo Tijhof, 2012
* @since 0.3.0
* @package TestSwarm
*/

require_once "inc/init.php";

$action = $swarmContext->getRequest()->getVal( "action", "info" );
$format = $swarmContext->getRequest()->getVal( "format", "json" );
$className = ucfirst( $action ) . "Action";
$className = class_exists( $className ) ? $className : null;

if ( !Api::isGreyFormat( $format ) ) {
session_start();
}

if ( $className ) {
try {
$actionObj = $className::newFromContext( $swarmContext );
$actionObj->doAction();
$response = array();

if ( $actionObj->getError() ) {
$response["error"] = $actionObj->getError();
}
if ( $actionObj->getData() ) {
$response[$action] = $actionObj->getData();
}
} catch ( Exception $e ) {
$response = array(
"error" => array(
"code" => "internal-error",
"info" => "An internal error occurred. Action could not be performed. Error message:\n" . $e->getMessage(),
),
);
}
} else {
$response = array(
"error" => array(
"code" => "invalid-input",
"info" => "Action `$action` does not exist",
),
);
}

$api = Api::newFromContext( $swarmContext );
$api->setFormat( $format );
$api->setResponse( $response );
$api->output();

exit;
19 changes: 9 additions & 10 deletions config/.htaccess-sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ Deny from all
RewriteEngine On
RewriteBase /

# Don't touch real files and directories (such as ./js/ and ./css/)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=51]

RewriteRule (.*[^/])$ $1/ [R=301,QSA]
# Don't touch .* files or directories (skip the following 10 lines)
RewriteRule ^.*$ - [S=10]

RewriteRule ^run/$ index.php?state=run [QSA,L]
RewriteRule ^run/(.*)/?$ index.php?state=run&user=$1 [QSA,L]
RewriteRule ^login/$ index.php?state=login [QSA,L]
RewriteRule ^logout/$ index.php?state=logout [QSA,L]
RewriteRule ^signup/$ index.php?state=signup [QSA,L]
RewriteRule ^scores/$ index.php?state=scores [QSA,L]
RewriteRule ^user/(.*)/?$ index.php?state=tinder&user=$1 [QSA,L]
RewriteRule ^job/(.*)/?$ index.php?state=jobstatus&job_id=$1 [QSA,L]
# Remove any trailing slash
RewriteRule ^(.*)/$ $1 [R=301,QSA]

# Dynamic action paths
RewriteRule ^([a-z]*)$ index.php?action=$1 [QSA]
RewriteRule ^([a-z]*)/(.*)$ index.php?action=$1&item=$2 [QSA]
1 change: 0 additions & 1 deletion config/cronjob.txt

This file was deleted.

13 changes: 13 additions & 0 deletions config/testswarm-sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
;;;;;;;;;;;;;;;;;;;;;;
; General settings ;
;;;;;;;;;;;;;;;;;;;;;;
; NOTE: Settings under section "general" are publicly retreivable
; through api.php?action=info.

;timezone=UTC
; Timezone that things should be displayed in.
Expand Down Expand Up @@ -43,6 +45,8 @@ password = "root"
; Settings for the web ;
; front-end (index.php) ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NOTE: Settings under section "web" are publicly retreivable
; through api.php?action=info.

;contextpath = "/"
; The context path is the prefix (starting at the domain name root)
Expand All @@ -57,11 +61,20 @@ password = "root"
; Will be used in the header of the site.
; Defaults to just "Test Swarm".

;ajax_update_interval = 5
; Interval in number of seconds to use on the job pages
; where the table data is updated in real-time.


[client]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Settings for browser client ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; NOTE: Settings under section "client" are publicly retreivable
; through api.php?action=info.
; NOTE: These are exported on index.php?action=run
; and the test runner client refreshes these values through
; api.php?action=getrun.

;cooldown_rate = 15
; After a run has been completed, wait this number of seconds before
Expand Down
9 changes: 4 additions & 5 deletions config/testswarm.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ CREATE TABLE `jobs` (
`id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`status` tinyint(4) NOT NULL default '0',
`updated` binary(14) NOT NULL default '19700101000000',
`created` binary(14) NOT NULL default '19700101000000',
PRIMARY KEY (`id`)
Expand Down Expand Up @@ -112,12 +111,12 @@ CREATE TABLE `useragents` (

CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL,
`updated` binary(14) NOT NULL default '19700101000000',
`created` binary(14) NOT NULL default '19700101000000',
`seed` double NOT NULL default '0',
`password` varchar(40) NOT NULL default '',
`auth` varchar(40) NOT NULL default '',
`seed` varchar(40) NOT NULL,
`password` varchar(40) NOT NULL,
`auth` varchar(40) NOT NULL,
`email` varchar(255) NOT NULL default '',
`request` mediumtext NOT NULL default '',
PRIMARY KEY (`id`),
Expand Down
73 changes: 0 additions & 73 deletions content/addjob.php

This file was deleted.

143 changes: 0 additions & 143 deletions content/home.php

This file was deleted.

Loading

0 comments on commit 2d05540

Please sign in to comment.