Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit 63869a7

Browse files
authored
Merge pull request #21 from jzaccone/master
three fixes and travis tests
2 parents 5a317f6 + ac1a23b commit 63869a7

File tree

6 files changed

+92
-6
lines changed

6 files changed

+92
-6
lines changed

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
##############################################################################
2+
# Copyright 2017 IBM Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
##############################################################################
15+
language: bash
16+
sudo: true
17+
18+
script:
19+
- ./travis-test.sh

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/IBM/openwhisk-data-processing-message-hub.svg?branch=master)](https://travis-ci.org/IBM/openwhisk-data-processing-message-hub)
2+
13
# Getting Started with OpenWhisk and Message Hub
24
This project provides sample code for creating your Message Hub (Kafka) data processing app with Apache OpenWhisk on IBM Bluemix. It should take no more than 10 minutes to get up and running.
35

actions/mhpost/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
22
"name": "mypost",
3-
"version": "0.1",
3+
"version": "0.1.0",
44
"description": "Action posting messages to a Message Hub topic",
55
"author": "IBM",
66
"license": "Apache-2.0",
77
"dependencies": {
8-
"message-hub-rest": "file:./node_modules/message-hub-rest"
9-
},
10-
"engines": {
11-
"node": "6.9"
8+
"message-hub-rest": "1.2.0"
129
},
1310
"main": "index.js"
1411
}

deploy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
# Load configuration variables
1919
source local.env
2020

21+
function usage() {
22+
echo -e "Usage: $0 [--install,--uninstall,--env]"
23+
}
24+
2125
function install() {
2226
echo -e "Installing OpenWhisk actions, triggers, and rules for openwhisk-data-processing-message-hub..."
2327

kafka_consume.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ decode_response() {
3131
local ARG=$1
3232
local ENCODED=${1##*,\"value\":\"}
3333
local ENCODED=${ENCODED%%\",\"partition\":*}
34-
DECODED=`echo $ENCODED | base64 -D`
34+
DECODED=`echo $ENCODED | base64 --decode`
3535
fi
3636
}
3737

travis-test.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
##############################################################################
4+
# Copyright 2017 IBM Corporation
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
##############################################################################
17+
set -e
18+
19+
OPEN_WHISK_BIN=/home/ubuntu/bin
20+
LINK=https://openwhisk.ng.bluemix.net/cli/go/download/linux/amd64/wsk
21+
22+
echo "Downloading OpenWhisk CLI from '$LINK'...\n"
23+
curl -O $LINK
24+
chmod u+x wsk
25+
export PATH=$PATH:`pwd`
26+
27+
echo "Configuring CLI from apihost and API key\n"
28+
wsk property set --apihost openwhisk.ng.bluemix.net --auth $OPEN_WHISK_KEY #OPEN_WHISK_KEY defined in travis-ci console
29+
30+
echo "Configure local.env"
31+
touch local.env #Configurations defined in travis-ci console
32+
33+
echo "installing jq for bash json parsing"
34+
sudo apt-get install jq
35+
36+
echo "Deploying wsk actions, etc."
37+
./deploy.sh --install
38+
39+
echo "Waiting for triggers/actions to finish installing (sleep 5)"
40+
sleep 5
41+
42+
echo "Publishing a kafka message"
43+
./kafka_publish.sh
44+
45+
echo "Waiting for triggers/actions to finish executing(sleep 5)"
46+
sleep 5
47+
48+
echo "Consuming kafka out-topic queue"
49+
KAFKA_MESSAGE=`./kafka_consume.sh | tail -3 | head -1`
50+
echo "consumed message: $KAFKA_MESSAGE"
51+
52+
MSG_AGENT=`echo $KAFKA_MESSAGE | jq -r '.agent'`
53+
if [[ $MSG_AGENT == "OpenWhisk action" ]]
54+
then
55+
echo "Found the message we were expecting"
56+
else
57+
echo "Something went wrong"
58+
echo "Uninstalling wsk actions, etc."
59+
./deploy.sh --uninstall
60+
exit -1
61+
fi
62+
63+
echo "Uninstalling wsk actions, etc."
64+
./deploy.sh --uninstall

0 commit comments

Comments
 (0)