You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/11/14 13:53:36 UTC

[camel-kamelets] 01/02: Added Kinesis Firehose IT Test

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch kinesis-firehose-sink
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit dae6dd5739c82814f0b8131b3f68a54914a39375
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Nov 14 14:39:03 2022 +0100

    Added Kinesis Firehose IT Test
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../aws-kinesis-firehose/sink/terraform/main.tf    | 86 ++++++++++++++++++++++
 .../sink/timer-aws-kinesis-firehose-it-test.sh     | 37 ++++++++++
 .../sink/timer-aws-kinesis-firehose.yaml           | 29 ++++++++
 3 files changed, 152 insertions(+)

diff --git a/it-tests/aws/aws-kinesis-firehose/sink/terraform/main.tf b/it-tests/aws/aws-kinesis-firehose/sink/terraform/main.tf
new file mode 100644
index 00000000..5b8a1405
--- /dev/null
+++ b/it-tests/aws/aws-kinesis-firehose/sink/terraform/main.tf
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+terraform {
+  required_providers {
+    aws = {
+      source  = "hashicorp/aws"
+      version = "~> 3.27"
+    }
+  }
+
+  required_version = ">= 0.14.9"
+}
+
+provider "aws" {
+  profile = "default"
+  region  = "eu-west-1"
+}
+
+variable "kinesis_delivery_stream_name" {
+  type = string
+  default = "kinesis-camel-test-123"
+}
+
+resource "aws_kinesis_firehose_delivery_stream" "extended_s3_stream" {
+  name        = var.kinesis_delivery_stream_name
+  destination = "extended_s3"
+
+  extended_s3_configuration {
+    role_arn   = aws_iam_role.firehose_role.arn
+    bucket_arn = aws_s3_bucket.bucket.arn
+  }
+}
+
+variable "s3_bucket_delivery_stream_name" {
+  type = string
+  default = "s3-camel-test-123"
+}
+
+
+resource "aws_s3_bucket" "bucket" {
+  bucket = var.s3_bucket_delivery_stream_name
+}
+
+resource "aws_iam_role" "firehose_role" {
+  name = "firehose_test_role"
+
+  assume_role_policy = <<EOF
+{
+  "Version": "2012-10-17",
+  "Statement": [
+    {
+      "Action": "sts:AssumeRole",
+      "Principal": {
+        "Service": "firehose.amazonaws.com"
+      },
+      "Effect": "Allow",
+      "Sid": ""
+    }
+  ]
+}
+EOF
+}
+
+output "Kinesis-firehose-dist-stream" {
+  value       = aws_kinesis_firehose_delivery_stream.extended_s3_stream.arn
+  description = "The Kinesis Stream ARN"
+}
+output "S3-Bucket" {
+  value       = aws_s3_bucket.bucket.id
+  description = "The S3 Bucket"
+}	
diff --git a/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose-it-test.sh b/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose-it-test.sh
new file mode 100755
index 00000000..c21b8c99
--- /dev/null
+++ b/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose-it-test.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+if [ $# -ne 1 ]; then
+    echo $0: usage: timer-aws-kinesis-firehose-it-test.sh camel-version
+    exit 1
+fi
+
+camel_version=$1
+
+cd terraform/
+terraform init
+terraform apply -auto-approve
+cd ../
+
+jbang run -Dcamel.jbang.version=$camel_version camel@apache/camel run timer-aws-kinesis-firehose.yaml &
+
+sleep 10
+
+variable=`jbang run -Dcamel.jbang.version=$camel_version camel@apache/camel get | tail -n +2` 
+success=`echo $variable | cut -d' ' -f11`
+fail=`echo $variable | cut -d' ' -f12`
+if [[ $success == 5 && $fail == 0 ]] 
+then 
+    mkdir -p ../../../tests/
+    echo "Test Successful" > ../../../tests/timer-aws-kinesis-firehose-it-test.result ;
+else
+    mkdir -p ../../../tests/
+    echo "Test failed" > ../../../tests/timer-aws-kinesis-firehose-it-test.result ;
+fi
+
+jbang run -Dcamel.jbang.version=$camel_version camel@apache/camel stop timer-aws-kinesis-firehose
+
+cd terraform/
+terraform destroy -auto-approve
+cd ../
+
+cat ../../../tests/timer-aws-kinesis-firehose-it-test.result
diff --git a/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose.yaml b/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose.yaml
new file mode 100644
index 00000000..288f9f2b
--- /dev/null
+++ b/it-tests/aws/aws-kinesis-firehose/sink/timer-aws-kinesis-firehose.yaml
@@ -0,0 +1,29 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+- route:
+    from:
+      uri: "timer://foo?delay=0&fixedRate=true&period=1000&repeatCount=5"
+      steps:
+      - set-body:
+          constant: "test"
+      - to: 
+          uri: "kamelet:aws-kinesis-firehose-sink"
+          parameters:
+            streamName: "kinesis-camel-test-123"
+            useDefaultCredentialsProvider: true
+            region: "eu-west-1"