Changeset 22

User picture

Author: gaffu

(2011/11/01 12:20) 7 months ago

Fix supplied via Bromine forum:

Re: RedHat(Bromine) -> WinXP(SeleniumServer) Issue

Postby mastert14 ยป Mon Oct 31, 2011 11:09 pm
I figured out the solution to my problem. I was missing the testruns/ directory that's supposed to be under the app/tmp/logs/ directory.

Affected files

Updated trunk/app/controllers/jobs_controller.php Download diff

2122
3
class JobsController extends AppController {
3
class JobsController extends AppController {
4
4
5
    public $helpers = array('Html', 'Form', 'Time');
5
    public $helpers = array('Html', 'Form', 'Time');
6
    public $timeout = 120; //Seconds 
6
    public $timeout = 120; //Seconds
7
    public $name = 'Jobs';
7
    public $name = 'Jobs';
8
8
9
    function beforeFilter() {
9
    function beforeFilter() {
...
...
42
        while ($nextPossible != false && $count < 100) {
42
        while ($nextPossible != false && $count < 100) {
43
            $this->updateNodes();
43
            $this->updateNodes();
44
            $this->run($nextPossible);
44
            $this->run($nextPossible);
45
            //$output .= date("m.d.y @ H:i:s") . ': Job ID:'.$nextPossible['jobs']['id'] . ' started test: \'' . $nextPossible['testcases']['name'] . '('.$nextPossible['testcases']['id'].')\' in ' . $nextPossible['browsers']['name'] . ' on ' . $nextPossible['operatingsystems']['name'] . "<br />";	
45
            //$output .= date("m.d.y @ H:i:s") . ': Job ID:'.$nextPossible['jobs']['id'] . ' started test: \'' . $nextPossible['testcases']['name'] .
'('.$nextPossible['testcases']['id'].')\' in ' . $nextPossible['browsers']['name'] . ' on ' . $nextPossible['operatingsystems']['name'] . "<br
/>";
46
            if ($nextPossible['suites']['id'] != $old_suite_id) {
46
            if ($nextPossible['suites']['id'] != $old_suite_id) {
47
                $old_suite_id = $nextPossible['suites']['id'];
47
                $old_suite_id = $nextPossible['suites']['id'];
48
                $output = "
48
                $output = "
...
...
83
        }
83
        }
84
        //Quick 'n dirty because we can't figure out why the nodes.running aint set to zero sometimes. TODO: FIX the problem, delete this.
84
        //Quick 'n dirty because we can't figure out why the nodes.running aint set to zero sometimes. TODO: FIX the problem, delete this.
85
        $nodes = $this->Node->find('all', array(
85
        $nodes = $this->Node->find('all', array(
86
                    'contain' => array(
86
            'contain' => array(
87
                        'Seleniumserver'
87
                'Seleniumserver'
88
                    )
88
            )
89
                ));
89
                ));
90
        foreach ($nodes as $node) {
90
        foreach ($nodes as $node) {
91
            if (empty($node['Seleniumserver'])) {
91
            if (empty($node['Seleniumserver'])) {
...
...
104
                $online[] = $node['Node']['id'];
104
                $online[] = $node['Node']['id'];
105
            }
105
            }
106
        }
106
        }
107
        $online = implode(',', $online);
107
        $online = implode("','", $online);
108
        $nextPossible = $this->Job->query("
108
        $nextPossible = $this->Job->query("
109
        SELECT * FROM jobs, browsers, operatingsystems, testcases, nodes, browsers_nodes, sites, suites, projects  WHERE
109
        SELECT * FROM jobs, browsers, operatingsystems, testcases, nodes, browsers_nodes, sites, suites, projects  WHERE
110
        testcases.project_id = projects.id AND
110
        testcases.project_id = projects.id AND
...
...
117
        browsers_nodes.node_id = nodes.id AND
117
        browsers_nodes.node_id = nodes.id AND
118
        jobs.suite_id = suites.id AND
118
        jobs.suite_id = suites.id AND
119
        suites.site_id = sites.id AND
119
        suites.site_id = sites.id AND
120
        nodes.id IN ($online)
120
        nodes.id IN ('$online')
121
        ORDER BY jobs.added ASC, nodes.running ASC
121
        ORDER BY jobs.added ASC, nodes.running ASC
122
        LIMIT 1;", false
122
        LIMIT 1;", false
123
        );
123
        );
...
...
136
136
137
    private function run($nextPossible) {
137
    private function run($nextPossible) {
138
        //$this->log("function run called with nextPossible: ".print_r($nextPossible, true), 'jobs');
138
        //$this->log("function run called with nextPossible: ".print_r($nextPossible, true), 'jobs');
139
        //Sets up the selenium-server in the DB, puts together the command line string 
139
        //Sets up the selenium-server in the DB, puts together the command line string
140
        //Setup the test in the DB
140
        //Setup the test in the DB
141
        $this->loadModel('Test');
141
        $this->loadModel('Test');
142
142
...
...
213
213
214
    private function execute($cmd, $test_id) {
214
    private function execute($cmd, $test_id) {
215
        //session_write_close(); //Needed for avoiding race conditions even when using ajax
215
        //session_write_close(); //Needed for avoiding race conditions even when using ajax
216
        $test_run_log_file = LOGS . "testruns" . DS . "$test_id.log";
217
216
        $this->log("Executing: $cmd", 'jobs');
218
        $this->log("Executing: $cmd", 'jobs');
217
        $this->log("Output printed to " . '"' . LOGS . "$test_id.log" . '"', 'jobs');
218
219
220
        if (!file_exists(dirname($test_run_log_file)) &&
221
                !mkdir(dirname($test_run_log_file))) {
222
            $this->log("Directory for job logs doesn't exist and an attempt to create it failed: " . dirname($test_run_log_file));
223
        }
224
225
        if (!is_writable(dirname($test_run_log_file))) {
226
            $this->log("Cannot write to jobs log directory: " . dirname($test_run_log_file));
227
        }
228
229
        $this->log("Output printed to {$test_run_log_file}.", 'jobs');
230
219
        if (substr(php_uname(), 0, 7) == "Windows") { //Windows
231
        if (substr(php_uname(), 0, 7) == "Windows") { //Windows
220
            pclose(popen("start /B " . $cmd . ' > ' . '"' . LOGS . "testruns" . DS . "$test_id.log" . '"' . " && exit", "r"));
232
            pclose(popen("start /B {$cmd} > \"{$test_run_log_file}\" && exit", "r"));
221
        } else { //Unix.
233
        } else { //Unix.
222
            exec($cmd . " > " . LOGS . "testruns" . DS . "$test_id.log &");
234
            exec("{$cmd} > {$test_run_log_file}", $output, $return_var);
223
        }
235
        }
224
    }
236
    }
225
237
...
...
250
262
251
}
263
}
252
264
253
?>
265
?>