Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Hofmann committed Nov 28, 2019
2 parents 50d00fa + d51ea1a commit 0c345d6
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { IsBoolean, IsNotEmpty, IsNumber, IsString } from 'class-validator'

export class CheckMkForwarderProperties {

public constructor(init?:Partial<CheckMkForwarderProperties>) {
Object.assign(this, init);
}

/**
* Send results to a CheckMK-enabled monitoring system, using the parameters below in your 'sakuli.properties' to activate the forwarder.
*/
Expand Down Expand Up @@ -34,4 +30,34 @@ export class CheckMkForwarderProperties {
*/
@StringProperty("sakuli.forwarder.check_mk.spoolfile_prefix")
spoolfilePrefix: string = "sakuli_suite";

/**
* Hostname for piggyback check results (<<<<YOUR_HOSTNAME_HERE>>>>)
*/
@StringProperty("sakuli.forwarder.check_mk.piggyback_hostname")
@IsString()
piggybackHostname: string = "";

/**
* Name of the reported section (<<<YOUR_SECTION_NAME>>>)
* DEFAULT: local
*/
@StringProperty("sakuli.forwarder.check_mk.section_name")
@IsString()
sectionName: string = "local";

/**
* optional service description forwarded to the output check result, when not set, testsuite.id is used
*/
@StringProperty("sakuli.forwarder.check_mk.service_description")
@IsString()
serviceDescription: string = "";

/**
* Boolean property to disable detailed summary in check results
* DEFAULT: true
*/
@BooleanProperty("sakuli.forwarder.check_mk.output.details")
@IsBoolean()
outputDetails: boolean = true;
}
27 changes: 13 additions & 14 deletions packages/sakuli-forwarder-check_mk/src/checkmk-forwarder.class.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Forwarder, Project, TestExecutionContext } from "@sakuli/core";
import { createPropertyObjectFactory, ifPresent, Maybe, SimpleLogger } from "@sakuli/commons";
import { CheckMkForwarderProperties } from "./checkmk-forwarder-properties.class";
import { promises as fs } from 'fs';
import { dirExists } from "./dir-exists.function";
import { join, resolve } from "path";
import { CheckMkResultBuilderProperties, CheckMkTestResultOutputBuilder } from "@sakuli/result-builder-checkmk";
import { createSpoolFileName } from "./create-spool-file.function";
import { validateProps } from "@sakuli/result-builder-commons";
import {Forwarder, Project, TestExecutionContext} from "@sakuli/core";
import {createPropertyObjectFactory, ifPresent, Maybe, SimpleLogger} from "@sakuli/commons";
import {CheckMkForwarderProperties} from "./checkmk-forwarder-properties.class";
import {promises as fs} from 'fs';
import {dirExists} from "./dir-exists.function";
import {join, resolve} from "path";
import {CheckMkTestResultOutputBuilder} from "@sakuli/result-builder-checkmk";
import {createSpoolFileName} from "./create-spool-file.function";
import {validateProps} from "@sakuli/result-builder-commons";

export class CheckMkForwarder implements Forwarder {

private properties: Maybe<CheckMkForwarderProperties>;
private logger: Maybe<SimpleLogger>;
private builderProperties : Maybe<CheckMkResultBuilderProperties>;

constructor(
private outputBuilder = new CheckMkTestResultOutputBuilder()
Expand All @@ -22,22 +21,22 @@ export class CheckMkForwarder implements Forwarder {
logDebug(message: string, ...data: any[]) {
ifPresent(this.logger, log => log.debug(message, ...data));
}

logInfo(message: string, ...data: any[]) {
ifPresent(this.logger, log => log.info(message, ...data));
}

logWarn(message: string, ...data: any[]) {
ifPresent(this.logger, log => log.warn(message, ...data));
}

logError(message: string, ...data: any[]) {
ifPresent(this.logger, log => log.error(message, ...data));
}

async setup(project: Project, logger: SimpleLogger): Promise<void> {
this.properties = createPropertyObjectFactory(project)(CheckMkForwarderProperties);
await validateProps(this.properties);

this.builderProperties = createPropertyObjectFactory(project)(CheckMkResultBuilderProperties);
await validateProps(this.builderProperties);
this.logger = logger;
}

Expand All @@ -47,7 +46,7 @@ export class CheckMkForwarder implements Forwarder {
for (const testContextEntity of ctx.testSuites) {
const renderedTemplate = this.outputBuilder.render(testContextEntity, {
currentSuite: testContextEntity,
props: this.builderProperties
props: this.properties
});
const fileName = createSpoolFileName(testContextEntity, props);
const path = props.spoolDir;
Expand Down

This file was deleted.

Loading

0 comments on commit 0c345d6

Please sign in to comment.