Skip to content

Commit

Permalink
Adding a working ci build v1
Browse files Browse the repository at this point in the history
  • Loading branch information
simonireilly committed Jun 30, 2019
1 parent df7b8b2 commit 4ac27ce
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
47 changes: 34 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
# Use the latest 2.1 version of CircleCI pipeline processing engine, see https://circleci.com/docs/2.0/configuration-reference/
version: 2.1
version: 2
jobs:
integration:
working_directory: ~/app
docker:
- image: circleci/node:4.8.
- image: wurstmeister/kafka:2.11-0.11.0.3
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ADVERTISED_PORT: 9092
KAFKA_PORT: 9092
KAFKA_ZOOKEEPER_CONNECT: localhost:2181
KAFKA_DELETE_TOPIC_ENABLE: true
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-npm-wee
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm test:integration

# Use a package of configuration called an orb, see https://circleci.com/docs/2.0/orb-intro/
orbs:
# Declare a dependency on the welcome-orb
welcome: circleci/[email protected]

# Orchestrate or schedule a set of jobs, see https://circleci.com/docs/2.0/workflows/
workflows:
# Name the workflow "Welcome"
Welcome:
# Run the welcome/run job in its own container
workflow:
version: 2
test:
jobs:
- welcome/run
- integration
9 changes: 6 additions & 3 deletions test/integration/create-topic-produce-consume.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const kafka = require('kafka-node')
const config = require('../../app/config/consumer-config')

// Setup - Constants
const testTopicName = 'test-create-topic-produce-consume'
const testTopicName = `test-create-topic-produce-consume-${Date.now()}`

const topicsToCreate = [{
topic: testTopicName,
Expand All @@ -22,18 +22,21 @@ const payloads = [{

// Client setup
const client = new kafka.KafkaClient(config.clientOptions)
const consumer = new kafka.Consumer(client, [{ topic: testTopicName }], config.consumerOptions)
const producer = new kafka.Producer(client)

// Create the topic if it does not exist
client.createTopics(topicsToCreate, (error, result) => {
if(error !== null) {
console.log('\nCreating topic error', error)
process.exit(1)
} else {
console.log('\nCreating topic result', result)
}
})

// Consumer/Producer Setup
const consumer = new kafka.Consumer(client, [{ topic: testTopicName }], config.consumerOptions)
const producer = new kafka.Producer(client)

// Produce a new message
producer.on('ready', function () {
producer.send(payloads, function (err, data) {
Expand Down

0 comments on commit 4ac27ce

Please sign in to comment.