本文整理汇总了Golang中k8s/io/kubernetes/test/e2e_node.CreateTestArchive函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateTestArchive函数的具体用法?Golang CreateTestArchive怎么用?Golang CreateTestArchive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateTestArchive函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
// Setup coloring
stat, _ := os.Stdout.Stat()
useColor := (stat.Mode() & os.ModeCharDevice) != 0
blue := ""
noColour := ""
if useColor {
blue = "\033[0;34m"
noColour = "\033[0m"
}
flag.Parse()
if *hosts == "" {
fmt.Printf("Must specific --hosts flag")
}
archive := e2e_node.CreateTestArchive()
defer os.Remove(archive)
results := make(chan *TestResult)
hs := strings.Split(*hosts, ",")
for _, h := range hs {
fmt.Printf("Starting tests on host %s.", h)
go func(host string) {
output, err := e2e_node.RunRemote(archive, host)
results <- &TestResult{
output: output,
err: err,
host: host,
}
}(h)
}
// Wait for all tests to complete and emit the results
errCount := 0
for i := 0; i < len(hs); i++ {
tr := <-results
host := tr.host
fmt.Printf("%s================================================================%s\n", blue, noColour)
if tr.err != nil {
errCount++
fmt.Printf("Failure Finished Host %s Test Suite %s %v\n", host, tr.output, tr.err)
} else {
fmt.Printf("Success Finished Host %s Test Suite %s\n", host, tr.output)
}
fmt.Printf("%s================================================================%s\n", blue, noColour)
}
// Set the exit code if there were failures
if errCount > 0 {
fmt.Printf("Failure: %d errors encountered.", errCount)
os.Exit(1)
}
}
示例2: main
func main() {
flag.Parse()
rand.Seed(time.Now().UTC().UnixNano())
if *buildOnly {
// Build the archive and exit
e2e_node.CreateTestArchive()
return
}
if *hosts == "" && *images == "" {
glog.Fatalf("Must specify one of --images or --hosts flag.")
}
if *images != "" && *zone == "" {
glog.Fatal("Must specify --zone flag")
}
if *images != "" && *project == "" {
glog.Fatal("Must specify --project flag")
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
}
// Setup coloring
stat, _ := os.Stdout.Stat()
useColor := (stat.Mode() & os.ModeCharDevice) != 0
blue := ""
noColour := ""
if useColor {
blue = "\033[0;34m"
noColour = "\033[0m"
}
archive := e2e_node.CreateTestArchive()
defer os.Remove(archive)
results := make(chan *TestResult)
running := 0
if *images != "" {
// Setup the gce client for provisioning instances
// Getting credentials on gce jenkins is flaky, so try a couple times
var err error
for i := 0; i < 10; i++ {
var client *http.Client
client, err = google.DefaultClient(oauth2.NoContext, compute.ComputeScope)
if err != nil {
continue
}
computeService, err = compute.New(client)
if err != nil {
continue
}
time.Sleep(time.Second * 6)
}
if err != nil {
glog.Fatalf("Unable to create gcloud compute service using defaults. Make sure you are authenticated. %v", err)
}
for _, image := range strings.Split(*images, ",") {
running++
fmt.Printf("Initializing e2e tests using image %s.\n", image)
go func(image string) { results <- testImage(image, archive) }(image)
}
}
if *hosts != "" {
for _, host := range strings.Split(*hosts, ",") {
fmt.Printf("Initializing e2e tests using host %s.\n", host)
running++
go func(host string) {
results <- testHost(host, archive, *cleanup)
}(host)
}
}
// Wait for all tests to complete and emit the results
errCount := 0
for i := 0; i < running; i++ {
tr := <-results
host := tr.host
fmt.Printf("%s================================================================%s\n", blue, noColour)
if tr.err != nil {
errCount++
fmt.Printf("Failure Finished Host %s Test Suite\n%s\n%v\n", host, tr.output, tr.err)
} else {
fmt.Printf("Success Finished Host %s Test Suite\n%s\n", host, tr.output)
}
fmt.Printf("%s================================================================%s\n", blue, noColour)
}
// Set the exit code if there were failures
if errCount > 0 {
fmt.Printf("Failure: %d errors encountered.", errCount)
os.Exit(1)
}
}
示例3: main
func main() {
flag.Parse()
rand.Seed(time.Now().UTC().UnixNano())
if *buildOnly {
// Build the archive and exit
e2e_node.CreateTestArchive()
return
}
if *hosts == "" && *imageConfigFile == "" && *images == "" {
glog.Fatalf("Must specify one of --image-config-file, --hosts, --images.")
}
gceImages := &ImageConfig{
Images: make(map[string]GCEImage),
}
if *imageConfigFile != "" {
// parse images
imageConfigData, err := ioutil.ReadFile(*imageConfigFile)
if err != nil {
glog.Fatalf("Could not read image config file provided: %v", err)
}
err = yaml.Unmarshal(imageConfigData, gceImages)
if err != nil {
glog.Fatalf("Could not parse image config file: %v", err)
}
}
// Allow users to specify additional images via cli flags for local testing
// convenience; merge in with config file
if *images != "" {
if *imageProject == "" {
glog.Fatal("Must specify --image-project if you specify --images")
}
cliImages := strings.Split(*images, ",")
for _, img := range cliImages {
gceImages.Images[img] = GCEImage{
Image: img,
Project: *imageProject,
}
}
}
if len(gceImages.Images) != 0 && *zone == "" {
glog.Fatal("Must specify --zone flag")
}
for shortName, image := range gceImages.Images {
if image.Project == "" {
glog.Fatalf("Invalid config for %v; must specify a project", shortName)
}
}
if len(gceImages.Images) != 0 {
if *project == "" {
glog.Fatal("Must specify --project flag to launch images into")
}
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
}
// Setup coloring
stat, _ := os.Stdout.Stat()
useColor := (stat.Mode() & os.ModeCharDevice) != 0
blue := ""
noColour := ""
if useColor {
blue = "\033[0;34m"
noColour = "\033[0m"
}
go arc.getArchive()
defer arc.deleteArchive()
var err error
computeService, err = getComputeClient()
if err != nil {
glog.Fatalf("Unable to create gcloud compute service using defaults. Make sure you are authenticated. %v", err)
}
results := make(chan *TestResult)
running := 0
for shortName, image := range gceImages.Images {
running++
fmt.Printf("Initializing e2e tests using image %s.\n", shortName)
go func(image, imageProject string, junitFileNum int) {
results <- testImage(image, imageProject, junitFileNum)
}(image.Image, image.Project, running)
}
if *hosts != "" {
for _, host := range strings.Split(*hosts, ",") {
fmt.Printf("Initializing e2e tests using host %s.\n", host)
running++
go func(host string, junitFileNum int) {
results <- testHost(host, *cleanup, junitFileNum, *setupNode)
}(host, running)
}
}
// Wait for all tests to complete and emit the results
errCount := 0
exitOk := true
//.........这里部分代码省略.........
示例4: getArchive
func (a *Archive) getArchive() (string, error) {
a.Do(func() { a.path, a.err = e2e_node.CreateTestArchive() })
return a.path, a.err
}
示例5: main
func main() {
flag.Parse()
rand.Seed(time.Now().UTC().UnixNano())
if *buildOnly {
// Build the archive and exit
e2e_node.CreateTestArchive()
return
}
if *hosts == "" && *images == "" {
glog.Fatalf("Must specify one of --images or --hosts flag.")
}
if *images != "" && *zone == "" {
glog.Fatal("Must specify --zone flag")
}
if *images != "" {
if *imageProject == "" {
glog.Fatal("Must specify --image-project flag")
}
if *project == "" {
glog.Fatal("Must specify --project flag")
}
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
}
// Setup coloring
stat, _ := os.Stdout.Stat()
useColor := (stat.Mode() & os.ModeCharDevice) != 0
blue := ""
noColour := ""
if useColor {
blue = "\033[0;34m"
noColour = "\033[0m"
}
go arc.getArchive()
defer arc.deleteArchive()
var err error
computeService, err = getComputeClient()
if err != nil {
glog.Fatalf("Unable to create gcloud compute service using defaults. Make sure you are authenticated. %v", err)
}
results := make(chan *TestResult)
running := 0
if *images != "" {
for _, image := range strings.Split(*images, ",") {
running++
fmt.Printf("Initializing e2e tests using image %s.\n", image)
go func(image string, junitFileNum int) { results <- testImage(image, junitFileNum) }(image, running)
}
}
if *hosts != "" {
for _, host := range strings.Split(*hosts, ",") {
fmt.Printf("Initializing e2e tests using host %s.\n", host)
running++
go func(host string, junitFileNum int) {
results <- testHost(host, *cleanup, junitFileNum, *setupNode)
}(host, running)
}
}
// Wait for all tests to complete and emit the results
errCount := 0
exitOk := true
for i := 0; i < running; i++ {
tr := <-results
host := tr.host
fmt.Printf("%s================================================================%s\n", blue, noColour)
if tr.err != nil {
errCount++
fmt.Printf("Failure Finished Host %s Test Suite\n%s\n%v\n", host, tr.output, tr.err)
} else {
fmt.Printf("Success Finished Host %s Test Suite\n%s\n", host, tr.output)
}
exitOk = exitOk && tr.exitOk
fmt.Printf("%s================================================================%s\n", blue, noColour)
}
// Set the exit code if there were failures
if !exitOk {
fmt.Printf("Failure: %d errors encountered.", errCount)
os.Exit(1)
}
}