Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 10698 Additional Anvil enhancements #2894

Merged
merged 11 commits into from
Sep 13, 2012
Merged
13 changes: 6 additions & 7 deletions anvil/driver/README → anvil/README
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ that make up a anvil test pass


HUB:
To be defined once the hub implementation is finished.
The hub is a collection of various software components that live in a hosted linux environment and
whos purpose is to serve as a bridge between driver instances and the CI server. An additional role
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whose

of the hub is to populate a mysql database that is used as the driving data source behind Anvil
reports accesible via the web. The hub serves as a TCP server that both the CI server and driver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessible

instances connect to.


DRIVER:
Expand Down Expand Up @@ -165,12 +169,7 @@ file for the harness
problems can be encountered in terms of adb and device connection. when switching back from ios
to android/mw it is suggested that adb be started (type "adb devices") and the device be unplugged
and replugged in so that the connection is "reset"
-when in remote mode, the driver expects a cloned version of the "titanium_mobile" repo to exist at
"anvil/driver/titanium_mobile". This should be setup manually when a remote driver instance is
setup (Example from anvil/driver: "git clone git@github.com:appcelerator/titanium_mobile.git") as
this is where branches will be pulled down and stored in remote mode.
-for remote mode, github access needs to be setup for access to the appcelerator "titanium_mobile"
repo


USAGE:
Driver:
Expand Down
28 changes: 5 additions & 23 deletions anvil/driver/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function init() {
};

driverGlobal.driverDir = __dirname;
driverGlobal.configSetDir = path.join(driverGlobal.driverDir, "configSet");
driverGlobal.configSetDir = path.join(driverGlobal.driverDir, "..", "..", "support", "anvil", "configSet");
driverGlobal.harnessTemplateDir = path.join(driverGlobal.driverDir, "harnessResourcesTemplate");

driverGlobal.platforms = {};
Expand Down Expand Up @@ -217,16 +217,11 @@ function loadConfigModule() {
process.exit(1);
}

driverUtils.checkConfigItem("androidSdkDir", config.androidSdkDir, "string");
driverUtils.checkConfigItem("tiSdkDirs", config.tiSdkDirs, "string");
driverUtils.checkConfigItem("maxLogs", config.maxLogs, "number");
driverUtils.checkConfigItem("androidSocketPort", config.androidSocketPort, "number");
driverUtils.checkConfigItem("iosSocketPort", config.iosSocketPort, "number");
driverUtils.checkConfigItem("maxSocketConnectAttempts", config.maxSocketConnectAttempts, "number");
driverUtils.checkConfigItem("httpPort", config.httpPort, "number");
driverUtils.checkConfigItem("defaultTestTimeout", config.defaultTestTimeout, "number");
driverUtils.checkConfigItem("tabString", config.tabString, "string");
driverUtils.checkConfigItem("defaultIosSimVersion", config.defaultIosSimVersion, "string");

// load the defaultPlatform config property and set the global platform property if needed
new function() {
Expand Down Expand Up @@ -286,23 +281,10 @@ function loadConfigModule() {
}

function setupTempDirs() {
function createDir(dir) {
if (path.existsSync(dir)) {
return;
}

try {
fs.mkdirSync(dir, 0777);

} catch(e) {
console.log("exception <" + e + "> occurred when creating " + dir);
}
}

createDir(driverGlobal.config.tempDir);
createDir(driverGlobal.harnessDir);
createDir(driverGlobal.logsDir);
createDir(path.join(driverGlobal.logsDir, driverGlobal.platform.name));
driverUtils.createDir(driverGlobal.config.tempDir);
driverUtils.createDir(driverGlobal.harnessDir);
driverUtils.createDir(driverGlobal.logsDir);
driverUtils.createDir(path.join(driverGlobal.logsDir, driverGlobal.platform.name));
}

init();
Expand Down
13 changes: 13 additions & 0 deletions anvil/driver/driverUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ module.exports = new function() {
}
};

this.createDir = function(dir) {
if (path.existsSync(dir)) {
return;
}

try {
fs.mkdirSync(dir, 0777);

} catch(e) {
console.log("exception <" + e + "> occurred when creating " + dir);
}
};

