Skip to content

Commit

Permalink
Added test for incorrect env prefixes case and test with all prefix s…
Browse files Browse the repository at this point in the history
…ources

Signed-off-by: Tigran Manasyan <tigran.manasyan@xored.com>
  • Loading branch information
Tigran Manasyan committed Oct 2, 2020
1 parent f130d2c commit 9b91207
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
Expand Down Expand Up @@ -739,6 +740,7 @@ golang.org/x/tools v0.0.0-20190909030654-5b82db07426d/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
Expand Down
5 changes: 3 additions & 2 deletions k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ package k8s
import (
"fmt"
"io/ioutil"
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
"os"
"path/filepath"
"sync"

v1 "k8s.io/client-go/kubernetes/typed/core/v1"

"github.com/edwarnicke/exechelper"
"github.com/sirupsen/logrus"
apiv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -109,7 +110,7 @@ func ShowLogs(namespace string, options ...*exechelper.Option) {
}
}

// Find a pod by name or by matching all labels passed.
// DescribePod - find a pod by name or by matching all labels passed.
func DescribePod(namespace, name string, labels map[string]string) (*corev1.Pod, error) {
client, err := Client()
if err != nil {
Expand Down
22 changes: 12 additions & 10 deletions test/excluded_prefixes_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ package test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"time"

"github.com/edwarnicke/exechelper"
"github.com/ghodss/yaml"
"github.com/networkservicemesh/integration-k8s-kind/k8s"
"github.com/networkservicemesh/sdk/pkg/tools/prefixpool"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite"
"io/ioutil"
v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8s_yaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"time"

"github.com/networkservicemesh/integration-k8s-kind/k8s"
"github.com/networkservicemesh/sdk/pkg/tools/prefixpool"
)

const (
Expand Down Expand Up @@ -282,7 +284,7 @@ func (et *ExcludedPrefixesSuite) waitForPodStart(namespace, appLabelValue string
}

func prefixesFromFile(filename string) ([]string, error) {
source, err := ioutil.ReadFile(filename)
source, err := ioutil.ReadFile(filepath.Clean(filename))
if err != nil {
logrus.Error(err)
return nil, err
Expand Down

0 comments on commit 9b91207

Please sign in to comment.