Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

test/calico: initial commit #210

Merged
merged 2 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ require (
github.com/packethost/packngo v0.2.0
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1
github.com/projectcalico/libcalico-go v1.7.2-0.20200121214551-31188cbacff0
github.com/prometheus/alertmanager v0.20.0
github.com/prometheus/client_golang v1.5.0
github.com/prometheus/procfs v0.0.10 // indirect
Expand Down Expand Up @@ -102,3 +103,6 @@ replace helm.sh/helm/v3 => github.com/kinvolk/helm/v3 v3.0.3-0.20200115143854-74
// https://github.com/kubernetes/kubernetes/issues/88183
// https://github.com/googleapis/gnostic/commit/896953e6749863beec38e27029c804e88c3144b8
replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.0

// To address https://github.com/etcd-io/etcd/issues/11563. Required until new version of etcd is released with the fix.
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
101 changes: 79 additions & 22 deletions go.sum

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions test/calico/calico_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2020 The Lokomotive Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build packet
// +build poste2e

package calico

import (
"context"
"testing"

"github.com/projectcalico/libcalico-go/lib/apiconfig"
client "github.com/projectcalico/libcalico-go/lib/clientv3"
"github.com/projectcalico/libcalico-go/lib/options"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/kinvolk/lokomotive/test/components/util"
)

func TestHostEndpoints(t *testing.T) {
// Build Calico client.
cac := apiconfig.NewCalicoAPIConfig()
cac.Spec.DatastoreType = apiconfig.Kubernetes
cac.Spec.Kubeconfig = util.KubeconfigPath(t)

c, err := client.New(*cac)
if err != nil {
t.Fatalf("failed creating Calico client: %v", err)
}

// Build list of nodes which has associated HostEndpoint object.
hostEndpointList, err := c.HostEndpoints().List(context.TODO(), options.ListOptions{})
if err != nil {
t.Fatalf("failed getting hostendpoint objects: %v", err)
}

endpoints := map[string]struct{}{}

for _, v := range hostEndpointList.Items {
endpoints[v.Spec.Node] = struct{}{}
}

cs := util.CreateKubeClient(t)

nodes, err := cs.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil {
t.Fatalf("failed getting list of nodes in the cluster: %v", err)
}

for _, v := range nodes.Items {
if _, ok := endpoints[v.Name]; !ok {
t.Errorf("no HostEndpoint object found for node %q", v.Name)
}
}
}
202 changes: 202 additions & 0 deletions vendor/cloud.google.com/go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading