Skip to content

Commit

Permalink
Merge pull request #1605 from jrha/metaconfig_kafka_hnormalise
Browse files Browse the repository at this point in the history
kafka & hnormalise: Add and fix tests
  • Loading branch information
stdweird committed Jul 28, 2023
2 parents 536f291 + 858d041 commit 1fedce4
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 8 deletions.
Expand Up @@ -2,7 +2,7 @@ unique template metaconfig/hnormalise/config;

include 'metaconfig/hnormalise/schema';

bind "/software/components/metaconfig/services/{/etc/hnormalise.yaml}/contents" = type_hnormalise;
bind "/software/components/metaconfig/services/{/etc/hnormalise.yaml}/contents" = hnormalise;

prefix "/software/components/metaconfig/services/{/etc/hnormalise.yaml}";
"daemons/hnormalise" = "restart";
Expand Down
5 changes: 5 additions & 0 deletions ncm-metaconfig/src/main/metaconfig/hnormalise/pan/schema.pan
Expand Up @@ -39,9 +39,14 @@ type hnormalise_output = {
"zeromq" ? hnormalise_output_zeromq
};

type hnormalise_logging = {
"frequency" ? long(0..)
};


type hnormalise = {
"input": hnormalise_input
"output": hnormalise_output
"fields": string[][]
"logging" ? hnormalise_logging
};
@@ -0,0 +1,40 @@
object template config;

include 'metaconfig/hnormalise/config';

prefix "/software/components/metaconfig/services/{/etc/hnormalise.yaml}/contents";

"logging" = dict(
"frequency", 100000,
);

"input" = dict(
"zeromq", dict(
"method", "pull",
"host", "lo",
"port", 31338,
),
);

"output" = dict(
"zeromq", dict(
"success", dict(
"method", "push",
"host", "localhost",
"port", 27001,
),
"failure", dict(
"method", "push",
"host", "localhost",
"port", 27002,
),
),
);

"fields" = list(
list("@source_host", "hostname"),
list("message", "msg"),
list("syslog_version", "version"),
list("syslog_abspri", "pri"),
list("program", "app_name"),
);
@@ -0,0 +1,32 @@
Base test for config
---
/etc/hnormalise.yaml
---
^fields:$
^- - '@source_host'$
^ - hostname$
^- - message$
^ - msg$
^- - syslog_version$
^ - version$
^- - syslog_abspri$
^ - pri$
^- - program$
^ - app_name$
^input:$
^ zeromq:$
^ host: lo$
^ method: pull$
^ port: 31338$
^logging:$
^ frequency: 100000$
^output:$
^ zeromq:$
^ failure:$
^ host: localhost$
^ method: push$
^ port: 27002$
^ success:$
^ host: localhost$
^ method: push$
^ port: 27001$
@@ -1,8 +1,4 @@
unique template common/kafka/config;

include 'components/metaconfig/config';
include 'components/dirperm/config';
include 'components/sysconfig/config';
object template config;

include 'metaconfig/kafka/config';

Expand Down
@@ -1,9 +1,9 @@
Base test for config
---
/etc/elasticsearch/elasticsearch.yml
/etc/kafka/server.properties
---
^advertised.listeners=INTERNAL://kafka.cluster.log:9092,EXTERNAL://kafka.cluster.os:9093,EXTERNAL_LOG://kafka.cluster.log:9094$
^broker.id=21$
^broker.id=42$
^inter.broker.listener.name=INTERNAL$
^listener.security.protocol.map=EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT,EXTERNAL_LOG:PLAINTEXT$
^listeners=INTERNAL://kafka.cluster.log:9092,EXTERNAL://kafka.cluster.os:9093,EXTERNAL_LOG://kafka.cluster.log:9094$
Expand Down
17 changes: 17 additions & 0 deletions ncm-metaconfig/src/test/perl/service-hnormalise.t
@@ -0,0 +1,17 @@
use Test::Quattor::ProfileCache qw(set_json_typed get_json_typed);

BEGIN {
set_json_typed()
}

use Test::More;
use Test::Quattor::TextRender::Metaconfig;

ok(get_json_typed(), "json_typed enabled for yaml render");

my $u = Test::Quattor::TextRender::Metaconfig->new(
service => 'hnormalise',
usett => 0, # uses builtin modules
)->test();

done_testing;
9 changes: 9 additions & 0 deletions ncm-metaconfig/src/test/perl/service-kafka.t
@@ -0,0 +1,9 @@
use Test::More;
use Test::Quattor::TextRender::Metaconfig;

my $u = Test::Quattor::TextRender::Metaconfig->new(
service => 'kafka',
usett => 0, # uses builtin modules
)->test();

done_testing;

0 comments on commit 1fedce4

Please sign in to comment.