Skip to content

Commit

Permalink
Move E2E tests to Ginkgo
Browse files Browse the repository at this point in the history
  • Loading branch information
palexster committed Jul 4, 2021
1 parent 037fff9 commit 192351f
Show file tree
Hide file tree
Showing 27 changed files with 932 additions and 918 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grandcat/zeroconf v1.0.0
github.com/gruntwork-io/gruntwork-cli v0.7.0
github.com/gruntwork-io/terratest v0.30.7
github.com/gruntwork-io/terratest v0.35.6
github.com/jinzhu/copier v0.0.0-20201025035756-632e723a6687
github.com/julienschmidt/httprouter v1.3.0
github.com/metal-stack/go-ipam v1.8.4-0.20210322080203-5a9da5064b27
Expand Down
49 changes: 27 additions & 22 deletions go.sum

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pkg/clusterid/clusterID.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewClusterIDFromClient(client kubernetes.Interface) (ClusterID, error) {
namespace, found := os.LookupEnv("POD_NAMESPACE")
if !found {
klog.Info("POD_NAMESPACE not set")
data, err := ioutil.ReadFile(consts.ServiceAccount)
data, err := ioutil.ReadFile(consts.ServiceAccountNamespacePath)
if err != nil {
klog.Error(err, "Unable to get namespace")
os.Exit(1)
Expand Down Expand Up @@ -112,12 +112,12 @@ func getClusterID(cm *v1.ConfigMap) string {
if cm == nil {
return ""
}
return cm.Data[consts.ConfigMapKey]
return cm.Data[consts.ClusterIDConfigMapKey]
}

// SetupClusterID sets a new clusterid.
func (cId *ClusterIDImpl) SetupClusterID(namespace string) error {
cm, err := cId.client.CoreV1().ConfigMaps(namespace).Get(context.TODO(), consts.ClusterIDconfigMapName,
cm, err := cId.client.CoreV1().ConfigMaps(namespace).Get(context.TODO(), consts.ClusterIDConfigMapName,
metav1.GetOptions{})
if err != nil && !k8serror.IsNotFound(err) {
klog.Error(err)
Expand Down Expand Up @@ -166,17 +166,17 @@ func (cId *ClusterIDImpl) getMasterID() (string, error) {

// saveToConfigMap stores the clusterid in the detailed configMap.
func (cId *ClusterIDImpl) saveToConfigMap(id, namespace string) error {
cm, err := cId.client.CoreV1().ConfigMaps(namespace).Get(context.TODO(), consts.ClusterIDconfigMapName,
cm, err := cId.client.CoreV1().ConfigMaps(namespace).Get(context.TODO(), consts.ClusterIDConfigMapName,
metav1.GetOptions{})
if err != nil {
if k8serror.IsNotFound(err) {
// does not exist
cm = &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: consts.ClusterIDconfigMapName,
Name: consts.ClusterIDConfigMapName,
},
Data: map[string]string{
consts.ConfigMapKey: id,
consts.ClusterIDConfigMapKey: id,
},
}
cId.id = id
Expand All @@ -187,8 +187,8 @@ func (cId *ClusterIDImpl) saveToConfigMap(id, namespace string) error {
return err
}
// already exists, update it if needed
if cm.Data[consts.ConfigMapKey] != id {
cm.Data[consts.ConfigMapKey] = id
if cm.Data[consts.ClusterIDConfigMapKey] != id {
cm.Data[consts.ClusterIDConfigMapKey] = id
_, err := cId.client.CoreV1().ConfigMaps(namespace).Update(context.TODO(), cm, metav1.UpdateOptions{})
return err
}
Expand All @@ -197,7 +197,7 @@ func (cId *ClusterIDImpl) saveToConfigMap(id, namespace string) error {

// updateClusterID updates the clusterid values.
func (cId *ClusterIDImpl) updateClusterID(obj interface{}) {
tmp := obj.(*v1.ConfigMap).Data[consts.ClusterIDconfigMapName]
tmp := obj.(*v1.ConfigMap).Data[consts.ClusterIDConfigMapKey]
cId.m.RLock()
curr := cId.id
if curr != tmp {
Expand Down
15 changes: 10 additions & 5 deletions pkg/consts/clusterid.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package consts

const (
ClusterIDconfigMapName = "cluster-id"
MasterLabel = "node-role.kubernetes.io/master"
ServiceAccount = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
ConfigMapKey = "cluster-id"
ClusterIDLabelName = "clusterID"
// ClusterIDConfigMapName is the name of the configmap where the cluster-id is stored.
ClusterIDConfigMapName = "cluster-id"
// MasterLabel contains the label used to identify the master nodes.
MasterLabel = "node-role.kubernetes.io/master"
// ServiceAccountNamespacePath contains the path where the namespace is stored in the serviceaccount volume mount.
ServiceAccountNamespacePath = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
// ClusterIDLabelName is the name of the label key to use with Cluster ID.
ClusterIDLabelName = "cluster-id"
// ClusterIDConfigMapKey is the key of the configmap where the cluster-id is stored.
ClusterIDConfigMapKey = "cluster-id"
)
2 changes: 1 addition & 1 deletion pkg/virtualKubelet/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

v1 "k8s.io/api/core/v1"

vke2e "github.com/liqotech/liqo/test/e2e"
vke2e "github.com/liqotech/liqo/pkg/virtualKubelet/test/e2e/framework"
)

const (
Expand Down
116 changes: 0 additions & 116 deletions test/e2e/deploy_app_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions test/e2e/e2e_test.go

This file was deleted.

60 changes: 0 additions & 60 deletions test/e2e/join_test.go

This file was deleted.

0 comments on commit 192351f

Please sign in to comment.