Skip to content

Commit

Permalink
Release 2.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
predix-adoption-bot committed Feb 13, 2019
1 parent 68f1710 commit 5ebb883
Show file tree
Hide file tree
Showing 92 changed files with 3,111 additions and 9,781 deletions.
1 change: 0 additions & 1 deletion COPYRIGHT.md

This file was deleted.

77 changes: 77 additions & 0 deletions LAUNCHTEST_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Table of Contents

- Introduction
- Launching Test
- Launching Smoke Tests for Production and external github branches

## Introduction
All the existing tests have been categorized into Sanity Tests via annotation @Category(SanityTest.class).
Further there are more categories for new tests or existing test that could be categorized further into correct bucket. Available categories are as follows
- SmokeTest - @Category(SmokeTest.class)
- IntegrationTest - @Category(IntegrationTest.class)
- RegressionTest - @Category(RegressionTest.class)
- DefectTest - @Category(DefectTest.class)

Once could either categorize a single test via these annoations by adding the annoation on the test or can categorize all the tests within a class by annotating at class level. e.g. AllSmokeTests.java . A single test can also be part of different category's by defining the categoery it belongs to e.g. @Category({SmokeTest.class,SanityTest.class})


## Launching Tests
To run tests you need to associate a profile. e.g. "mvn test -P $PROFILENAME". This profilename is lets you pick which category of tests you want to launch. The profiles are below
- -P Smoke tied to SmokeTest
- -P Sanity tied to SanityTest
- -P Integration tied to IntegrationTest
- -P Regression tied to RegressionTest
- -P Defect tied to DefectTest

However there is a default profile that is tied to that, which is SmokeTest. This will be picked up when you launch "mvn clean install".
If you want to run a different category of Tests you can launch via mvn $TARGET -P Sanity ($TARGET could be clean,compile,test,install)

You can also launch multiple profile tests together. e.g. mvn test -P Smoke,Sanity

To Run all Tests "mvn test -P Sanity"

## Launching Smoke Tests for Production and external github branches
To simply launching tests on these environments and be able to leverage same tests across different environment targets without making use of exporting environment variables we have provision this via use of properties file. The properties file takes only few variables that should be enough to launch the tests against different environments.
There are two properites file aiding to help you launch the tests against different environments from a single point without having to edit the same property file while flipping between target enviornments.

1.) event-hub.properties tied to env variable environemnt=production .

2.) event-hub-test.properties file tied to env variable environment=test .

If the env variable is not set; it will default to environement=test and read the corresponding file to gather the key value pairs.

Contents of the properties file, but not limited to the following. You are free to add more property values and add a test that consumes that.
- EVENTHUB_URI= - Mandatory, however Either this needs to be present or EVENT_HOST needs to be present
- EVENTHUB_HOST= - Same as above
- AUTH_URL= - Mandatory
- CLIENT_ID= - Mandatory
- CLIENT_SECRET= - Mandatory
- ZONE_ID= - Mandatory
- EVENTHUB_PORT= - Mandatory
- NUMBER_OF_MESSAGES= - If not specified, defaults to 1.

### e.g of Launching Smoke Tests to make use of event-hub.properties

1.) Step 1 : export environment=production

2.) Step 2 : mvn test -P Smoke

You should see the following log messages

2018-12-13 17:48:29 INFO AllSmokeTest:71 - Environment used for testing : PRODUCTION

2018-12-13 17:48:29 INFO PropertiesConfiguration:84 - Looking for file event-hub.properties at path


### e.g. Launching Smoke Tess to make use of event-hub-test.properties

1.) Step 1 (Optional): export environment=test

2.) Step 2 : mvn test -P Smoke

You should see the following log messages

2018-12-14 10:19:58 INFO AllSmokeTest:71 - Environment used for testing : TEST

2018-12-14 10:19:58 INFO PropertiesConfiguration:84 - Looking for file event-hub-test.properties at path .

67 changes: 36 additions & 31 deletions LICENSE.md

Large diffs are not rendered by default.

45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<a href="http://predixdev.github.io/predix-event-hub-sdk/javadocs/index.html" target="_blank" >
<img height="50px" width="100px" src="images/javadoc.png" alt="view javadoc"></a>
&nbsp;
<a href="http://predixdev.github.io/predix-event-hub-sdk" target="_blank">
<img height="50px" width="100px" src="images/pages.jpg" alt="view github pages">
</a>

