Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests need to delete topic between runs #41

Open
DreadPirateShawn opened this issue Mar 24, 2020 · 1 comment
Open

tests need to delete topic between runs #41

DreadPirateShawn opened this issue Mar 24, 2020 · 1 comment

Comments

@DreadPirateShawn
Copy link

DreadPirateShawn commented Mar 24, 2020

The following tick + test will work fine:

var weather = batch
	| query('''
		SELECT mean(temperature)
		FROM "weather"."default"."temperature"
		''')
			.period(5m)
			.every(10m)

	weather
	| alert().id('Temperature')
		.topic('weather')
		.message('Temperature alert - batch')
		.warn(lambda: "mean" > 80)
		.crit(lambda: "mean" > 100)
		.stateChangesOnly()
    .log('/tmp/temperature_batch.tick.log')
tests:

  - name: "Alert weather:: batch"
    task_name: alert_weather_batch.tick
    db: weather
    rp: default
    type: batch
    data:
      - temperature,location=us-midwest temperature=110
      - temperature,location=us-midwest temperature=91
    expects:
      ok: 0
      warn: 0
      crit: 1

However, if a topic is added to the tick:

	| alert().id('Temperature')
		.topic('weather')

...then the test will only work once, and will fail on subsequent runs.

This is due to .stateChangesOnly() combined with the lack of topic state deletion between test runs.

That is to say -- in kapacitor, the "weather" topic tracks the critical state of the task, so even deleting and recreating the task between tests in not sufficient to reset the state.

The problem is confirmed for batch, unconfirmed for stream.

@DreadPirateShawn DreadPirateShawn changed the title tests need to delete topic between runs (confirmed for batch, unconfirmed for stream) tests need to delete topic between runs Mar 24, 2020
@DreadPirateShawn
Copy link
Author

Topic cleanup added in https://github.com/DreadPirateShawn/kapacitor-unit

(With apologies, I've fully forked rather than pushing upstream PRs, since the upstream doesn't really have an active maintainer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant