Apama Extension for Visual Studio Code to develop/test Cumulocity EPL App

Hi,

I took a look at the VS Code Extension for Apama, looked at the Knowledge Article and managed to:

  1. install the extension
  2. create a github project using the template streaming-analytics-sample-repo-template
  3. started the devcontainer

My questions are:

  1. Where do I specify to Cumulocity Tenant I want to connect?
  2. After changing the epl code, what are the steps to test the changes? Restart the devcontainer?
  3. Where do I see the correlator logs in the devcontainer?

Regards Christof

Hi Christof, it’s great to hear you’ve got the container setup.

The container comes with a checkout of the EPL Apps Tools (GitHub - Cumulocity-IoT/apama-eplapps-tools: Tools for uploading and testing EPL Apps for Cumulocity Streaming Analytics (Apama)), documented at EPL Apps Tools — EPL Apps Tools documentation so the next steps for testing and deploying would be follow those instructions - while benefitting from the EPL language support that the dev container gives you

Can I use the devcontainer to connect to a Cumulocity tenant as documented here?

Hi, just to confirm, you’re building an EPL app (not a custom microservice written in EPL)?

In that case I think what you need is the steps in Using PySys to test your EPL apps — EPL Apps Tools documentation to try out your EPL apps in a testcase. To configure the tenant details, see GitHub - Cumulocity-IoT/streaming-analytics-sample-repo-template: This repo provides a template for developing Cumulocity Streaming Analytics assets such as Blocks and EPL Apps, with a dev container for opening in Visual Studio Code. If you run it “locally” the correlator output will be in the test output dir. Even if you don’t bother to write any verify logic to start with, the approach of running it from a testcase is a good way to go.

You definintely wouldn’t restart the dev container - instead just run the pysys test within the container whenever you want to try things out.

You can also deploy the app to the cloud by running the commands shown in Using the eplapp.py command line tool — EPL Apps Tools documentation, in which case use the command line args mentioned in that topic to provide the tenant details.

Hope that helps, let us know if anything isn’t quite clear yet.

@Christof_Strack once you get this to work, would be great to have a second article describing this workflow.

I successfully added a connectivity plugin through the Apama Project View in VSCode.
Now I want to configure the properties to connect to my tenant.
The template to uses a script c8y-vars to define the connection properties.

  1. Question:Can I reference the env variables in my property file config/connectivity/CumulocityRESTSupport/CumulocityIoTREST.properties?
CUMULOCITY_USERNAME=${CUMULOCITY_USERNAME}
  1. The VS Code page mentions to run correlator --config connectivity.yaml.
    I did not find the file connectivity.yaml. Do I have to create this myself and what is the content for CumulocityIoTREST? Or is this created when the connectivity bundle is added?

I’m still not quite sure why you need the connectivity plugin - are you building an EPL app, or is it EPL in a custom Apama microservice?

  1. No, for connectivity properties you’d need to put the required values into a .properties file, or on the correlator command line with -Dkey=value. Just remember don’t commit any file with a password to version control

  2. connectivity.yaml is just a placeholder, so you’d need to point at whatever connectivity yaml files are in your project, which as you guessed are created when you add a connectivity bundle to the project

I realize I didn’t explain what I actually wanted to achieve clearly.

My goal is to test an EPL app, such as the sample app “Create an alarm if the value exceeds min/max,” locally.

I’m familiar with the Apama plugin in Eclipse, where I could:

  1. Create an EPL app and add the Cumulocity Connectivity plugin
  2. Configure the required parameters for a Cumulocity tenant
  3. Run the EPL application locally

I’d like to replicate this experience as closely as possible using a devcontainer and the Apama Extension for Visual Studio Code.

I have the following resources:

  1. Apama VSCode extension
  2. streaming-analytics-sample-repo-template

I’m trying to determine how to connect these pieces to fill in the missing parts.

Is this approach feasible?

Cool, so the question is how to do “local” testing of an EPL app.

I know this is different than what you were used to with eclipse, but currently the recommended approach for that would be to use PySys, as in Using PySys to test your EPL apps — EPL Apps Tools documentation

It doesn’t mean you have to write lots of testcases and validation logic up front, but using an actual test framework for starting your application gives you a simple and repeatable way it getting it running. And then if/when you do want to formalise your experiments into actual testcases you can stick with the same approach.

It also avoids us having two different ways of doing the same thing (i.e. starting up an EPL app locally) which feels a bit wasteful, and two different ways of configuring tenant options etc.

You can use a test like apama-eplapps-tools/samples/TestLocalCorrelator at main · Cumulocity-IoT/apama-eplapps-tools · GitHub as a starting point, and provide your C8Y tenant options in apama-eplapps-tools/samples/pysysproject.xml at main · Cumulocity-IoT/apama-eplapps-tools · GitHub (except for the password - use an env var for that to avoid a security risk). If you want you can even keep the test running until you press Enter by adding a Python raw_input() function call to the test.

This is a bit of a new workflow, so if any part is unclear let us know so we can improve the instructions.