-
Notifications
You must be signed in to change notification settings - Fork 30
Move to Native Testlets #80
Changes from 123 commits
89cc89f
573f2b4
0a9d723
2e1cbc3
ebf0001
5742306
726bc83
2f389b6
91ce8ed
f023d31
8b6d304
412423a
7909ab4
aec7dd2
c09854c
0e652b6
7b0f02d
6875683
9a42484
3e10090
f4041cc
69e7caf
588b237
eec275f
f4734f1
7cae0cf
880e07b
8c4b981
5f1c30b
14d9929
7408315
4045257
967ed0d
b2acddd
5a3401f
7ee3fd6
62ba6c0
7ac7dca
02bd94e
0a229bd
4929bec
19f2de9
99c2533
4c0d0ce
5056f30
7adfee1
287aa03
7c67377
3d96d8a
6cb591c
9d8e7ae
1c83aea
bd0f9f7
ca56642
89081e8
823d0cc
2f2f2a3
7235411
5e2dc41
83de4a0
8e79ee7
954fe27
9be0b0a
5aa3288
467b552
30a312d
06fb854
1115f6d
a6e5a7d
1b91cf9
79d91f6
9ce5844
6b6fe19
e9f72e8
1e6fdf4
e1eda3a
9b50b20
1e5f023
9e0bddf
5c44e3e
43f3309
ca3352b
89ea72a
25b64d5
e632a04
fdf2571
84ea3b7
b5aeda3
37fc165
e53e916
8ddffcf
376693e
ecf6784
213cc97
0b85873
c781b56
60925b1
a6b5136
94fdc30
e837048
93aef66
15536a6
eb8a3c3
2c87bf3
ba132d8
4e6a2ff
ecab915
5db5c0d
318a560
66f43cf
a91ccfa
9a5a09b
a04a6c9
4163110
cf5da33
5a97598
118c9b5
579b7b2
4b63c09
6776423
4905176
1fa262b
0b13b92
6f1db24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
ToDD testing package | ||
|
||
Contains infrastructure running testlets as well as maintaining | ||
conformance for other native-Go testlet projects | ||
|
||
Copyright 2016 Matt Oswalt. Use or modification of this | ||
source code is governed by the license provided here: | ||
https://github.com/Mierdin/todd/blob/master/LICENSE | ||
*/ | ||
|
||
package testing | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
|
||
// This map provides name redirection so that the native testlets can use names that don't | ||
// conflict with existing system tools (i.e. using "toddping" instead of "ping") but users | ||
// can still refer to the testlets using simple names. | ||
// | ||
// In short, users refer to the testlet by <key> and this map will redirect to the | ||
// actual binary name <value> | ||
nativeTestlets = map[string]string{ | ||
"ping": "toddping", | ||
} | ||
) | ||
|
||
// Testlet defines what a testlet should look like if built in native | ||
// go and compiled with the agent | ||
type Testlet interface { | ||
|
||
// Run is the "workflow" function for a testlet. All testing takes place here | ||
// (or in a function called within) | ||
Run(target string, args []string, timeLimit int) (metrics map[string]string, err error) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having a "Base*" struct seems like an attempt to use inheritance. What does this add beyond the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing, now. This was another relic from the previous approach. Removed in upcoming patch |
||
|
||
// GetTestletPath generates whatever path is needed to reach the given testlet | ||
// It first determines if the referenced testlet is native or not - if it is native, | ||
// then only the name needs to be returned (all native testlets must be in the path). | ||
// If it is a custom testlet, then it will generate the full path to the testlet, | ||
// ensure it is a valid path, and if so, return that full path back to the caller. | ||
func GetTestletPath(testletName, optDir string) (string, error) { | ||
|
||
if _, ok := nativeTestlets[testletName]; ok { | ||
log.Debugf("%s is a native testlet", testletName) | ||
return nativeTestlets[testletName], nil | ||
} | ||
|
||
log.Debugf("%s is a custom testlet", testletName) | ||
|
||
// Generate path to testlet and make sure it exists. | ||
testletPath := fmt.Sprintf("%s/assets/testlets/%s", optDir, testletName) | ||
if _, err := os.Stat(testletPath); err != nil || os.IsNotExist(err) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, my intention was that regardless of the error, I wanted to treat it like the testlet didn't exist. However, that's fairly confusing. I clarified this a bit by making the error more generic (and removing |
||
log.Errorf("Testlet %q does not exist on this agent", testletName) | ||
return "", errors.New("Error installing testrun - testlet doesn't exist on this agent.") | ||
} | ||
|
||
return testletPath, nil | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General note, this could be changed to use
exec.CommandContext
(added in 1.7) and simplify the timeout logic below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created https://github.com/Mierdin/todd/issues/93 to track this so that when I move CI to Go 1.7, I'll add this. Thanks