@@ -482,6 +482,49 @@ var _ = Describe("Kubectl client", func() {
482482 }
483483 })
484484 })
485+
486+ Describe ("Kubectl run" , func () {
487+ var nsFlag string
488+ var rcName string
489+
490+ BeforeEach (func () {
491+ nsFlag = fmt .Sprintf ("--namespace=%v" , ns )
492+ rcName = "e2e-test-nginx-rc"
493+ })
494+
495+ AfterEach (func () {
496+ runKubectl ("stop" , "rc" , rcName , nsFlag )
497+ })
498+
499+ It ("should create an rc from an image" , func () {
500+ image := "nginx"
501+
502+ By ("running the image " + image )
503+ runKubectl ("run" , rcName , "--image=" + image , nsFlag )
504+ By ("verifying the rc " + rcName + " was created" )
505+ rc , err := c .ReplicationControllers (ns ).Get (rcName )
506+ if err != nil {
507+ Failf ("Failed getting rc %s: %v" , rcName , err )
508+ }
509+ containers := rc .Spec .Template .Spec .Containers
510+ if containers == nil || len (containers ) != 1 || containers [0 ].Image != image {
511+ Failf ("Failed creating rc %s for 1 pod with expected image %s" , rcName , image )
512+ }
513+
514+ By ("verifying the pod controlled by rc " + rcName + " was created" )
515+ label := labels .SelectorFromSet (labels .Set (map [string ]string {"run" : rcName }))
516+ podlist , err := waitForPodsWithLabel (c , ns , label )
517+ if err != nil {
518+ Failf ("Failed getting pod controlled by rc %s: %v" , rcName , err )
519+ }
520+ pods := podlist .Items
521+ if pods == nil || len (pods ) != 1 || len (pods [0 ].Spec .Containers ) != 1 || pods [0 ].Spec .Containers [0 ].Image != image {
522+ runKubectl ("get" , "pods" , "-L" , "run" , nsFlag )
523+ Failf ("Failed creating 1 pod with expected image %s. Number of pods = %v" , image , len (pods ))
524+ }
525+ })
526+ })
527+
485528})
486529
487530// Checks whether the output split by line contains the required elements.
0 commit comments