Open bogski87 opened 6 years ago
Hey @bogski87! Did you run go get .
?
Hi @gpestana thanks for getting back to me.
No, if i try to run that i get a permission denied error. Running it through sudo doesn't work either (i tried sudo -E which used to work).
I'm quite new to the go language and environment so it is probably i've made a mistake somewhere, i did the following:
1) CD go_projects/src 2) sudo git clone https://github.com/gpestana/kapacitor-unit.git
This created a folder 'kapacitor-unit'
3) go install github.com/gpestana/kapacitor-unit
Then i get the error messages:
philb@KapacitorUnitTest:~/go_projects/src$ go install github.com/gpestana/kapacitor-unit can't load package: package github.com/gpestana/kapacitor-unit: cannot find package "github.com/gpestana/kapacitor-unit" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit (from $GOROOT) /home/philb/go_projects/src/github.com/gpestana/kapacitor-unit (from $GOPATH)
IF i CD into the kapacitor-unit directory and run go install then i get more error messages > philb@KapacitorUnitTest:~/go_projects/src/kapacitor-unit$ go install kapacitorunit.go:5:2: cannot find package "github.com/fatih/color" in any of: /usr/local/go/src/github.com/fatih/color (from $GOROOT) /home/philb/go_projects/src/github.com/fatih/color (from $GOPATH) kapacitorunit.go:6:2: cannot find package "github.com/gpestana/kapacitor-unit/cli" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/cli (from $GOROOT) /home/philb/go_projects/src/github.com/gpestana/kapacitor-unit/cli (from $GOPATH) kapacitorunit.go:7:2: cannot find package "github.com/gpestana/kapacitor-unit/io" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/io (from $GOROOT) /home/philb/go_projects/src/github.com/gpestana/kapacitor-unit/io (from $GOPATH) kapacitorunit.go:8:2: cannot find package "github.com/gpestana/kapacitor-unit/task" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/task (from $GOROOT) /home/philb/go_projects/src/github.com/gpestana/kapacitor-unit/task (from $GOPATH) kapacitorunit.go:9:2: cannot find package "github.com/gpestana/kapacitor-unit/test" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/test (from $GOROOT) /home/philb/go_projects/src/github.com/gpestana/kapacitor-unit/test (from $GOPATH) kapacitorunit.go:10:2: cannot find package "gopkg.in/yaml.v2" in any of: /usr/local/go/src/gopkg.in/yaml.v2 (from $GOROOT) /home/philb/go_projects/src/gopkg.in/yaml.v2 (from $GOPATH)
if i run go install github.com/gpestana/kapacitor-unit from within the directory i get the same issue
also, I realise that in the output i have up top the go path is looking for gp_projects - I've updated this to the right path now though with the same result.
Any other information please ask
PhilB
Hi again,
I did a bit of digging about go lang and in the end i gave up. I think there is a problem with go and ubuntu 17 or something because i've just done this on an older box and it worked.
Could i ask for some clarification though please? I'm running the unit test from one VM and connecting to my Kapacitor and InfluxDB instance on another machine. I'm using this line:
kapacitor-unit -dir /etc/kapacitor/ -kapacitor 192.168.1.12 --influxdb 192.168.1.12 --tests ./sample/test_cpu.yaml
Is this correct? because I'm getting an error message 2018/04/04 15:56:14 Post 192.168.1.12/kapacitor/v1/tasks: unsupported protocol scheme ""
I've read that it is related to the HTTP package for GO but i'm reluctant to start messing with files.
Thanks @gpestana
EDIT: I worked it out, i was adding the http part to the URL but forgetting to include the ports. However the test fails when it runs and i'm not sure why :(
@bogski87 Ok, cool to know that you managed to get it going. Can you print the output of the tests? The tests that come in the repo (samples) are failing on purpose -- as an example. But could you paste the output of the tests so we verify it?
Hi @gpestana
If they're designed to fail on purpose then fair enough. I'd not realised. The error message was about parsing the configuration. I'm thinking though after some hindsight that that could be down to me neglecting to make sure my tick scripts and the tests had the same values/fields.
At this point i think the issue is definitely between keyboard and chair. I'm going to try again this morning from scratch but if i continue to get error messages I'll come back with the ouput!
Thank you for your time! I like the idea of this unit tester. I'm trying to write alerts for a citrix environment and it's difficult to test with real data because of the timing. I think if i can create some dummy data with this i should be able to get my scripts working!
Sounds good! Let me know if you run into any problems related to the configuration parsing or anything else. If so, please paste the output and the command you ran for me to try to recreate it. And let me know if we can close this issue 👌
HI @gpestana
I managed to get this going yesterday but am struggling to get it working again.
I've tried a couple of different scripts now and i can't see why the config wont parse.
yaml file:
tests:
- name: "Alert Windows Disk:: critical when Percent_Free_Space < 90"
task_name: WinDiskAlert.tick
db: DataBase
rp: year
type: stream
data:
- win_disk,host=Aserver Percent_Free_Space=70
- win_disk,host=Bserver Percent_Free_Space=95
expects:
ok: 0
warn: 0
crit: 1
- name: "Alert Disk:: warning when Percent_Free_Space < 80"
task_name: WinDiskAlert.tick
db: DataBase
rp: year
type: stream
data:
- win_disk,host=Aserver Percent_Free_Space=70
- win_disk,host=Bserver Percent_Free_Space=82
expects:
ok: 0
warn: 1
crit: 0
TICK Script:
var db = 'DataBase'
var rp = 'year'
var measurement = 'win_disk'
var groupBy = ['host']
var whereFilter = lambda: ("host" == 'Aserver' OR "host" == 'Bserver')
var name = 'WinDiskTesting'
var idVar = name + ':{{.Group}}'
var message = ''
var idTag = 'alertID'
var levelTag = 'level'
var messageField = 'message'
var durationField = 'duration'
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'alerts'
var triggerType = 'threshold'
var crit = 90
var warn = 80
var data = stream
|from()
.database('DataBase')
.retentionPolicy('autogen')
.measurement('win_disk')
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "Percent_Free_Space")
.as('Percent_Free_Space')
var trigger = data
|alert()
.crit(lambda: "Percent_Free_Space" < 90)
.warn(lambda: "Percent_Free_Space" < 80)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.email('email@email.co.uk')
I've replaced the DB name (can't include real ones)
I'm expecting a CRITICAL and a WARNING alert when i run this, but it fails to parse the config file.
Commands:
$GOBIN/kapacitor-unit --dir ./sample/disk/ --tests ./sample/disk/WinDiskAlert.yaml
$GOBIN/kapacitor unit --dir ./sample/disk/ -influxdb http://database_ip:8086 -kapacitor http://kapacitor_ip: 9092 --tests ./sample/disk/WinDiskAlert.yaml
Output:
philb@InfluxDB:~/go_projects/src/github.com/kapacitor-unit/sample/disk$ $GOBIN/kapacitor-unit --dir ./sample/disk/ --tests ./sample/disk/WinDiskAlert.yaml
_ _ _ _ _
| | (_) | (_) |
| | ____ _ _ __ __ _ ___ _| |_ ___ _ __ ______ _ _ _ __ _| |_
| |/ / _` | '_ \ / _` |/ __| | __/ _ \| '__|______| | | | '_ \| | __|
| < (_| | |_) | (_| | (__| | || (_) | | | |_| | | | | | |_
|_|\_\__,_| .__/ \__,_|\___|_|\__\___/|_| \__,_|_| |_|_|\__|
| |
|_|
The unit test framework for TICK scripts (v0.8)
2018/04/06 10:59:25 Test configuration parse failed
philb@InfluxDB:~/go_projects/src/github.com/kapacitor-unit/sample/disk$
I'm uploading the files to my home directory and copying them into the sample/disk/ directory. I haven't used sudo to move the files.
I was having the same issue before i started putting the different alerts/scripts in folders.
I can't see anything obvious that stands out from the config file.
I did notice yesterday i was having trouble with one script, but once i removed the |window node from my TICK script it worked. So i don't know if that is a separate issue?
The TICK scripts i use are generally built using Chronograf's TICK script editor then copied into Visual Studio.
Any idea's? i'd love to get this working so i can start some proper testing.
Thanks,
PhilB
EDIT:
I'm putting my scripts in sample/cpu and using ./sample/ for the --dir and --tests this always gives a parse error.
If i run the unit tests and specify the full path
--dir /home/philb/go_projects/src/github.com/kapacitor-unit/sample/cpu/ --tests /home/philb/go_projects/src/github.com/kapacitor-unit/sample/cpu/collectorCPU.yaml
it works, prcoessing the config
Thanks.
Hello,
I don't know if I've missed something here or not but the unit test package won't install. I followed the documentation on this repository to no avail.
Expected result: i run the commands listed on the documentaion, the Kapacitor unit test installs and i use it for testing.
Actual result: _kapacitorunit.go:5:2: cannot find package "github.com/fatih/color" in any of: /usr/local/go/src/github.com/fatih/color (from $GOROOT) /home/philb/gp_projects/src/github.com/fatih/color (from $GOPATH) kapacitorunit.go:6:2: cannot find package "github.com/gpestana/kapacitor-unit/cli" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/cli (from $GOROOT) /home/philb/gp_projects/src/github.com/gpestana/kapacitor-unit/cli (from $GOPATH) kapacitorunit.go:7:2: cannot find package "github.com/gpestana/kapacitor-unit/io" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/io (from $GOROOT) /home/philb/gp_projects/src/github.com/gpestana/kapacitor-unit/io (from $GOPATH) kapacitorunit.go:8:2: cannot find package "github.com/gpestana/kapacitor-unit/task" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/task (from $GOROOT) /home/philb/gp_projects/src/github.com/gpestana/kapacitor-unit/task (from $GOPATH) kapacitorunit.go:9:2: cannot find package "github.com/gpestana/kapacitor-unit/test" in any of: /usr/local/go/src/github.com/gpestana/kapacitor-unit/test (from $GOROOT) /home/philb/gp_projects/src/github.com/gpestana/kapacitor-unit/test (from $GOPATH) kapacitorunit.go:10:2: cannot find package "gopkg.in/yaml.v2" in any of: /usr/local/go/src/gopkg.in/yaml.v2 (from $GOROOT) /home/philb/gpprojects/src/gopkg.in/yaml.v2 (from $GOPATH)
As far as i know the environment is set up correctly.
Go ENV: GOARCH="amd64" GOBIN="/home/philb/gp_projects/bin" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/philb/gp_projects" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config"
Go Version is 1.9
If other packages are required to install this, then it should be listed in the installation instructions.
Have i missed something or is it broken?
Thanks,
Phil