/*
these are stand alone from the driver wide log levels since the arguments to runCommand do
not change based on the --log-level argument
Expand Down
146 changes: 97 additions & 49 deletions anvil/driver/exampleConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var path = require("path");

module.exports = new function() {

// local values
Expand All @@ -8,53 +10,44 @@ module.exports = new function() {
taste by adding or removing values if desired)

Examples:
var baseDir = "/Users/ocyrus/dev";
var tiDir = baseDir + "/appcelerator/git/titanium_mobile";
var baseDir = path.join(path.sep, "Users", "ocyrus", "dev");
var tiDir = path.join(baseDir, "appcelerator", "git", "titanium_mobile");
*/


// required values
// required values for all driver configurations
/*******************************************************************************/

// Example: this.androidSdkDir = baseDir + "/installed/android-sdk-mac_x86"
this.androidSdkDir = ""; // location of the android SDK;
/*
location of titanium SDKs. This directory should be the containing directory of various
versions of the titanium SDK. For example, the contents of an example directory location
might contain the following: "1.8.2 1.8.3 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0"

// Example: this.tiSdkDirs = "/Users/ocyrus/Library/Application Support/Titanium/mobilesdk/osx";
this.tiSdkDirs = ""; // location of titanium SDKs;
Example: this.tiSdkDirs = path.join(path.sep, "Users", "ocyrus", "Library",
"Application Support", "Titanium", "mobilesdk", "osx");
*/
this.tiSdkDirs = "";

/*
this can be changed but shouldn't need to be. This is the location where the harness instances
and log output is stored under

Example: this.tempDir = path.join(__dirname, "tmp");
*/
this.tempDir = "/tmp/driver";
this.tempDir = path.join(path.sep, "tmp", "driver");

this.maxLogs = 20; // change this to control how many log files are kept per platform
// change this to control how many log files are kept per platform
this.maxLogs = 20;

/*
change this in the case you normally want a different logging level (can be "quiet",
"normal" or "verbose")
*/
this.defaultLogLevel = "normal";

/*
ports that socket based test runs will use for communication between driver and harness.
Android and iOS use different ports in order to get around some behavior in ADB

WARNING: Make sure that the port you assign to iOS is not used in any tests!!! Otherwise there will be
reporting problems, test failures, and possibly other issues, since the simulator and the driver
are sharing a network interface.

To assist with this, ports in the range 40500-40600 should be considered reserved for harness testing.
*/
this.androidSocketPort = 40404;
this.iosSocketPort = 40405;

// max number of connection attempts (driver to harness) for socket based test runs
this.maxSocketConnectAttempts = 20;

// port that the driver will listen on for http based test runs
this.httpPort = 8125;

/*
if no timeout value is set in a suite file for a specific test, this value will be used as
a timeout value for the test
Expand All @@ -64,55 +57,110 @@ module.exports = new function() {
// string representing a tab (currently only used for printing results)
this.tabString = " ";

/*
default sim version to use when running ios test pass if a specific sim version is not
specified with the --sim-version argument to the start command
*/
this.defaultIosSimVersion = "5.0";

// required for socket based configurations
/*******************************************************************************/

// optional values
// max number of connection attempts (driver to harness) for socket based test runs
this.maxSocketConnectAttempts = 20;


// required values for android driver configurations
/*******************************************************************************/

/*
list of directories that contain additonal test configs that should be included in the list of
harness configs that will be run when a test pass is started (assuming no specific config set
is specified)
location of the android SDK - only needed when running with --platform=android;

Example: this.customHarnessConfigDirs = ["/tmp/myconfigs"];
Example: this.androidSdkDir = path.join(baseDir, "installed", "android-sdk-mac_x86");
*/
this.androidSdkDir = "";

/*
default platform to be used if the --platform argument is not provided

Example: this.defaultPlatform = "android";
Port that will be used for communication between driver and harness running on Android.
Note that Android and iOS need to use a different port from other platforms in order
to get around some behavior in ADB
*/
this.androidSocketPort = 40404;


