mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 06:02:18 +00:00
Convert private.sh test to Go and remove basic.sh and private.sh
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2015 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,13 @@ import (
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
func TestBasic(c *client.Client) bool {
|
||||
// A basic test to check the deployment of an image using
|
||||
// a replication controller. The image serves its hostname
|
||||
// which is checked for each replica.
|
||||
func TestBasicImage(c *client.Client, image string) bool {
|
||||
ns := api.NamespaceDefault
|
||||
// TODO(satnam6502): Generate a unique name to allow
|
||||
// parallel executions of this test.
|
||||
name := "my-hostname"
|
||||
replicas := 2
|
||||
|
||||
@@ -45,9 +50,13 @@ func TestBasic(c *client.Client) bool {
|
||||
glog.Infof("Found a straggler %s controller", name)
|
||||
// Delete any pods controlled by this replicaiton controller.
|
||||
cnt.Spec.Replicas = 0
|
||||
c.ReplicationControllers(ns).Update(&cnt)
|
||||
if _, err := c.ReplicationControllers(ns).Update(&cnt); err != nil {
|
||||
glog.Warningf("Failed to resize straggler controller to zero: %v", err)
|
||||
}
|
||||
// Delete the controller
|
||||
c.ReplicationControllers(ns).Delete(name)
|
||||
if err = c.ReplicationControllers(ns).Delete(name); err != nil {
|
||||
glog.Warningf("Failed to delete straggler replicatior controller: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -56,6 +65,7 @@ func TestBasic(c *client.Client) bool {
|
||||
// that serves its hostname on port 8080.
|
||||
// The source for the Docker containter kubernetes/serve_hostname is
|
||||
// in contrib/for-demos/serve_hostname
|
||||
glog.Infof("Creating replication controller %s", name)
|
||||
controller, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
@@ -73,7 +83,7 @@ func TestBasic(c *client.Client) bool {
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: name,
|
||||
Image: "kubernetes/serve_hostname",
|
||||
Image: image,
|
||||
Ports: []api.Port{{ContainerPort: 9376, HostPort: 8080}},
|
||||
},
|
||||
},
|
||||
@@ -152,3 +162,9 @@ func TestBasic(c *client.Client) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// TestBasic performs the TestBasicImage check with the
|
||||
// image kubernetes/serve_hostname
|
||||
func TestBasic(c *client.Client) bool {
|
||||
return TestBasicImage(c, "kubernetes/serve_hostname")
|
||||
}
|
||||
|
@@ -51,21 +51,23 @@ func outputTAPSummary(infoList []testInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
func RunE2ETests(authConfig, certDir, host, repoRoot string, testList []string) {
|
||||
testContext = testContextType{authConfig, certDir, host, repoRoot}
|
||||
// Run each Go end-to-end-test. This function assumes the
|
||||
// creation of a test cluster.
|
||||
func RunE2ETests(authConfig, certDir, host, repoRoot, provider string, testList []string) {
|
||||
testContext = testContextType{authConfig, certDir, host, repoRoot, provider}
|
||||
util.ReallyCrash = true
|
||||
util.InitLogs()
|
||||
defer util.FlushLogs()
|
||||
|
||||
// TODO: Associate a timeout with each test individually.
|
||||
go func() {
|
||||
defer util.FlushLogs()
|
||||
time.Sleep(5 * time.Minute)
|
||||
time.Sleep(10 * time.Minute)
|
||||
glog.Fatalf("This test has timed out. Cleanup not guaranteed.")
|
||||
}()
|
||||
|
||||
c := loadClientOrDie()
|
||||
|
||||
// Define the tests. Important: for a clean test grid, please keep ids for a test constant.
|
||||
tests := []testSpec{
|
||||
{TestKubernetesROService, "TestKubernetesROService", 1},
|
||||
{TestKubeletSendsEvent, "TestKubeletSendsEvent", 2},
|
||||
@@ -75,6 +77,7 @@ func RunE2ETests(authConfig, certDir, host, repoRoot string, testList []string)
|
||||
{TestClusterDNS, "TestClusterDNS", 6},
|
||||
{TestPodHasServiceEnvVars, "TestPodHasServiceEnvVars", 7},
|
||||
{TestBasic, "TestBasic", 8},
|
||||
{TestPrivate, "TestPrivate", 9},
|
||||
}
|
||||
|
||||
validTestNames := util.NewStringSet()
|
||||
|
35
test/e2e/private.go
Normal file
35
test/e2e/private.go
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2015 Google Inc. All rights reserved.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// A basic test to check the deployment of the
|
||||
// container.cloud.google.com/_b_k8s_test/serve_hostname image
|
||||
// with the TestBasicImage test. This test is only supported
|
||||
// for the providers GCE and GKE.
|
||||
func TestPrivate(c *client.Client) bool {
|
||||
if testContext.provider != "gce" && testContext.provider != "gke" {
|
||||
glog.Infof("Skipping test private which is only supported for proivders gce and gke (not %s)", testContext.provider)
|
||||
return true
|
||||
}
|
||||
glog.Info("Calling out to TestBasic")
|
||||
return TestBasicImage(c, "container.cloud.google.com/_b_k8s_test/serve_hostname")
|
||||
}
|
@@ -34,6 +34,7 @@ type testContextType struct {
|
||||
certDir string
|
||||
host string
|
||||
repoRoot string
|
||||
provider string
|
||||
}
|
||||
|
||||
var testContext testContextType
|
||||
|
Reference in New Issue
Block a user