Skip to content

Commit

Permalink
Add scope test instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Shotwell committed Jan 30, 2020
1 parent 3982e20 commit 10b2941
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ vendor
*.swo
*~

# scope test logs
scope-go-*.log

dist
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/hashicorp/go-getter v1.3.1-0.20190627223108-da0323b9545e
github.com/hashicorp/go-multierror v1.0.0
github.com/imdario/mergo v0.3.7 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mholt/archiver v3.1.1+incompatible
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/nwaples/rardecode v1.0.0 // indirect
Expand All @@ -30,13 +29,17 @@ require (
github.com/tj/go-spin v1.1.0
github.com/ugorji/go v1.1.7 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.undefinedlabs.com/scopeagent v0.1.6
gopkg.in/yaml.v2 v2.2.4
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
k8s.io/api v0.17.0
k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783
k8s.io/apimachinery v0.17.0
k8s.io/cli-runtime v0.17.0
k8s.io/client-go v0.17.0
k8s.io/code-generator v0.16.5-beta.1 // indirect
sigs.k8s.io/controller-runtime v0.4.0
sigs.k8s.io/controller-tools v0.2.4 // indirect
)

replace github.com/appscode/jsonpatch => github.com/gomodules/jsonpatch v2.0.1+incompatible
42 changes: 42 additions & 0 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/analyze/cluster_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (

"github.com/blang/semver"
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"go.undefinedlabs.com/scopeagent"
)

func Test_analyzeClusterVersionResult(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
outcomes := []*troubleshootv1beta1.Outcome{
{
Fail: &troubleshootv1beta1.SingleOutcome{
Expand Down
5 changes: 5 additions & 0 deletions pkg/analyze/container_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.undefinedlabs.com/scopeagent"
)

func Test_compareRuntimeConditionalToActual(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
conditional string
Expand Down Expand Up @@ -67,6 +70,8 @@ func Test_compareRuntimeConditionalToActual(t *testing.T) {
}

func Test_containerRuntime(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
analyzer troubleshootv1beta1.ContainerRuntime
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyze/deployment_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.undefinedlabs.com/scopeagent"
)

func Test_deploymentStatus(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
analyzer troubleshootv1beta1.DeploymentStatus
Expand Down
6 changes: 5 additions & 1 deletion pkg/analyze/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.undefinedlabs.com/scopeagent"
)

func Test_compareDistributionConditionalToActual(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
conditional string
Expand Down Expand Up @@ -49,10 +52,11 @@ func Test_compareDistributionConditionalToActual(t *testing.T) {
assert.Equal(t, test.expected, actual)
})
}

}

func Test_mustNormalizeDistributionName(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
raw string
expected Provider
Expand Down
12 changes: 12 additions & 0 deletions pkg/analyze/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package analyzer

import (
"os"
"testing"

"go.undefinedlabs.com/scopeagent"
)

func TestMain(m *testing.M) {
os.Exit(scopeagent.Run(m))
}
6 changes: 5 additions & 1 deletion pkg/analyze/text_analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.undefinedlabs.com/scopeagent"
)

func Test_textAnalyze(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
analyzer troubleshootv1beta1.TextAnalyze
Expand Down Expand Up @@ -218,6 +221,8 @@ func Test_textAnalyze(t *testing.T) {
}

func Test_compareRegex(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
conditional string
Expand Down Expand Up @@ -263,5 +268,4 @@ func Test_compareRegex(t *testing.T) {
assert.Equal(t, test.expected, actual)
})
}

}
3 changes: 3 additions & 0 deletions pkg/apis/troubleshoot/v1beta1/analyzer_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.undefinedlabs.com/scopeagent"
"gopkg.in/yaml.v2"
)

func TestAnalyze_Unmarshal(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
spec string
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/troubleshoot/v1beta1/v1beta1_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"
"testing"

"go.undefinedlabs.com/scopeagent"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -49,7 +50,7 @@ func TestMain(m *testing.M) {
log.Fatal(err)
}

code := m.Run()
code := scopeagent.Run(m)
t.Stop()
os.Exit(code)
}
3 changes: 3 additions & 0 deletions pkg/collect/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import (

troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/stretchr/testify/assert"
"go.undefinedlabs.com/scopeagent"
)

func Test_ParseSpec(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
spec string
Expand Down
12 changes: 12 additions & 0 deletions pkg/collect/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package collect

import (
"os"
"testing"

"go.undefinedlabs.com/scopeagent"
)

func TestMain(m *testing.M) {
os.Exit(scopeagent.Run(m))
}
5 changes: 5 additions & 0 deletions pkg/collect/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import (

troubleshootv1beta1 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta1"
"github.com/stretchr/testify/assert"
"go.undefinedlabs.com/scopeagent"
)

func Test_selectorToString(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
selector []string
Expand All @@ -29,6 +32,8 @@ func Test_selectorToString(t *testing.T) {
}

func Test_DeterministicIDForCollector(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
tests := []struct {
name string
collector *troubleshootv1beta1.Collect
Expand Down
12 changes: 12 additions & 0 deletions pkg/redact/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package redact

import (
"os"
"testing"

"go.undefinedlabs.com/scopeagent"
)

func TestMain(m *testing.M) {
os.Exit(scopeagent.Run(m))
}
3 changes: 3 additions & 0 deletions pkg/redact/redact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.undefinedlabs.com/scopeagent"
)

func Test_Redactors(t *testing.T) {
test := scopeagent.StartTest(t)
defer test.End()
original := `[
{
"metadata": {
Expand Down

0 comments on commit 10b2941

Please sign in to comment.