From: <st...@us...> - 2007-01-10 22:15:08
|
Revision: 3798 http://svn.sourceforge.net/smartfrog/?rev=3798&view=rev Author: steve_l Date: 2007-01-10 14:15:05 -0800 (Wed, 10 Jan 2007) Log Message: ----------- components to start and stop mysql, and tests. The tests arent running though; more research needed on that. Modified Paths: -------------- trunk/core/components/database/build.xml trunk/core/components/database/src/org/smartfrog/services/database/mysql/components.sf trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/components.sf trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/hsqldb/components.sf trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/components.sf Added Paths: ----------- trunk/core/components/database/src/org/smartfrog/services/database/mysql/binding.sf trunk/core/components/database/src/org/smartfrog/services/database/mysql/daemon.sf trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/ConnectionOpenTest.sf trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/MysqlTest.java trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/TableManipulationTest.sf Modified: trunk/core/components/database/build.xml =================================================================== --- trunk/core/components/database/build.xml 2007-01-10 20:59:23 UTC (rev 3797) +++ trunk/core/components/database/build.xml 2007-01-10 22:15:05 UTC (rev 3798) @@ -31,6 +31,7 @@ <property file="build.properties"/> <property name="javac.java.version" value="1.5"/> <property name="is.component" value="true"/> + <property name="system.tests.enabled" value="true"/> <property name="root.dir" location="../.."/> <property name="antbuild.dir" location="${root.dir}/antbuild"/> Added: trunk/core/components/database/src/org/smartfrog/services/database/mysql/binding.sf =================================================================== --- trunk/core/components/database/src/org/smartfrog/services/database/mysql/binding.sf (rev 0) +++ trunk/core/components/database/src/org/smartfrog/services/database/mysql/binding.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -0,0 +1,26 @@ +/** (C) Copyright 2006 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + + +/* + * components for MySQL integration + */ + +#include "/org/smartfrog/services/database/mysql/daemon.sf" Modified: trunk/core/components/database/src/org/smartfrog/services/database/mysql/components.sf =================================================================== --- trunk/core/components/database/src/org/smartfrog/services/database/mysql/components.sf 2007-01-10 20:59:23 UTC (rev 3797) +++ trunk/core/components/database/src/org/smartfrog/services/database/mysql/components.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -23,56 +23,5 @@ * components for MySQL integration */ -#include "/org/smartfrog/services/database/core/components.sf" -#include "/org/smartfrog/services/os/java/library.sf" - -/** - * We don't redist MySQL as it has interesting license - * ramifications for non-OSS applications, though (LGPL) smartfrog - * is free to redist it and retain its license - * http://mysql.com - */ - -MySqlBinding extends DatabaseBinding { - driver "com.mysql.jdbc.Driver"; -} - -/** - * Add host and database names to the binding - */ -MySqlTargetedBinding extends MysqlBinding { - host locahost; - //port - port 3306; - database ""; - binding_prefix "jdbc:mysql://"; - url (((((binding_prefix ++ host) ++ ":" ) ++ port) ++ "/")) ++ database); -} - -/** - * The administrator account - */ -MySqlAdministrator extends MysqlTargetedBinding { - username "root"; - password ""; -} - -/** - * Test for a live database - * Requires a database > 3.22, and a compatible mysql driver. - */ -IsMySqlLive extends ConnectionOpens { - sfClass "org.smartfrog.services.database.mysql.IsMysqlLive"; -} - - -/** - * This is the definition for mysql 5. To use you need to instantiate the JAR component - * with the library attribute set to a relevant library - */ -mysql5.jar extends JarArtifact { - project "mysql"; - artifact "mysql-connector-java"; - version "5.0.4"; - sha1 "ce259b62d08cce86a68a8f17f5f9c8218371b235"; -} \ No newline at end of file +#include "/org/smartfrog/services/database/mysql/daemon.sf" +#include "/org/smartfrog/services/database/mysql/binding.sf" Added: trunk/core/components/database/src/org/smartfrog/services/database/mysql/daemon.sf =================================================================== --- trunk/core/components/database/src/org/smartfrog/services/database/mysql/daemon.sf (rev 0) +++ trunk/core/components/database/src/org/smartfrog/services/database/mysql/daemon.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -0,0 +1,166 @@ +/** (C) Copyright 2006 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + + +/* + * components to manage the MySQL daemon + */ + +#include "/org/smartfrog/sfcore/workflow/combinators/finally.sf" +#include "/org/smartfrog/services/os/runshell/components.sf" + + /** + * the various names of the mysql programs. + */ + MySqlApplicationNames { + mysqladmin "mysqladmin"; + mysqldaemon "mysqld"; + mysql "mysql"; + } + + + optional extends ifThenElse { + condition false; + value ""; + if(condition); + then value; + else ""; + } + + /** + * run the mysql daemon. + */ + mysqldaemon extends ExecuteProgram { + shellCmd MySqlApplicationNames:mysqldaemon; + shellArguments arguments; + //options + ansi false; + bigtables false; + datadir TBD; + defaults "--no-defaults", + logdir TBD; + low-priority-updates false; + skip-networking false; + //build the options + + arguments [ + defaults, + IF ansi THEN "--ansi" ELSE "" FI, + IF bigtables THEN "--big-tables" ELSE "" FI, + ("--datadir=" ++ dataDir), + IF low-priority-updates THEN "--low-priority-updates" ELSE "" FI, + IF skip-networking THEN "--skip-networking" ELSE "" FI + ]; + } + +/* + create databasename Create a new database + debug Instruct server to write debug information to log + drop databasename Delete a database and all its tables + extended-status Gives an extended status message from the server + flush-hosts Flush all cached hosts + flush-logs Flush all logs + flush-status Clear status variables + flush-tables Flush all tables + flush-threads Flush the thread cache + flush-privileges Reload grant tables (same as reload) + kill id,id,... Kill mysql threads + password new-password Change old password to new-password, MySQL 4.1 hashing. + old-password new-password Change old password to new-password in old format. + ping Check if mysqld is alive + processlist Show list of active threads in server + reload Reload grant tables + refresh Flush all tables and close and open logfiles + shutdown Take server down + status Gives a short status message from the server + start-slave Start slave + stop-slave Stop slave + variables Prints variables available + version Get version info from server + +*/ + + /** + * execute a mysqladmin command. Requires that the mysql commands + * are on the classpath + */ + mysqladmin extends ExecuteProgram { + shellCmd MySqlApplicationNames:mysqladmin; + shellArguments arguments; + arguments []; + + //define all the commands of mysql admin + create "create"; + debug "debug"; + drop "drop"; + extended-status "extended-status"; + flush-hosts "flush-hosts"; + flush-logs "flush-logs"; + flush-status "flush-status"; + flush-tables "flush-tables"; + flush-threads "flush-threads"; + flush-privileges "flush-privileges"; + password "password"; + ping "ping"; + processlist "processlist"; + reload "reload"; + refresh "refresh"; + shutdown "shutdown"; + status "status"; + start-slave "start-slave"; + stop-slave "stop-slave"; + variables "variables"; + version "version"; + } + + mysqladmin-ping extends mysqladmin { + arguments [ping]; + } + + mysqladmin-reload extends mysqladmin { + arguments [reload]; + } + + mysqladmin-refresh extends mysqladmin { + arguments [refresh]; + } +/** + * Shut down a local mysql daemon by running mysqladmin -shutdown" + * This does not need binding info when it goes against the local host; + * it runs on user permissions instead + */ + mysqladmin-shutdown extends mysqladmin { + arguments [shutdown]; + } + + + mysqladmin-status extends mysqladmin { + arguments [status]; + } + + + +/** + * the shutdown operation delayed until termination time. This + * is something you can deploy early on and have it do its work when it is undeployed. + */ +FinallyTerminateMysql extends Finally { + action extends mysqladmin-shutdown; +} Modified: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/components.sf =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/components.sf 2007-01-10 20:59:23 UTC (rev 3797) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/components.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -57,4 +57,30 @@ primary key (EVENT_ID)); # ]; - } + } + + + /** + Create any user + */ + CreateUser extends AdminCommand { + username TBD; + password TBD; + sqlCommands [ + (("CREATE USER " ++ username ) ++ (" PASSWORD " ++ password)) + ]; + } + + DropUser extends AdminCommand { + username TBD; + sqlCommands [ + ("DROP USER " ++ username ) + ]; + } + + DropTable extends AdminCommand { + table TBD; + sqlCommands [ + ("DROP TABLE " ++ table) + ]; + } \ No newline at end of file Modified: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/hsqldb/components.sf =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/hsqldb/components.sf 2007-01-10 20:59:23 UTC (rev 3797) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/hsqldb/components.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -50,45 +50,5 @@ database LAZY TestUserBinding; } - /** - Create any user - */ - CreateUser extends AdminCommand { - username TBD; - password TBD; - sqlCommands [ - (("CREATE USER " ++ username ) ++ (" PASSWORD " ++ password)) - ]; - } - DropUser extends AdminCommand { - username TBD; - sqlCommands [ - ("DROP USER " ++ username ) - ]; - } - DropTable extends AdminCommand { - table TBD; - sqlCommands [ - ("DROP TABLE " ++ table) - ]; - } - - /** - * Create an events table with various attributes - * this is an implicit test of multi-line SQL. - */ - CreateEventsTable extends AdminCommand { - sqlCommands [ - ##CREATE TABLE events ( - EVENT_ID varchar(64) not null, - EVENT_NAME varchar(255) not null, - EVENT_DATE timestamp not null, - EVENT_VERSION integer, - EVENT_LASTMODIFIED timestamp, - EVENT_TEXT varchar(8192), - primary key (EVENT_ID)); - # - ]; - } \ No newline at end of file Added: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/ConnectionOpenTest.sf =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/ConnectionOpenTest.sf (rev 0) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/ConnectionOpenTest.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -0,0 +1,29 @@ + +#include "/org/smartfrog/services/database/test/system/core/mysqldb/components.sf"; + + +ConnectionOpenTest extends TestCompound { + + description "This test blocks until a connection is open, and fails if this is not possible"; + sfShouldTerminate false; + + action extends DatabaseAndBinding ; + + tests extends Sequence { + + wait extends FailingWaitFor { + condition extends ConnectionOpen { + database LAZY action:binding; + } + interval 200; + timeout 2000; + } + + } + } + +sfConfig extends ConnectionOpenTest { + + + +} \ No newline at end of file Added: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/MysqlTest.java =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/MysqlTest.java (rev 0) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/MysqlTest.java 2007-01-10 22:15:05 UTC (rev 3798) @@ -0,0 +1,32 @@ +package org.smartfrog.services.database.test.system.core.mysql; + +import org.smartfrog.test.DeployingTestBase; +import org.smartfrog.services.assertions.TestBlock; + +/** + * Mysql tests + */ +public class MysqlTest extends DeployingTestBase { + private static final String BASE = "/org/smartfrog/services/database/test/system/core/mysql/"; + + public MysqlTest(String name) { + super(name); + } + + public void testTableManipulationTest() throws Throwable { + application = deployExpectingSuccess( + BASE +"TableManipulationTest.sf", + "TableManipulationTest"); + TestBlock block = (TestBlock) application; + expectSuccessfulTermination(block); + } + + + public void testConnectionOpenTest() throws Throwable { + application = deployExpectingSuccess( + BASE +"ConnectionOpenTest.sf", + "ConnectionOpenTest"); + TestBlock block = (TestBlock) application; + expectSuccessfulTermination(block); + } +} Added: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/TableManipulationTest.sf =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/TableManipulationTest.sf (rev 0) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/TableManipulationTest.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -0,0 +1,61 @@ + +#include "/org/smartfrog/services/database/test/system/core/hsqldb/components.sf"; + + +TableManipulationTest extends TestCompound { + + description "Creates users and tables"; + sfShouldTerminate false; + + action extends action extends DatabaseAndBinding { + } + + tests extends Sequence { + + + dropUser1 extends DropUser { + database LAZY ATTRIB action:binding; + username testUser; + failOnSqlError false; + } + + //forward reference + dropTable1 extends dropTable { + failOnSqlError false; + } + + newuser extends CreateUser { + database LAZY PARENT:PARENT:action:binding; + username testUser; + password testPass; + } + + + events extends CreateEventsTable { + database LAZY ATTRIB action:binding; + } + + select extends Transaction { + database LAZY ATTRIB action:binding; + sqlCommands [ + "SELECT * from events" + ]; + } + + dropTable extends DropTable { + database LAZY ATTRIB action:binding; + table "events"; + } + + dropUser2 extends dropUser1 { + failOnSqlError true; + } + + } + } + +sfConfig extends TableManipulationTest { + + + +} \ No newline at end of file Modified: trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/components.sf =================================================================== --- trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/components.sf 2007-01-10 20:59:23 UTC (rev 3797) +++ trunk/core/components/database/test/org/smartfrog/services/database/test/system/core/mysql/components.sf 2007-01-10 22:15:05 UTC (rev 3798) @@ -30,7 +30,10 @@ testUser "testUser"; testPass "secret"; - TestDB extends MysqlTargetedBinding { + + Mysqld extends mysqldaemon; + + MysqlBinding extends MysqlTargetedBinding { database "diary"; } @@ -39,4 +42,25 @@ password testPass; } - } \ No newline at end of file + + DatabaseAndBinding extends Parallel { + + mysqld extends Mysqld; + + binding extends MysqlBinding; + + } + + + sfConfig { + + + mysqld extends Mysqld; + + -- extends mysqladmin-status; + + -- extends mysqladmin-shutdown; + + TestUserBinding; + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |