This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from kinvolk/invidian/calico-tests
test/calico: initial commit
- Loading branch information
Showing
825 changed files
with
195,262 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.