本文整理汇总了Golang中github.com/openshift/origin/pkg/api/graph/test.BuildGraph函数的典型用法代码示例。如果您正苦于以下问题:Golang BuildGraph函数的具体用法?Golang BuildGraph怎么用?Golang BuildGraph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BuildGraph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMissingPortMapping
func TestMissingPortMapping(t *testing.T) {
// Multiple service ports - no route port specified
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/missing-route-port.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
routeedges.AddAllRouteEdges(g)
markers := FindMissingPortMapping(g)
if expected, got := 1, len(markers); expected != got {
t.Fatalf("expected %d markers, got %d", expected, got)
}
if expected, got := MissingRoutePortWarning, markers[0].Key; expected != got {
t.Fatalf("expected %s marker key, got %s", expected, got)
}
// Dangling route
g, _, err = osgraphtest.BuildGraph("../../../api/graph/test/lonely-route.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
routeedges.AddAllRouteEdges(g)
markers = FindMissingPortMapping(g)
if expected, got := 1, len(markers); expected != got {
t.Fatalf("expected %d markers, got %d", expected, got)
}
if expected, got := MissingServiceWarning, markers[0].Key; expected != got {
t.Fatalf("expected %s marker key, got %s", expected, got)
}
}
示例2: TestUnpushableBuild
func TestUnpushableBuild(t *testing.T) {
// Unconfigured internal registry
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
markers := FindUnpushableBuildConfigs(g, osgraph.DefaultNamer)
if e, a := 2, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if got, expected := markers[0].Key, MissingRequiredRegistryErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
actualBC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedBC1 := g.Find(osgraph.UniqueName("BuildConfig|example/ruby-hello-world"))
expectedBC2 := g.Find(osgraph.UniqueName("BuildConfig|example/ruby-hello-world-2"))
if e1, e2, a := expectedBC1.ID(), expectedBC2.ID(), actualBC.ID(); e1 != a && e2 != a {
t.Errorf("expected either %v or %v, got %v", e1, e2, a)
}
actualIST := markers[0].RelatedNodes[0]
expectedIST := g.Find(osgraph.UniqueName("ImageStreamTag|example/ruby-hello-world:latest"))
if e, a := expectedIST.ID(), actualIST.ID(); e != a {
t.Errorf("expected %v, got %v: \n%v", e, a, g)
}
// Missing image stream
g, _, err = osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build-2.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
markers = FindUnpushableBuildConfigs(g, osgraph.DefaultNamer)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if got, expected := markers[0].Key, MissingOutputImageStreamErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
}
示例3: TestBareRCGroup
func TestBareRCGroup(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bare-rc.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
kubeedges.AddAllExposedPodEdges(g)
kubeedges.AddAllManagedByRCPodEdges(g)
coveredNodes := IntSet{}
serviceGroups, coveredByServiceGroups := AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServiceGroups.List()...)
bareRCs, coveredByRCs := AllReplicationControllers(g, coveredNodes)
coveredNodes.Insert(coveredByRCs.List()...)
if e, a := 1, len(serviceGroups); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareRCs); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例4: TestBareDCGroup
func TestBareDCGroup(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bare-dc.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
buildedges.AddAllInputOutputEdges(g)
deployedges.AddAllTriggerEdges(g)
coveredNodes := IntSet{}
serviceGroups, coveredByServiceGroups := AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServiceGroups.List()...)
bareDCPipelines, coveredByDCs := AllDeploymentConfigPipelines(g, coveredNodes)
coveredNodes.Insert(coveredByDCs.List()...)
bareBCPipelines, coveredByBCs := AllImagePipelinesFromBuildConfig(g, coveredNodes)
coveredNodes.Insert(coveredByBCs.List()...)
if e, a := 0, len(serviceGroups); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareDCPipelines); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 0, len(bareBCPipelines); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareDCPipelines[0].Images); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例5: TestUnpushableBuild
func TestUnpushableBuild(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
markers := FindUnpushableBuildConfigs(g)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
actualBC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedBC := g.Find(osgraph.UniqueName("BuildConfig|/ruby-hello-world"))
if e, a := expectedBC.ID(), actualBC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualIST := markers[0].RelatedNodes[0]
expectedIST := g.Find(osgraph.UniqueName("ImageStreamTag|/ruby-hello-world:latest"))
if e, a := expectedIST.ID(), actualIST.ID(); e != a {
t.Errorf("expected %v, got %v: \n%v", e, a, g)
}
}
示例6: TestMissingSecrets
func TestMissingSecrets(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bad_secret_refs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
markers := FindMissingSecrets(g, osgraph.DefaultNamer)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
actualDC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedDC := g.Find(osgraph.UniqueName("DeploymentConfig|/docker-nfs-server"))
if e, a := expectedDC.ID(), actualDC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualSecret := markers[0].RelatedNodes[0]
expectedSecret := g.Find(osgraph.UniqueName("Secret|/missing-secret"))
if e, a := expectedSecret.ID(), actualSecret.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例7: TestCheckMountedSecrets
func TestCheckMountedSecrets(t *testing.T) {
g, objs, err := osgraphtest.BuildGraph("../../../api/graph/test/bad_secret_refs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
var dc *deployapi.DeploymentConfig
for _, obj := range objs {
if currDC, ok := obj.(*deployapi.DeploymentConfig); ok {
if dc != nil {
t.Errorf("got more than one dc: %v", currDC)
}
dc = currDC
}
}
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
dcNode := g.Find(deploygraph.DeploymentConfigNodeName(dc))
unmountable, missing := CheckMountedSecrets(g, dcNode.(*deploygraph.DeploymentConfigNode))
if e, a := 2, len(unmountable); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if e, a := 1, len(missing); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if e, a := "missing-secret", missing[0].Name; e != a {
t.Fatalf("expected %v, got %v", e, a)
}
}
示例8: TestPendingImageStreamTag
func TestPendingImageStreamTag(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
buildedges.AddAllBuildEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
// Drop the build to showcase a TagNotAvailable warning (should happen when no
// build is new, pending, or running currently)
nodeFn := osgraph.NodesOfKind(imagegraph.ImageStreamTagNodeKind, buildgraph.BuildConfigNodeKind)
edgeFn := osgraph.EdgesOfKind(buildedges.BuildInputImageEdgeKind, buildedges.BuildOutputEdgeKind)
g = g.Subgraph(nodeFn, edgeFn)
markers := FindPendingTags(g, osgraph.DefaultNamer)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if got, expected := markers[0].Key, TagNotAvailableWarning; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
}
示例9: TestBuildConfigNoOutput
func TestBuildConfigNoOutput(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bc-missing-output.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
// we were getting go panics with nil refs cause output destinations are not required for BuildConfigs
buildedges.AddAllInputOutputEdges(g)
}
示例10: TestDuelingRC
func TestDuelingRC(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/dueling-rcs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllManagedByControllerPodEdges(g)
markers := FindDuelingReplicationControllers(g, osgraph.DefaultNamer)
if e, a := 2, len(markers); e != a {
t.Errorf("expected %v, got %v", e, a)
}
expectedRC1 := g.Find(osgraph.UniqueName("ReplicationController|/rc-1"))
expectedRC2 := g.Find(osgraph.UniqueName("ReplicationController|/rc-2"))
found1 := false
found2 := false
for i := 0; i < 2; i++ {
actualPod := osgraph.GetTopLevelContainerNode(g, markers[i].RelatedNodes[0])
expectedPod := g.Find(osgraph.UniqueName("Pod|/conflicted-pod"))
if e, a := expectedPod.ID(), actualPod.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualOtherRC := osgraph.GetTopLevelContainerNode(g, markers[i].RelatedNodes[1])
actualRC := markers[i].Node
if e, a := expectedRC1.ID(), actualRC.ID(); e == a {
found1 = true
expectedOtherRC := expectedRC2
if e, a := expectedOtherRC.ID(), actualOtherRC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
if e, a := expectedRC2.ID(), actualRC.ID(); e == a {
found2 = true
expectedOtherRC := expectedRC1
if e, a := expectedOtherRC.ID(), actualOtherRC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
}
if !found1 {
t.Errorf("expected %v, got %v", expectedRC1, markers)
}
if !found2 {
t.Errorf("expected %v, got %v", expectedRC2, markers)
}
}
示例11: TestCircularDeps
func TestCircularDeps(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/circular.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
if len(FindCircularBuilds(g, osgraph.DefaultNamer)) != 1 {
t.Fatalf("expected having circular dependencies")
}
not, _, err := osgraphtest.BuildGraph("../../../api/graph/test/circular-not.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(not)
if len(FindCircularBuilds(not, osgraph.DefaultNamer)) != 0 {
t.Fatalf("expected not having circular dependencies")
}
}
示例12: TestPushableBuild
func TestPushableBuild(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/pushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
if e, a := 0, len(FindUnpushableBuildConfigs(g, osgraph.DefaultNamer)); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例13: TestPushableBuild
func TestPushableBuild(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/pushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
if e, a := false, hasUnresolvedImageStreamTag(g); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例14: TestRestartingPodWarning
func TestRestartingPodWarning(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/restarting-pod.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
markers := FindRestartingPods(g)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if e, a := RestartingPodWarning, markers[0].Key; e != a {
t.Fatalf("expected %v, got %v", e, a)
}
}
示例15: TestImageStreamPresent
func TestImageStreamPresent(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/prereq-image-present.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
if e, a := 0, len(FindMissingInputImageStreams(g, osgraph.DefaultNamer)); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}