# Event Hub SDK for Java
Event Hub SDK is a library that helps connect an application to [Event Hub](https://www.predix.io/services/service.html?id=1987)

Expand All @@ -20,6 +13,7 @@ Event Hub SDK is a library that helps connect an application to [Event Hub](http
- [Debugging](#debugging)
- [Building SDK from repository](#building-sdk-from-repository)
- [Common Issues](#building-sdk-from-repository)
- [Running Tests](#running-tests)

## SDK from Artifactory
The most simple way to use this SDK is to pull from the Predix Snapshot artifactory repository. Add the following to your pom file:
Expand All @@ -30,7 +24,7 @@ The most simple way to use this SDK is to pull from the Predix Snapshot artifact
<dependency>
<groupId>com.ge.predix.eventhub</groupId>
<artifactId>predix-event-hub-sdk</artifactId>
<version>2.0.7</version>
<version>2.2.4</version>
</dependency>
...
</dependencies>
Expand Down Expand Up @@ -502,13 +496,31 @@ You can resubscribe to rebuild the stream.

#### Multiple Subscribers

Only one subscription per `subscriberName` can be made.

Event Hub will send each unique `subscriberName` or subscription all stored messages. If there are multiple clients
per `subscriberName` (max of five) those clients will collectively receive all the messages. That is, the stored
messages will be divided and load balanced among the clients for that `subscriberName`. Note that this can be used to
increase the speed at which messages are retrieved from EventHub for a subscription.

#### Multiple Topics

Event Hub allows users to subscribe to multiple topics. This allows a single subscription to consume all messages published
across default and custom topics associated with their respective zone ID.

```java
//Provide the names of the topic.
String topicSuffix1 = "NewTopic1";
String topicSuffix2 = "NewTopic2";

List<String> topicSuffixes = new ArrayList<String>();
topicSuffixes.add(topicSuffix1);
topicSuffixes.add(topicSuffix2);

EventHubConfiguration configuration_all_topics_subscribe = new EventHubConfiguration.Builder()
.fromEnvironmentVariables()
.subscribeConfiguration(new SubscribeConfiguration.Builder()
.topics(topicSuffixes) //Note the topics(List) vs topic(String)
```

## Logging
The Event hub sdk offers the ability to configure logging though a
configuration object. The skd can either use the default Simple Logging Facade
Expand Down Expand Up @@ -614,7 +626,7 @@ where `string` is all the scopes comma separated. The following are the scopes t
| predix-event-hub.zones.`<zoneID>`.grpc.publish | Required to publish to default topic
| predix-event-hub.zones.`<zoneID>`.grpc.subscribe | Required to subscribe to default topic
| predix-event-hub.zones.`<zoneID>`.`<subTopic>`.grpc.subscribe | Required to subscribe to a subtopic topic
| predix-event-hub.zones.`<zoneID>`.`<subTopic>`.grpc.publish | Required to publish to a subtiouc topic
| predix-event-hub.zones.`<zoneID>`.`<subTopic>`.grpc.publish | Required to publish to a subtopic topic

Note: if you are a user of the Power VPC then you need to replace the scope prefix, predix-event-hub, with event-hub-power

Expand Down Expand Up @@ -672,10 +684,11 @@ The following dependency needs to be added *first* of the dependencies
in the pom.xml of the project using the Java SDK.

```xml

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.5.Final</version>
<version>2.0.7.Final</version>
</dependency>

<repositories>
Expand All @@ -686,7 +699,7 @@ in the pom.xml of the project using the Java SDK.
</repositories>
```
### Best Practices
See [this](https://github.com/PredixDev/predix-event-hub-java-sdk/tree/develop/examples) for sample apps, examples, and step-by-step guides on best practices.
See [this](https://github.com/PredixDev/event-hub-java-sample-app) for sample apps, examples, and step-by-step guides on best practices.
### FAQ
1. What is latest stable version of EventHub SDK?
- v1.2.11 can be used in production now. v2.X.X is also available, but is being reviewed for public release (you can still use it if you're not planning to be in production)
Expand Down Expand Up @@ -780,5 +793,9 @@ See [this](https://github.com/PredixDev/predix-event-hub-java-sdk/tree/develop/e
| | 11. Error or unable finding instance
| EventHubClientException.PublishFailureException | 1. Publish failed

## Running Tests
Please refer [Here](./LAUNCHTEST_README.md)

[![Analytics](https://predix-beacon.appspot.com/UA-82773213-1/event-hub-java-sdk/readme?pixel)](https://github.com/PredixDev)


[![Analytics](https://ga-beacon.appspot.com/UA-82773213-1/predix-event-hub-sdk/readme?pixel)](https://github.com/PredixDev)
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

12 changes: 6 additions & 6 deletions examples/event-hub-java-spark-sample-app/MANIFEST.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
applications:
- name: event-hub-java-sample-spark-app
memory: 512M
memory: 1GB
instances: 1
timeout: 180
path: target/event-hub-java-spark-sample-app-1.0-SNAPSHOT.jar
buildpack: java-buildpack
env:
UAA_INSTANCE_NAME: <uaa>
EVENTHUB_INSTANCE_NAME: <event_hub>
CLIENT_ID: <client_id>
CLIENT_SECRET: <client_password>
UAA_INSTANCE_NAME: <UAA Instance Name>
EVENTHUB_INSTANCE_NAME: <Event Hub Instance Name>
CLIENT_ID: <Client ID>
CLIENT_SECRET: <Client Secret>
EVENTHUB_ENABLE_DEBUG: true

JAVA_OPTS: -Dspark.driver.memory=471859200
6 changes: 2 additions & 4 deletions examples/event-hub-java-spark-sample-app/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# event-hub-java-spark-sample-app

## Background:
Built on top of EventHub Java Sample App (https://github.com/PredixDev//predix-event-hub-java-sdk/examples) but this app adds a simple Spark job.
Built on top of EventHub Java Sample App (https://github.com/PredixDev/event-hub-java-sample-app) but this app adds a simple Spark job.

## Summary:
Writes all received messages in the Subscriber Callback to a file.

A GET request to "/spark" will trigger a simple Spark job that counts how many times unique words appear in the written file of received messages.

The results of the Spark job are then written to "output/part-00000".


[![Analytics](https://ga-beacon.appspot.com/UA-82773213-1/predix-event-hub-sdk/readme?pixel)](https://github.com/PredixDev)
[![Analytics](https://predix-beacon.appspot.com/UA-82773213-1/event-hub-java-sdk/readme?pixel)](https://github.com/PredixDev)
20 changes: 3 additions & 17 deletions examples/event-hub-java-spark-sample-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

<groupId>event-hub-java-spark-sample-app</groupId>
<artifactId>event-hub-java-spark-sample-app</artifactId>
<version>1.0.0</version>
<version>1.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<version>2.0.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -60,10 +60,6 @@
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.6.5</jackson.version>
</properties>

<dependencies>
<dependency>
Expand All @@ -88,30 +84,20 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;

Expand All @@ -50,8 +47,13 @@ public void makeClient() throws Exception {
writer = new BufferedWriter(new FileWriter("messages.txt", true));
conf = new SparkConf().setMaster("local").setAppName("Work Count App");
sc = new JavaSparkContext(conf);
System.out.println("******************************* Using environment variables *******************************");
fromExplicit();
if(System.getenv("EVENTHUB_INSTANCE_NAME") != null && System.getenv("UAA_INSTANCE_NAME") != null) {
System.out.println("******************************* Using bound services *******************************");
fromEnv();
} else {
System.out.println("******************************* Using environment variables *******************************");
fromExplicit();
}

class SubCallback implements Client.SubscribeCallback {
@Override
Expand Down Expand Up @@ -83,10 +85,45 @@ void spark() {
JavaRDD<String> lines = sc.textFile("messages.txt");
JavaPairRDD<String, Integer> pairs = lines.mapToPair(s -> new Tuple2<>(s,1));
JavaPairRDD<String, Integer> counts = pairs.reduceByKey((a, b) -> a + b);
counts.foreach(data -> {
System.out.println("result" + data);
});
counts.saveAsTextFile("output");
sc.close();
}

/**
* Initialize the EventHubConfiguration Object
* As if it were in cloud foundry (Uses V_cap services)
* @throws EventHubClientException Exception occurred during creation
*/
private void fromEnv() throws EventHubClientException {
try {
EventHubConfiguration configuration = new EventHubConfiguration.Builder()
.fromEnvironmentVariables()
.publishConfiguration(new PublishConfiguration.Builder().publisherType(PublishConfiguration.PublisherType.SYNC).build())
.subscribeConfiguration(new SubscribeConfiguration.Builder().subscriberName(subscriberName).subscriberInstance(subscriberInstance).build())
.build();

eventHub = new Client(configuration);
logger.info("** logging Client details **");
logger.info(configuration.getAuthURL());
logger.info(configuration.getClientID());
logger.info(configuration.getClientSecret());
logger.info(configuration.getHost());
logger.info(configuration.getZoneID());
logger.info(configuration.getPort() + "");
logger.info(configuration.isAutomaticTokenRenew() + "");
logger.info("** logging Client details **");
eventHub.forceRenewToken();
eventHubConfiguration = configuration;

} catch (EventHubClientException.InvalidConfigurationException e){
logger.info(e.getMessage());
System.out.println("Could not create client");
}
}


private void fromExplicit() throws EventHubClientException {
try {
Expand Down
3 changes: 1 addition & 2 deletions examples/quick-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,5 @@ class QuickStart{
}
}

```
[![Analytics](https://predix-beacon.appspot.com/UA-82773213-1/event-hub-java-sdk/readme?pixel)](https://github.com/PredixDev)

[![Analytics](https://ga-beacon.appspot.com/UA-82773213-1/predix-event-hub-sdk/readme?pixel)](https://github.com/PredixDev)
2 changes: 1 addition & 1 deletion examples/quick-start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dependency>
<groupId>com.ge.predix.eventhub</groupId>
<artifactId>predix-event-hub-sdk</artifactId>
<version>2.0.1</version>
<version>2.0.0</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-rest/MANIFEST.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ applications:
memory: 512M
instances: 1
timeout: 180
path: target/spring-rest-1.0.0.jar
path: target/spring-rest-1.1-SNAPSHOT.jar
buildpack: java-buildpack
env:
UAA_INSTANCE_NAME: <Bound UAA Instance Name>
Expand Down
Loading

0 comments on commit 5ebb883

Please sign in to comment.