Add resource auto grouping
Sorry for the size of this patch, I was busy hacking and plumbing away and it got out of hand! I'm allowing this because there doesn't seem to be anyone hacking away on parts of the code that this would break, since the resource code is fairly stable in this change. In particular, it revisits and refreshes some areas of the code that didn't see anything new or innovative since the project first started. I've gotten rid of a lot of cruft, and in particular cleaned up some things that I didn't know how to do better before! Here's hoping I'll continue to learn and have more to improve upon in the future! (Well let's not hope _too_ hard though!) The logical goal of this patch was to make logical grouping of resources possible. For example, it might be more efficient to group three package installations into a single transaction, instead of having to run three separate transactions. This is because a package installation typically has an initial one-time per run cost which shouldn't need to be repeated. Another future goal would be to group file resources sharing a common base path under a common recursive fanotify watcher. Since this depends on fanotify capabilities first, this hasn't been implemented yet, but could be a useful method of reducing the number of separate watches needed, since there is a finite limit. It's worth mentioning that grouping resources typically _reduces_ the parallel execution capability of a particular graph, but depending on the cost/benefit tradeoff, this might be preferential. I'd submit it's almost universally beneficial for pkg resources. This monster patch includes: * the autogroup feature * the grouping interface * a placeholder algorithm * an extensive test case infrastructure to test grouping algorithms * a move of some base resource methods into pgraph refactoring * some config/compile clean ups to remove code duplication * b64 encoding/decoding improvements * a rename of the yaml "res" entries to "kind" (more logical) * some docs * small fixes * and more!
This commit is contained in:
55
misc_test.go
55
misc_test.go
@@ -18,7 +18,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
@@ -58,6 +57,9 @@ func TestMiscT1(t *testing.T) {
|
||||
t.Errorf("Result is incorrect.")
|
||||
}
|
||||
|
||||
if Basename("") != "" { // TODO: should this equal something different?
|
||||
t.Errorf("Result is incorrect.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiscT2(t *testing.T) {
|
||||
@@ -169,57 +171,6 @@ func TestMiscT5(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiscT6(t *testing.T) {
|
||||
|
||||
type foo struct {
|
||||
Name string `yaml:"name"`
|
||||
Res string `yaml:"res"`
|
||||
Value int `yaml:"value"`
|
||||
}
|
||||
|
||||
obj := foo{"dude", "sweet", 42}
|
||||
output, ok := ObjToB64(obj)
|
||||
if ok != true {
|
||||
t.Errorf("First result should be true.")
|
||||
}
|
||||
var data foo
|
||||
if B64ToObj(output, &data) != true {
|
||||
t.Errorf("Second result should be true.")
|
||||
}
|
||||
// TODO: there is probably a better way to compare these two...
|
||||
if fmt.Sprintf("%+v\n", obj) != fmt.Sprintf("%+v\n", data) {
|
||||
t.Errorf("Strings should match.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiscT7(t *testing.T) {
|
||||
|
||||
type Foo struct {
|
||||
Name string `yaml:"name"`
|
||||
Res string `yaml:"res"`
|
||||
Value int `yaml:"value"`
|
||||
}
|
||||
|
||||
type bar struct {
|
||||
Foo `yaml:",inline"` // anonymous struct must be public!
|
||||
Comment string `yaml:"comment"`
|
||||
}
|
||||
|
||||
obj := bar{Foo{"dude", "sweet", 42}, "hello world"}
|
||||
output, ok := ObjToB64(obj)
|
||||
if ok != true {
|
||||
t.Errorf("First result should be true.")
|
||||
}
|
||||
var data bar
|
||||
if B64ToObj(output, &data) != true {
|
||||
t.Errorf("Second result should be true.")
|
||||
}
|
||||
// TODO: there is probably a better way to compare these two...
|
||||
if fmt.Sprintf("%+v\n", obj) != fmt.Sprintf("%+v\n", data) {
|
||||
t.Errorf("Strings should match.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMiscT8(t *testing.T) {
|
||||
|
||||
r0 := []string{"/"}
|
||||
|
||||
Reference in New Issue
Block a user