// >>>>>>>> when running in remote mode, all the following values must be set!!! <<<<<<<<
// required values for iOS driver configurations
/*******************************************************************************/

/*
host that the hub lives on
Port that will be used for communication between driver and harness running on iOS.
Note that Android and iOS need to use a different port from other platforms in order
to get around some behavior in ADB

Example: this.hubHost = "";
WARNING: Make sure that the port you assign is not used in any tests!!! Otherwise there will be
reporting problems, test failures, and possibly other issues, since the simulator and the driver
are sharing a network interface.

To assist with this, ports in the range 40500-40600 should be considered reserved for harness testing.
*/
this.iosSocketPort = 40405;

/*
hub listens for driver connections on this port

Example: this.hubPort = ;
default sim version to use when running ios test pass if a specific sim version is not
specified with the --sim-version argument to the start command
*/
this.defaultIosSimVersion = "5.0";


// required values for mobile web driver configurations
/*******************************************************************************/

// port that the driver will listen on for http based test runs
this.httpPort = 8125;


// required values for driver configurations running in remote mode
/*******************************************************************************/

// host that the hub lives on
this.hubHost = "anvil.appcelerator.com";

// hub listens for driver connections on this port
this.hubPort = 97;

// id that this driver instance will be identified as in reporting from the hub
this.driverId = "exampleDriver";

// description of the driver that will be used for reporting via the hub
this.driverDescription = "this is an example driver instance";

/*
id that this driver instance will be identified as in reporting from the hub
this object is passed to the hub upon registration and used by the hub to filter which driver
instances should be used to test certain SDK versions.

Example: this.driverId = "";
An example of this is when you have an older iOS SDK that is not compatible with an older
version of XCode. In that scenario we will have multiple drivers for iOS with varied
environments (older versions of XCode and some newer) and this provides a means for the hub to
only have the older driver environment run the tests for that specific SDK version.

The supported properties on the object will evolve over time as needed. The list of supported
properties will be listed in the readme for the hub
*/
this.driverEnvironment = {
// always specify a platform
platform = "android",

// if running for iOS, specify the version of Xcode
xcodeVersion = "4.2.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax is incorrect. Should use ":" instead of "=".

};


// optional values
/*******************************************************************************/

// default platform to be used if the --platform argument is not provided
this.defaultPlatform = "android";

/*
description of the driver that will be used for
list of directories that contain additonal test configs that should be included in the list of
harness configs that will be run when a test pass is started (assuming no specific config set
is specified)

Example: this.driverDescription = "";
Example: this.customHarnessConfigDirs = [path.join(path.sep, "tmp", "myconfigs")];
*/

}

4 changes: 4 additions & 0 deletions anvil/driver/platforms/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module.exports = new function() {
this.name = "android";

this.init = function(commandCallback, testPassCallback) {
// check android specific config items
driverUtils.checkConfigItem("androidSdkDir", driverGlobal.config.androidSdkDir, "string");
driverUtils.checkConfigItem("androidSocketPort", driverGlobal.config.androidSocketPort, "number");

commandFinishedCallback = commandCallback;
testPassFinishedCallback = testPassCallback;
};
Expand Down
4 changes: 4 additions & 0 deletions anvil/driver/platforms/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ module.exports = new function() {
this.name = "ios";

this.init = function(commandCallback, testPassCallback) {
// check ios specific config items
driverUtils.checkConfigItem("iosSocketPort", driverGlobal.config.iosSocketPort, "number");
driverUtils.checkConfigItem("defaultIosSimVersion", driverGlobal.config.defaultIosSimVersion, "string");

commandFinishedCallback = commandCallback;

testPassFinishedCallback = function(results) {
Expand Down
3 changes: 3 additions & 0 deletions anvil/driver/platforms/mobileweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ module.exports = new function() {
this.name = "mobileweb";

this.init = function(commandCallback, testPassCallback) {
// check mobile web specific config items
driverUtils.checkConfigItem("httpPort", driverGlobal.config.httpPort, "number");

commandFinishedCallback = commandCallback;
testPassFinishedCallback = testPassCallback;
};
Expand Down