apama.project

Contains PySys extensions for projects: creating, manipulating and deploying.

ProjectHelper

class apama.project.ProjectHelper(testcase, name, projectRoot=None, deployedPath=None)[source]

Bases: object

Helper class for creating, manipulating and deploying Apama projects, compatible with Software AG Designer.

You can have multiple projects in one test by overriding the parameters:

myProject=self.apama.projectHelper("my-project")

myProject=self.apama.projectHelper("my-project", projectRoot='my-root-path')

myProject=self.apama.projectHelper("my-project", deployedPath='my-deployed-path')

This class provides the ability to create, add and delete bundles, deploy and manipulate projects:

myProject = self.apama.projectHelper("my-project")
myProject.create()
myProject.addBundle("onAppInitialized")
myProject.addBundle("...")

#copy monitor files into project 
...

myProject.deploy()

# start the deployed application
myCorrelator = self.apama.startCorrelator('myCorrelator', config=myProject.deployedDir())

Additionally, you can use this command to use an existing project created with Software AG Designer or apama_project:

myProject = self.apama.projectHelper("my-project-from-template")
myProject.create(existingProject='path-to/my-project-template')

#further set-up as above
...

myProject.deploy()

# start the deployed application
myCorrelator = self.apama.startCorrelator('myCorrelator', config=myProject.deployedDir())
Parameters
  • testcase (BaseTest) – The ProjectHelper should be initialized with an instance of a test, normally the one in which the helper is created.

  • name (str) – the project name.

  • projectRoot (str) – the directory that contains/will contain the project

  • deployedPath (str) – the directory containing the deployed project, if this exists you must deploy with overwrite=True.

create(existingProject=None, **kwargs)[source]

Creates the base project in the output directory by default or projectRoot if set in the constructor:

myProject = ProjectHelper(self, name="my-project-from-template")

#create new
myProject.create()

#use existing, copies project into correct location name changed to the project name
myProject.create(existingProject='path-to/my-project-template')
Parameters
addBundle(nameList, instanceName=None, **kwargs)[source]

Adds a list of bundles or a bundle with instance name to the project:

myProject = ProjectHelper(self, name="my-project")

...

myProject.addBundle(['onAppInitialized'])
myProject.addBundle(['File Adapter', 'Any Extractor', 'Cumulocity IoT > Cumulocity Client'])

myProject.addBundle(['HTTP Server'], instanceName='myHttpServerInstance')

It is most efficient to add all bundles (except those with an instance name) in a single call to addBundle.

Note that this command does not set any of the configuration. This must be done by the user in the test environment in the same way as a Designer or apama_project user needs to do this.

Parameters
  • nameList (list[str]) – The name of the bundle(s) to add to the project, as a string or a list of strings. apama_project list bundles can be used to get the current usable list.

  • instanceName (str) – Certain bundles can specify the instance name (optional). Bundles requiring an an instance name must be added one at a time.

  • kwargs – Optional pysys.process.user.ProcessUser.startProcess keyword arguments, e.g. timeout, ignoreExitStatus.

removeBundle(name=None, instanceName=None, **kwargs)[source]

Removes a specific bundle from the project:

myProject = ProjectHelper(self,name="my-project")

...

myProject.removeBundle('onAppInitialized')

#will remove ALL instances as well as the bundle
myProject.removeBundle(name ='HTTP Server')

#removes the instance but not the bundle unless it is the only instance
myProject.removeBundle(instanceName='myHttpServerInstance')

Only one of the parameters should be specified.

Parameters
  • name – If this is specified, all instances of that bundle will be removed.

  • instanceName – If this is specified, the specific instance will be removed.

  • kwargs – Optional pysys.process.user.ProcessUser.startProcess keyword arguments, e.g. timeout, ignoreExitStatus.

deploy(overwrite=False, dest=None, **kwargs)[source]

Deploys a runnable project.

Creates a <project name>-deployed directory in the output directory by default or projectRoot if set in the constructor. If you try to deploy to an existing directory, it will fail by default. Use overwrite=True to enable it:

myProject = ProjectHelper(self,name="my-project")

...

#create runnable application, add 120s timeout to deployment via kwargs
myProject.deploy(timeout=120)

#create runnable application, allow redeployment to the same name
myProject.deploy(overwrite=true)

#create runnable application, set/override the deployment directory
myProject.deploy(dest='path-to/my-override-dir',timeout=120)
Parameters
  • dest – Override the destination directory for the deployed project.

  • overwrite – Remove an existing deployment with the same path (default is False).

  • kwargs – Optional pysys.process.user.ProcessUser.startProcess keyword arguments, e.g. timeout, ignoreExitStatus.

deployedDir()[source]

Retrieves the deployed directory.

If the project has not been deployed then the command will return the path to <projectname>-deployed. If the deployed project was overridden at deployment then this will return that path.

projectDir()[source]

Returns the path to the project.

monitorsDir()[source]

Returns the directory path to the project monitors.

configDir()[source]

Returns the directory path of the project configuration.