You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by tr...@apache.org on 2005/04/12 13:37:27 UTC
svn commit: r161043 - in maven/continuum/trunk/continuum-core-it: ./
add-apache-ds.py add-continuum.py add-jakarta-commons.py add-maven-wagon.py
add-plexus.py cli.py continuum.py continuum_cli.py it.py
Author: trygvis
Date: Tue Apr 12 04:37:25 2005
New Revision: 161043
URL: http://svn.apache.org/viewcvs?view=rev&rev=161043
Log:
o Adding the forgotten ITs.
o Changed the temp directory that the IT uses from 'test-ci' to 'target'.
Added:
maven/continuum/trunk/continuum-core-it/ (with props)
maven/continuum/trunk/continuum-core-it/add-apache-ds.py
maven/continuum/trunk/continuum-core-it/add-continuum.py
maven/continuum/trunk/continuum-core-it/add-jakarta-commons.py
maven/continuum/trunk/continuum-core-it/add-maven-wagon.py
maven/continuum/trunk/continuum-core-it/add-plexus.py
maven/continuum/trunk/continuum-core-it/cli.py
maven/continuum/trunk/continuum-core-it/continuum.py
maven/continuum/trunk/continuum-core-it/continuum_cli.py
maven/continuum/trunk/continuum-core-it/it.py
Propchange: maven/continuum/trunk/continuum-core-it/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 12 04:37:25 2005
@@ -0,0 +1,8 @@
+target
+*~
+*.log
+.classpath
+.project
+*.ipr
+*.iws
+*.iml
Added: maven/continuum/trunk/continuum-core-it/add-apache-ds.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/add-apache-ds.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/add-apache-ds.py (added)
+++ maven/continuum/trunk/continuum-core-it/add-apache-ds.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,25 @@
+import continuum
+import sys
+
+baseurl = "scm:svn:http://svn.apache.org/repos/asf/directory"
+configuration = {}
+
+continuum.addProjectFromScm( baseurl + "/apacheds/trunk", "maven-1", "", "nobody@localhost", "1.0", configuration )
+
+sys.exit()
+
+continuum.addProjectFromScm( baseurl + "/apacheds/trunk/core", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/apacheds/trunk/main", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/apacheds/trunk/plugin", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/apacheds/trunk/shared", "maven-1", "", "nobody@localhost", "1.0", configuration )
+
+continuum.addProjectFromScm( baseurl + "/asn1/trunk/ber", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/asn1/trunk/codec", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/asn1/trunk/der", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/asn1/trunk/stub-compiler", "maven-1", "", "nobody@localhost", "1.0", configuration )
+
+continuum.addProjectFromScm( baseurl + "/authx/trunk/core", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/authx/trunk/example", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/authx/trunk/jdbc", "maven-1", "", "nobody@localhost", "1.0", configuration )
+continuum.addProjectFromScm( baseurl + "/authx/trunk/script", "maven-1", "", "nobody@localhost", "1.0", configuration )
+
Added: maven/continuum/trunk/continuum-core-it/add-continuum.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/add-continuum.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/add-continuum.py (added)
+++ maven/continuum/trunk/continuum-core-it/add-continuum.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,10 @@
+import continuum
+import sys
+
+baseurl = "http://cvs.continuum.codehaus.org/*checkout*/continuum-apache/"
+
+continuumId = continuum.addProjectFromUrl( baseurl + "pom.xml", "maven2" )
+continuumModelId = continuum.addProjectFromUrl( baseurl + "continuum-model/pom.xml", "maven2" )
+continuumCoreId = continuum.addProjectFromUrl( baseurl + "continuum-core/pom.xml", "maven2" )
+continuumXmlRpcId = continuum.addProjectFromUrl( baseurl + "continuum-xmlrpc/pom.xml", "maven2" )
+continuumWebId = continuum.addProjectFromUrl( baseurl + "continuum-web/pom.xml", "maven2" )
Added: maven/continuum/trunk/continuum-core-it/add-jakarta-commons.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/add-jakarta-commons.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/add-jakarta-commons.py (added)
+++ maven/continuum/trunk/continuum-core-it/add-jakarta-commons.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,11 @@
+import continuum
+import sys
+
+baseurl = "scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper"
+configuration = { "executable" : "ant", "targets" : "all" }
+
+langId = continuum.addProjectFromScm( baseurl + "/lang/trunk", "ant", "Jakarta Commons Lang", "nobody@localhost", "1.0", configuration )
+loggingId = continuum.addProjectFromScm( baseurl + "/logging/trunk", "ant", "Jakarta Commons Logging", "nobody@localhost", "1.0", configuration )
+
+continuum.buildProject( langId )
+continuum.buildProject( loggingId )
Added: maven/continuum/trunk/continuum-core-it/add-maven-wagon.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/add-maven-wagon.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/add-maven-wagon.py (added)
+++ maven/continuum/trunk/continuum-core-it/add-maven-wagon.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,23 @@
+import continuum
+import sys
+
+baseurl = "http://cvs.apache.org/viewcvs.cgi/*checkout*/maven-scm"
+baseurl = "file:/home/trygvis/tmp/continuum/co/maven-scm"
+
+#scmId = continuum.addProjectFromUrl( baseurl + "/pom.xml", "maven2" )
+#continuum.buildProject( scmId )
+#sys.exit( -1 )
+
+scmId = continuum.addProjectFromUrl( baseurl + "/pom.xml", "maven2" )
+scmApiId = continuum.addProjectFromUrl( baseurl + "/maven-scm-api/pom.xml", "maven2" )
+scmTestId = continuum.addProjectFromUrl( baseurl + "/maven-scm-test/pom.xml", "maven2" )
+scmProvidersId = continuum.addProjectFromUrl( baseurl + "/maven-scm-providers/pom.xml", "maven2" )
+scmLocalId = continuum.addProjectFromUrl( baseurl + "/maven-scm-providers/maven-scm-provider-local/pom.xml", "maven2" )
+scmCvsId = continuum.addProjectFromUrl( baseurl + "/maven-scm-providers/maven-scm-provider-cvs/pom.xml", "maven2" )
+
+continuum.buildProject( scmId )
+continuum.buildProject( scmApiId )
+continuum.buildProject( scmTestId )
+continuum.buildProject( scmProvidersId )
+continuum.buildProject( scmLocalId )
+continuum.buildProject( scmCvsId )
Added: maven/continuum/trunk/continuum-core-it/add-plexus.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/add-plexus.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/add-plexus.py (added)
+++ maven/continuum/trunk/continuum-core-it/add-plexus.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,38 @@
+import continuum
+import sys
+
+baseurl = "http://cvs.plexus.codehaus.org/*checkout*/plexus/"
+
+plexusComponentsId = continuum.addProjectFromUrl( baseurl + "plexus-components/pom.xml", "maven2" );
+plexusActionId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-action/pom.xml", "maven2" );
+plexusArchiverId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-archiver/pom.xml", "maven2" );
+plexusBayesianId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-bayesian/pom.xml", "maven2" );
+plexusCommandId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-command/pom.xml", "maven2" );
+plexusCompilerId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/pom.xml", "maven2" );
+plexusCompilerApiId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compiler-api/pom.xml", "maven2" );
+plexusCompilersId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compilers/pom.xml", "maven2" );
+plexusCompilerAspectjId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml", "maven2" );
+plexusCompilerEclipseId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml", "maven2" );
+plexusCompilerJavacId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml", "maven2" );
+plexusCompilerKikesId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml", "maven2" );
+plexusDroolsId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-drools/pom.xml", "maven2" );
+plexusFormicaId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-formica-web/pom.xml", "maven2" );
+plexusFormicaId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-formica/pom.xml", "maven2" );
+plexusHibernateId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-hibernate/pom.xml", "maven2" );
+plexusI18nId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-i18n/pom.xml", "maven2" );
+plexusJettyId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-jetty-httpd/pom.xml", "maven2" );
+plexusJettyId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-jetty/pom.xml", "maven2" );
+plexusMimetyperId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-mimetyper/pom.xml", "maven2" );
+plexusSummitId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-summit/pom.xml", "maven2" );
+plexusVelocityId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-velocity/pom.xml", "maven2" );
+plexusWerkflowId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-werkflow/pom.xml", "maven2" );
+plexusXmlrpcId = continuum.addProjectFromUrl( baseurl + "plexus-components/plexus-xmlrpc/pom.xml", "maven2" );
+plexusContainersId = continuum.addProjectFromUrl( baseurl + "plexus-containers/pom.xml", "maven2" );
+plexusContainerArtifactId = continuum.addProjectFromUrl( baseurl + "plexus-containers/plexus-container-artifact/pom.xml", "maven2" );
+plexusContainerDefaultId = continuum.addProjectFromUrl( baseurl + "plexus-containers/plexus-container-default/pom.xml", "maven2" );
+plexusUtilsId = continuum.addProjectFromUrl( baseurl + "plexus-utils/pom.xml", "maven2" );
+plexusServletId = continuum.addProjectFromUrl( baseurl + "plexus-servlet/pom.xml", "maven2" );
+plexusToolsId = continuum.addProjectFromUrl( baseurl + "plexus-tools/pom.xml", "maven2" );
+plexusCdcId = continuum.addProjectFromUrl( baseurl + "plexus-tools/plexus-cdc/pom.xml", "maven2" );
+plexusRuntimeBuilderId = continuum.addProjectFromUrl( baseurl + "plexus-tools/plexus-runtime-builder/pom.xml", "maven2" );
+
Added: maven/continuum/trunk/continuum-core-it/cli.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/cli.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/cli.py (added)
+++ maven/continuum/trunk/continuum-core-it/cli.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,112 @@
+import os
+import sys
+import string
+
+class cli:
+ prompt = '# '
+
+ def __init__(self):
+ try:
+ import readline
+ readline.set_completer(self.complete)
+ readline.parse_and_bind("tab: complete")
+ except:
+ pass
+
+ def cmdloop(self):
+ stop = None
+ while not stop:
+ try:
+ line = raw_input(self.prompt)
+ except EOFError:
+ print
+ break
+
+ line = self.precmd(line)
+ stop = self.onecmd(line)
+ stop = self.postcmd(stop, line)
+
+ self.postloop()
+
+ def postloop(self):
+ pass
+
+ def precmd(self, line):
+ return line
+
+ def postcmd(self, stop, line):
+ return stop
+
+ def onecmd(self, line):
+ line = string.strip(line)
+ if not line:
+ return None
+ tokens = string.split(line)
+
+ help = 0
+ if tokens[0] == 'help' or tokens[0] == 'man':
+ help = 1
+ del(tokens[0])
+
+ func = None
+ for i in range(len(tokens), 0, -1):
+ try:
+ func = getattr(self, 'do_' + string.join(tokens[:i], '_'))
+ args = tokens[i:]
+ except AttributeError:
+ func = None
+ else:
+ break
+
+ if help:
+ self.do_help(func)
+ elif func:
+ return func(args)
+ else:
+ print "%s: no such command" % (tokens[0])
+ return None
+
+ def do_help(self, func):
+ """Welcome to the help system"""
+ if func:
+ if func.__doc__:
+ print func.__doc__
+ else:
+ print "No help available"
+ else:
+ sortedkeys = self.__class__.__dict__.keys()
+ sortedkeys.sort()
+ for i in sortedkeys:
+ if i[0:3] == 'do_':
+ print " %-20s %s" % \
+ ( string.replace(i[3:], '_', ' '),
+ string.split(self.__class__.__dict__[i].__doc__, "\n")[0])
+
+ return None
+
+ def complete(self, text, state):
+ #import readline
+ #print
+ #print "DEBUG bidx =", readline.get_begidx()
+ #print "DEBUG eidx =", readline.get_endidx()
+ #print "DEBUG line =", readline.get_line_buffer()
+ #print "DEBUG text =", text
+ if state == 0:
+ self.matches = self.global_matches(text)
+ try:
+ return self.matches[state]
+ except IndexError:
+ return None
+
+ def global_matches(self, text):
+ matches = []
+ n = len(text)
+
+ for word in self.__class__.__dict__.keys():
+ if word[0:3] == 'do_':
+ word = string.join(string.split(word, '_')[1:], ' ')
+ if word[:n] == text:
+ matches.append(word)
+
+ return matches
+
Added: maven/continuum/trunk/continuum-core-it/continuum.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/continuum.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum.py (added)
+++ maven/continuum/trunk/continuum-core-it/continuum.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,191 @@
+import cli
+import os
+import socket
+import sys
+from time import strftime, gmtime
+import xmlrpclib
+
+STATE_NEW = "new"
+STATE_OK = "ok"
+STATE_FAILED = "failed"
+STATE_ERROR = "error"
+STATE_BUILD_SIGNALED = "build signaled"
+STATE_BUILDING = "building"
+
+server = xmlrpclib.Server("http://localhost:8000")
+
+try:
+ server.continuum.getAllProjects()
+except socket.error, msg:
+ print "Error while connecting to the XML-RPC server"
+ print msg
+ sys.exit( -1 )
+
+def checkResult( map ):
+ if ( map[ "result" ] == "ok" ):
+ return map
+
+ print "Error while executing method."
+ print "Method: " + map[ "method" ]
+ print "Message: " + map[ "message" ]
+ print "Stack trace: " + map[ "stackTrace" ]
+
+ raise Exception( "Error while executing method" )
+
+def decodeState( state ):
+ if ( state == 1 ):
+ return STATE_NEW
+ elif ( state == 2 ):
+ return STATE_OK
+ elif ( state == 3 ):
+ return STATE_FAILED
+ elif ( state == 4 ):
+ return STATE_ERROR
+ elif ( state == 5 ):
+ return STATE_BUILD_SIGNALED
+ elif ( state == 6 ):
+ return STATE_BUILDING
+ else:
+ return "UNKNOWN STATE (" + state + ")."
+
+def addProjectFromUrl( url, builderId ):
+ result = checkResult( server.continuum.addProjectFromUrl( url, builderId ) )
+
+ return result[ "projectId" ]
+
+def addProjectFromScm( scmUrl, builderId, name, nagEmailAddress, version, configuration ):
+ result = checkResult( server.continuum.addProjectFromScm( scmUrl, builderId, name, nagEmailAddress, version, configuration ) )
+
+ return result[ "projectId" ]
+
+def getProject( projectId ):
+ result = checkResult( server.continuum.getProject( projectId ) )
+
+ return Project( result[ "project" ] )
+
+def updateProjectFromScm( projectId ):
+ checkResult( server.continuum.updateProjectFromScm( projectId ) )
+
+def updateProjectConfiguration( projectId, configuration ):
+ checkResult( server.continuum.updateProjectConfiguration( projectId, configuration ) )
+
+def getAllProjects():
+ result = checkResult( server.continuum.getAllProjects() )
+
+ return result[ "projects" ]
+
+def buildProject( projectId ):
+ result = checkResult( server.continuum.buildProject( projectId ) )
+
+ return result[ "buildId" ]
+
+def getBuildsForProject( projectId, start, end ):
+ result = checkResult( server.continuum.getBuildsForProject( projectId, start, end ) )
+
+ builds = []
+ for build in result[ "builds" ]:
+ builds.append( Build( build ) )
+
+ return builds;
+
+def getBuild( buildId ):
+ result = checkResult( server.continuum.getBuild( buildId ) )
+
+ return Build( result[ "build" ] )
+
+def getBuildResult( buildId ):
+ result = checkResult( server.continuum.getBuildResult( buildId ) )
+
+ buildResult = result[ "buildResult" ]
+
+ if ( len( buildResult ) == 0 ):
+ return None
+
+ return BuildResult( buildResult )
+
+class Project:
+ def __init__( self, map ):
+ self.map = map
+ self.id = map[ "id" ]
+ self.name = map[ "name" ]
+ self.nagEmailAddress = map[ "nagEmailAddress" ]
+ self.state = decodeState( int( map[ "state" ] ) )
+ self.version = map[ "version" ]
+ self.builderId = map[ "builderId" ]
+ self.configuration = map[ "configuration" ]
+
+ def __str__( self ):
+ str = "id: " + self.id + os.linesep +\
+ "name: " + self.name + os.linesep +\
+ "nagEmailAddress: " + self.nagEmailAddress + os.linesep +\
+ "state: " + self.state + os.linesep +\
+ "version: " + self.version + os.linesep +\
+ "builder id: " + self.builderId + os.linesep
+
+ if ( len( self.configuration.keys() ) > 0 ):
+ conf = ""
+ for key in self.configuration.keys():
+ conf += os.linesep + key + "=" + self.configuration[ key ]
+ str += conf
+
+ return str
+
+class Build:
+ def __init__( self, map ):
+ map[ "totalTime" ] = int( map[ "endTime" ] )/ 1000 - int( map[ "startTime" ] ) / 1000
+ map[ "startTime" ] = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime( int( map[ "startTime" ] ) / 1000 ) )
+ map[ "endTime" ] = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime( int( map[ "endTime" ] ) / 1000 ) )
+ map[ "state" ] = decodeState( int( map[ "state" ] ) )
+
+ self.id = map[ "id" ]
+ self.state = map[ "state" ]
+ self.startTime = map[ "startTime" ]
+ self.endTime = map[ "endTime" ]
+ self.totalTime = map[ "totalTime" ]
+ self.error = map.get( "error" )
+ self.map = map
+
+ if ( self.error == None ):
+ self.error = ""
+ map[ "error" ] = ""
+
+ def __str__( self ):
+ map = self.map
+
+ value = """Id: %(id)s
+State: %(state)s
+Start time: %(startTime)s
+End time: %(endTime)s
+Build time: %(totalTime)ss""" % map
+ if ( self.error != "" ):
+ value += "Error: %(error)s" % map
+
+ return value
+
+class BuildResult:
+ def __init__( self, map ):
+ # This is the common stuff between all ContinuumBuildResult objects
+ self.success = map[ "success" ] == "true"
+ self.buildExecuted = map[ "buildExecuted" ] == "true"
+ self.changedFiles = map[ "changedFiles" ]
+
+ # These fields just happen to be the same for all the build results
+ if ( self.buildExecuted ):
+ self.exitCode = int( map[ "exitCode" ] )
+ self.standardOutput = map[ "standardOutput" ]
+ self.standardError = map[ "standardError" ]
+
+ def __str__( self ):
+ value = "Success: " + str( self.success ) + os.linesep +\
+ "Build executed: " + str( self.buildExecuted )
+
+ if ( self.buildExecuted ):
+ value += os.linesep + "Exit code: " + str( self.exitCode )
+
+ if ( len( self.standardOutput ) > 0 ):
+ value += os.linesep + "Standard output: " + self.standardOutput
+
+ if ( len( self.standardError ) > 0 ):
+ value += os.linesep + "Standard error: " + self.standardError
+
+ return value
Added: maven/continuum/trunk/continuum-core-it/continuum_cli.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/continuum_cli.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum_cli.py (added)
+++ maven/continuum/trunk/continuum-core-it/continuum_cli.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+
+import cli
+import continuum
+
+##########################################################
+# Build your commands in this class. Each method that
+# starts with "do_" is exposed as a shell command, and
+# its doc string is used when the user types 'help' or
+# 'man'. A command that does not return None, will
+# cause the shell to terminate.
+#
+# The first line of the docstring is used when help is
+# typed by itself to give a summary, and then if the
+# user requests specific help on a command, the full
+# text is supplied.
+#
+# If your system has the GNU readline stuff on it, then
+# pressing tab will do tab completion of the commands.
+# You will also get much nicer command line editing
+# just like using your shell, as well as command
+# history.
+##########################################################
+
+class ContinuumXmlRpcClient(cli.cli):
+ def __init__(self):
+ cli.cli.__init__(self)
+
+ def do_quit(self, args):
+ """Exit the command interpreter.
+ Use this command to quit the demo shell."""
+
+ return 1
+
+ def do_version(self, args):
+ """Display the version of the shell.
+ Prints the version of this software on the command line."""
+
+ print "Version 1.0"
+
+ def do_addProject(self, args):
+ """Add a Continuum project.
+ Use this command to add a project to Continuum."""
+
+ projectId = continuum.addProjectFromUrl( args[0], args[1] )
+
+ print "Added project, id: " + projectId
+
+ def do_showProject(self, args):
+ """Shows Continuum project.
+ Use this command to show the details of a Continuum project."""
+
+ project = continuum.getProject( args[0] )
+
+ print "Project details:"
+ print """Id: %(id)s
+Name: %(name)s
+Version: %(version)s
+Working directory: %(workingDirectory)s
+Builder type: %(builderId)s""" % project.map
+ print ""
+
+ print "Project Configuration:"
+ for key in project.configuration.keys():
+ print key + "=" + project.configuration[ key ]
+
+ print ""
+ print "Project Builds:"
+ print "| Id | State | Start time | End time | Build time |"
+ builds = continuum.getBuildsForProject( project.id, 0, 0 )
+ for build in builds:
+ build.state = continuum.decodeState( build.state )
+ print "| %(id)4s | %(state)6s | %(startTime)s | %(endTime)s | %(totalTime)10s |" % build.map
+
+ def do_showProjects(self, args):
+ """Shows all Continuum projects registeret.
+ Use this command to list all Continuum projects."""
+
+ projects = continuum.getAllProjects()
+
+ for project in projects:
+ print "Id %(id)s, name: '%(name)s'" % project
+
+ def do_buildProject(self, args):
+ """Build a Continuum project.
+ Use this command to signal a build for a Continuum project."""
+
+ buildId = continuum.buildProject( args[ 0 ] )
+
+ print "Enqueued project, build id: " + buildId
+
+ def do_showBuild( self, args ):
+ """Shows the result of a build."""
+
+ build = continuum.getBuild( args[ 0 ] );
+
+ print build
+
+ buildResult = continuum.getBuildResult( args[ 0 ] );
+
+ print buildResult
+
+ def do_run(self, args):
+ """Run a script of commands.
+ Use this command to run a script of commands."""
+
+ commands = open( args[0], "r" ).readlines()
+
+ for command in commands:
+ cli.cli.onecmd( self, command )
+
+##########################################################
+# Main loop
+##########################################################
+
+try:
+ ContinuumXmlRpcClient().cmdloop()
+
+except Exception, e:
+ print "Error:", e
+
Added: maven/continuum/trunk/continuum-core-it/it.py
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/it.py?view=auto&rev=161043
==============================================================================
--- maven/continuum/trunk/continuum-core-it/it.py (added)
+++ maven/continuum/trunk/continuum-core-it/it.py Tue Apr 12 04:37:25 2005
@@ -0,0 +1,428 @@
+import continuum
+import os
+import shutil
+import sys
+import time
+import traceback
+
+def progress( message ):
+ print "* " + message
+
+def fail( message ):
+ print "FAILURE: " + message
+ sys.exit( -1 )
+
+def assertEquals( message, expected, actual ):
+ if ( expected == None and actual != None ):
+ print "Expected None but the actual value was: '" + str( actual ) + "'."
+ sys.exit( -1 )
+
+ if ( expected != None and actual == None ):
+ assert 0, "Expected '" + str( expected ) + "' but the actual value None."
+ sys.exit( -1 )
+
+ if( expected == actual ):
+ return
+
+ print
+ print "##############################################"
+ print "ASSERTION FAILURE!"
+ print "##############################################"
+ print "Message: " + message
+ print "Expected: " + str( expected )
+ print "Actual: " + str( actual )
+ print "##############################################"
+ print "Traceback"
+ print "##############################################"
+ traceback.print_stack()
+ print "##############################################"
+ print
+
+ sys.exit( -1 )
+
+def assertTrue( message, condition ):
+ assertEquals( message, True, condition )
+
+def assertFalse( message, condition ):
+ assertEquals( message, False, condition )
+
+def assertNotNull( message, condition ):
+ if( condition != None ):
+ return
+
+ print message
+
+ sys.exit( -1 )
+
+def assertProject( projectId, name, nagEmailAddress, state, version, builderId, project ):
+ assertNotNull( "project.id", projectId )
+ assertEquals( "project.name", name, project.name )
+ assertEquals( "project.nagEmailAddress", nagEmailAddress, project.nagEmailAddress )
+ assertEquals( "project.state", state, project.state )
+ assertEquals( "project.version", version, project.version )
+ assertEquals( "project.builderId", builderId, project.builderId )
+
+def assertSuccessfulNoBuildPerformed( buildId ):
+ build = waitForBuild( buildId )
+ assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+ buildResult = continuum.getBuildResult( buildId )
+ assertNotNull( "Build result was null.", buildResult )
+ assertTrue( "The build wasn't successful", buildResult.success )
+ assertFalse( "The build was executed", buildResult.buildExecuted )
+
+def assertSuccessfulMaven1Build( buildId ):
+ build = waitForBuild( buildId )
+ assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+ buildResult = continuum.getBuildResult( buildId )
+ assertNotNull( "Build result was null.", buildResult )
+ assertTrue( "The build wasn't successful", buildResult.success )
+ assertTrue( "The build wasn't executed", buildResult.buildExecuted )
+ assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+ assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
+
+def assertSuccessfulMaven2Build( buildId ):
+ build = waitForBuild( buildId )
+ assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+ buildResult = continuum.getBuildResult( buildId )
+ assertNotNull( "Build result was null.", buildResult )
+ assertTrue( "The build wasn't successful", buildResult.success )
+ assertTrue( "The build wasn't executed", buildResult.buildExecuted )
+ assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+ assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
+
+def assertSuccessfulAntBuild( buildId ):
+ build = waitForBuild( buildId )
+ assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+ buildResult = continuum.getBuildResult( buildId )
+ assertNotNull( "Build result was null.", buildResult )
+ assertTrue( "The build wasn't successful", buildResult.success )
+ assertTrue( "The build wasn't executed", buildResult.buildExecuted )
+ assertTrue( "Standard output didn't contain the 'BUILD SUCCESSFUL' message.", buildResult.standardOutput.find( "BUILD SUCCESSFUL" ) != -1 )
+ assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
+
+def assertSuccessfulShellBuild( buildId, expectedStandardOutput ):
+ build = waitForBuild( buildId )
+ assertEquals( "The build wasn't successful.", continuum.STATE_OK, build.state )
+ buildResult = continuum.getBuildResult( buildId )
+ assertNotNull( "Build result was null.", buildResult )
+ assertTrue( "The build wasn't successful", buildResult.success )
+ assertTrue( "The build wasn't executed", buildResult.buildExecuted )
+ assertEquals( "Standard output didn't contain the expected output.", expectedStandardOutput, buildResult.standardOutput )
+ assertEquals( "Standard error wasn't empty.", 0, len( buildResult.standardError ) )
+
+def execute( workingDirectory, command ):
+ cwd = os.getcwd()
+ os.chdir( workingDirectory )
+# print "workingDirectory: " + workingDirectory
+# print "command: " + command
+ file = os.popen( command )
+ os.chdir( cwd )
+
+ output = file.read()
+
+ ret = file.close()
+
+ if ( ret != None ):
+ print output
+ print "ret: " + str( ret )
+ fail( "The command didn't return 0." )
+
+ return output
+
+def waitForBuild( buildId ):
+ timeout = 60
+ sleepInterval = 0.1
+
+ build = continuum.getBuild( buildId )
+
+ while( build.state == continuum.STATE_BUILD_SIGNALED or build.state == continuum.STATE_BUILDING ):
+ build = continuum.getBuild( buildId )
+ time.sleep( sleepInterval )
+ timeout -= sleepInterval
+
+ if ( timeout <= 0 ):
+ fail( "Timeout while waiting for build (id=%(id)s) to complete" % { "id" : buildId } )
+
+ return build
+
+def cleanDirectory( dir ):
+ if ( os.path.isdir( dir ) ):
+ shutil.rmtree( dir )
+
+def cvsCommit( basedir ):
+ return execute( basedir, "cvs commit -m ''" );
+
+def cvsCheckout( cvsroot, module, coDir ):
+ return execute( basedir, "cvs -d " + cvsroot + " checkout -d " + coDir + " " + module );
+
+def cvsImport( basedir, cvsroot, artifactId ):
+ return execute( basedir, "cvs -d " + cvsroot + " import -m '' " + artifactId + " continuum_test start" )
+
+def svnImport( basedir, svnroot, artifactId ):
+ return execute( basedir, "svn import -m '' . file://" + svnroot + "/" + artifactId )
+
+def makeScmUrl( scm, scmroot, artifactId ):
+ if ( scm == "cvs" ):
+ return "scm:cvs:local:%(scmroot)s:%(module)s" % { "scmroot" : scmroot , "module" : artifactId }
+ elif ( scm == "svn" ):
+ return "scm:svn:file:%(scmroot)s/%(artifactId)s" % { "scmroot" : scmroot , "module" : artifactId }
+
+ raise Exception( "Unknown SCM type '" + scm + "'" )
+
+def initMaven1Project( basedir, scm, scmroot, artifactId ):
+ cleanDirectory( basedir )
+ os.makedirs( basedir )
+ pom = file( basedir + "/project.xml", "w+" )
+ pom.write( """
+<project>
+ <pomVersion>3</pomVersion>
+ <groupId>continuum</groupId>
+ <artifactId>%(artifactId)s</artifactId>
+ <currentVersion>1.0</currentVersion>
+ <name>Maven 1 Project</name>
+ <repository>
+ <connection>%(scmUrl)s</connection>
+ </repository>
+ <build>
+ <nagEmailAddress>%(email)s</nagEmailAddress>
+ </build>
+</project>
+""" % {
+ "artifactId" : artifactId,
+ "scm" : scm,
+ "scmUrl" : makeScmUrl( scm, scmroot, artifactId ),
+ "email" : email
+ } )
+ pom.close()
+
+ os.makedirs( basedir + "/src/main/java" )
+ foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+ foo.write( "class Foo { }" )
+ foo.close()
+
+ cvsImport( basedir, cvsroot, artifactId )
+
+def initMaven2Project( basedir, cvsroot, artifactId ):
+ cleanDirectory( basedir )
+ os.makedirs( basedir )
+ pom = file( basedir + "/pom.xml", "w+" )
+ pom.write( """
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>continuum</groupId>
+ <artifactId>%(artifactId)s</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <name>Maven 2 Project</name>
+ <ciManagement>
+ <notifiers>
+ <notifier>
+ <type>mail</type>
+ <address>%(email)s</address>
+ </notifier>
+ </notifiers>
+ </ciManagement>
+ <scm>
+ <connection>scm:cvs:local:%(cvsroot)s:%(artifactId)s</connection>
+ </scm>
+</project>
+""" % { "artifactId" : artifactId, "cvsroot" : cvsroot, "email" : email } )
+ pom.close()
+
+ os.makedirs( basedir + "/src/main/java" )
+ foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+ foo.write( "class Foo { }" )
+ foo.close()
+
+ cvsImport( basedir, cvsroot, artifactId )
+
+def initAntProject( basedir ):
+ cleanDirectory( basedir )
+ os.makedirs( basedir )
+ buildXml = file( basedir + "/build.xml", "w+" )
+ buildXml.write( """
+<project>
+ <target name="build">
+ <property name="classes" value="target/classes"/>
+ <mkdir dir="${classes}"/>
+ <javac srcdir="src/main/java" destdir="${classes}"/>
+ </target>
+ <target name="clean">
+ <delete dir="${classes}"/>
+ </target>
+</project>""" )
+ buildXml.close()
+
+ os.makedirs( basedir + "/src/main/java" )
+ foo = file( basedir + "/src/main/java/Foo.java", "w+" )
+ foo.write( "class Foo { }" )
+ foo.close()
+
+def initShellProject( basedir ):
+ cleanDirectory( basedir )
+ os.makedirs( basedir )
+ script = file( basedir + "/script.sh", "w+" )
+ script.write( """#!/bin/sh
+for arg in "$@"
+do
+ echo $arg
+ done
+""" )
+ script.close()
+ os.system( "chmod +x " + basedir + "/script.sh" )
+
+############################################################
+# Start
+############################################################
+
+# This is the email that will be used as the nag email address
+email = "trygvis@codehaus.org"
+
+basedir = os.getcwd() + "/target"
+cvsroot = basedir + "/cvsroot"
+svnroot = basedir + "/svnroot"
+maven1Project = basedir + "/maven-1"
+maven2Project = basedir + "/maven-2"
+antProject = basedir + "/ant"
+shellProject = basedir + "/shell"
+coDir = basedir + "/tmp-co"
+
+cleanDirectory( basedir )
+os.makedirs( basedir )
+os.makedirs( cvsroot )
+os.makedirs( svnroot )
+
+execute( os.getcwd(), "cvs -d " + cvsroot + " init" )
+execute( os.getcwd(), "svnadmin create " + svnroot )
+
+startTime = int( time.time() )
+
+if 1:
+ progress( "Initializing Maven 1 CVS project" )
+ initMaven1Project( maven1Project, "cvs", cvsroot, "maven-1" )
+ progress( "Adding Maven 1 project" )
+ maven1Id = continuum.addProjectFromUrl( "file:" + maven1Project + "/project.xml", "maven-1" )
+ maven1 = continuum.getProject( maven1Id )
+ assertProject( maven1Id, "Maven 1 Project", email, continuum.STATE_NEW, "1.0", "maven-1", maven1 )
+
+ progress( "Building Maven 1 project" )
+ buildId = continuum.buildProject( maven1.id )
+ assertSuccessfulMaven1Build( buildId )
+
+ progress( "Testing that the POM is updated before each build." )
+ cleanDirectory( coDir )
+ cvsCheckout( cvsroot, "maven-1", coDir )
+ pom = file( coDir + "/project.xml", "r" )
+ value = pom.read()
+ pom.close()
+
+ value = value.replace( "Maven 1 Project", "Maven 1 Project - Changed" )
+ value = value.replace( "1.0", "1.1" )
+
+ pom = file( coDir + "/project.xml", "w+" )
+ pom.write( value )
+ pom.close()
+
+ cvsCommit( coDir )
+
+ continuum.updateProjectFromScm( maven1.id )
+ maven1 = continuum.getProject( maven1.id )
+ assertEquals( "The project name wasn't changed.", "Maven 1 Project - Changed", maven1.name )
+ assertEquals( "The project version wasn't changed.", "1.1", maven1.version )
+
+if 1:
+ progress( "Initializing Maven 2 CVS project" )
+ initMaven2Project( maven2Project, cvsroot, "maven-2" )
+ progress( "Adding Maven 2 project" )
+ maven2Id = continuum.addProjectFromUrl( "file:" + maven2Project + "/pom.xml", "maven2" )
+ maven2 = continuum.getProject( maven2Id )
+ assertProject( maven2Id, "Maven 2 Project", email, continuum.STATE_NEW, "2.0-SNAPSHOT", "maven2", maven2 )
+
+ progress( "Building Maven 2 project" )
+ build = continuum.buildProject( maven2.id )
+ assertSuccessfulMaven2Build( build )
+
+ progress( "Test that a build without any files changed won't execute the builder" )
+ build = continuum.buildProject( maven2.id )
+ assertSuccessfulNoBuildPerformed( build )
+
+if 1:
+ progress( "Initializing Ant SVN project" )
+ initAntProject( antProject )
+ svnImport( antProject, svnroot, "ant-svn" )
+
+ progress( "Adding Ant SVN project" )
+ antSvnId = continuum.addProjectFromScm( "scm:svn:file://" + svnroot + "/ant-svn", "ant", "Ant SVN Project", email, "3.0",
+ {
+ "executable": "ant",
+ "targets" : "clean, build"
+ } )
+ antSvn = continuum.getProject( antSvnId )
+ assertProject( antSvnId, "Ant SVN Project", email, continuum.STATE_NEW, "3.0", "ant", antSvn )
+ progress( "Building SVN Ant project" )
+ build = continuum.buildProject( antSvn.id )
+ assertSuccessfulAntBuild( build )
+
+if 1:
+ progress( "Initializing Ant CVS project" )
+ initAntProject( antProject )
+ cvsImport( antProject, cvsroot, "ant-cvs" )
+ antCvsId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:ant-cvs", "ant", "Ant CVS Project", email, "3.0",
+ { "executable": "ant", "targets" : "clean, build"} )
+ antCvs = continuum.getProject( antCvsId )
+ assertProject( antCvsId, "Ant CVS Project", email, continuum.STATE_NEW, "3.0", "ant", antCvs )
+ progress( "Building CVS Ant project" )
+ build = continuum.buildProject( antCvs.id )
+ assertSuccessfulAntBuild( build )
+
+if 1:
+ progress( "Initializing Shell CVS project" )
+ initShellProject( shellProject )
+ cvsImport( shellProject, cvsroot, "shell" )
+
+ progress( "Adding CVS Shell project" )
+ shellId = continuum.addProjectFromScm( "scm:cvs:local:" + basedir + "/cvsroot:shell", "shell", "Shell Project", email, "3.0",
+ { "executable": "script.sh", "arguments" : ""} )
+
+ shell = continuum.getProject( shellId )
+ assertProject( shellId, "Shell Project", email, continuum.STATE_NEW, "3.0", "shell", shell )
+
+ progress( "Building Shell project" )
+ build = continuum.buildProject( shell.id )
+ assertSuccessfulShellBuild( build, "" )
+
+ # Test project reconfiguration
+ # Test that a project will be built after a changed file is committed
+ progress( "Building Shell project with alternative configuration" )
+
+ cleanDirectory( coDir )
+ cvsCheckout( cvsroot, "shell", coDir )
+ script = file( coDir + "/script.sh", "r" )
+ value = script.read() + "# Extra line" + os.linesep
+ script.close()
+
+ script = file( coDir + "/script.sh", "w+" )
+ script.write( value )
+ script.close()
+
+ output = cvsCommit( coDir )
+
+ configuration = shell.configuration
+ configuration[ "arguments" ] = "a b";
+ continuum.updateProjectConfiguration( shell.id, configuration );
+ shell = continuum.getProject( shell.id )
+ build = continuum.buildProject( shell.id )
+ assertSuccessfulShellBuild( build, """a
+b
+""" )
+
+# TODO: Add project failure tests
+
+endTime = int( time.time() )
+
+print ""
+print "##############################################"
+print "ALL TESTS PASSED"
+print "##############################################"
+print "Time elapsed: " + str( endTime - startTime ) + "s."
+print "##############################################"
+print ""
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org