func TestHPADCEdges(t *testing.T) { hpa := &autoscaling.HorizontalPodAutoscaler{} hpa.Namespace = "test-ns" hpa.Name = "test-hpa" hpa.Spec = autoscaling.HorizontalPodAutoscalerSpec{ ScaleTargetRef: autoscaling.CrossVersionObjectReference{ Name: "test-dc", Kind: "DeploymentConfig", }, } dc := &deployapi.DeploymentConfig{} dc.Name = "test-dc" dc.Namespace = "test-ns" g := osgraph.New() hpaNode := kubegraph.EnsureHorizontalPodAutoscalerNode(g, hpa) dcNode := deploygraph.EnsureDeploymentConfigNode(g, dc) AddHPAScaleRefEdges(g) if edge := g.Edge(hpaNode, dcNode); edge == nil { t.Fatalf("edge between HPA and DC missing") } else { if !g.EdgeKinds(edge).Has(ScalingEdgeKind) { t.Errorf("expected edge to have kind %v, got %v", ScalingEdgeKind, edge) } } }
func (l *horizontalPodAutoscalerLoader) AddToGraph(g osgraph.Graph) error { for i := range l.items { kubegraph.EnsureHorizontalPodAutoscalerNode(g, &l.items[i]) } return nil }
func TestHPARCEdges(t *testing.T) { hpa := &autoscaling.HorizontalPodAutoscaler{} hpa.Namespace = "test-ns" hpa.Name = "test-hpa" hpa.Spec = autoscaling.HorizontalPodAutoscalerSpec{ ScaleTargetRef: autoscaling.CrossVersionObjectReference{ Name: "test-rc", Kind: "ReplicationController", }, } rc := &kapi.ReplicationController{} rc.Name = "test-rc" rc.Namespace = "test-ns" g := osgraph.New() hpaNode := kubegraph.EnsureHorizontalPodAutoscalerNode(g, hpa) rcNode := kubegraph.EnsureReplicationControllerNode(g, rc) AddHPAScaleRefEdges(g) if edge := g.Edge(hpaNode, rcNode); edge == nil { t.Fatalf("edge between HPA and RC missing") } else { if !g.EdgeKinds(edge).Has(ScalingEdgeKind) { t.Errorf("expected edge to have kind %v, got %v", ScalingEdgeKind, edge) } } }