mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
kubetestgen -> kubeconform
This commit is contained in:
parent
77edd42619
commit
074a676dbc
@ -33,8 +33,7 @@ filegroup(
|
|||||||
srcs = [
|
srcs = [
|
||||||
":package-srcs",
|
":package-srcs",
|
||||||
"//test/conformance/behaviors:all-srcs",
|
"//test/conformance/behaviors:all-srcs",
|
||||||
"//test/conformance/kubetestgen:all-srcs",
|
"//test/conformance/kubeconform:all-srcs",
|
||||||
"//test/conformance/kubetestlink:all-srcs",
|
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
@ -2,8 +2,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["kubetestgen.go"],
|
srcs = [
|
||||||
importpath = "k8s.io/kubernetes/test/conformance/kubetestgen",
|
"gen.go",
|
||||||
|
"kubeconform.go",
|
||||||
|
"link.go",
|
||||||
|
],
|
||||||
|
importpath = "k8s.io/kubernetes/test/conformance/kubeconform",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//test/conformance/behaviors:go_default_library",
|
"//test/conformance/behaviors:go_default_library",
|
||||||
@ -29,7 +33,7 @@ filegroup(
|
|||||||
)
|
)
|
||||||
|
|
||||||
go_binary(
|
go_binary(
|
||||||
name = "kubetestgen",
|
name = "kubeconform",
|
||||||
data = ["//api/openapi-spec"],
|
data = ["//api/openapi-spec"],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
@ -30,29 +29,10 @@ import (
|
|||||||
"k8s.io/kubernetes/test/conformance/behaviors"
|
"k8s.io/kubernetes/test/conformance/behaviors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type options struct {
|
|
||||||
schemaPath string
|
|
||||||
resource string
|
|
||||||
area string
|
|
||||||
behaviorsDir string
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseFlags() *options {
|
|
||||||
o := &options{}
|
|
||||||
flag.StringVar(&o.schemaPath, "schema", "", "Path to the OpenAPI schema")
|
|
||||||
flag.StringVar(&o.resource, "resource", ".*", "Resource name")
|
|
||||||
flag.StringVar(&o.area, "area", "default", "Area name to use")
|
|
||||||
flag.StringVar(&o.behaviorsDir, "dir", "../behaviors/", "Path to the behaviors directory")
|
|
||||||
flag.Parse()
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
var defMap map[string]analysis.SchemaRef
|
var defMap map[string]analysis.SchemaRef
|
||||||
|
|
||||||
func main() {
|
func gen(o *options) {
|
||||||
defMap = make(map[string]analysis.SchemaRef)
|
defMap = make(map[string]analysis.SchemaRef)
|
||||||
o := parseFlags()
|
|
||||||
|
|
||||||
d, err := loads.JSONSpec(o.schemaPath)
|
d, err := loads.JSONSpec(o.schemaPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: %s\n", err.Error())
|
fmt.Printf("ERROR: %s\n", err.Error())
|
64
test/conformance/kubeconform/kubeconform.go
Normal file
64
test/conformance/kubeconform/kubeconform.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 The Kubernetes Authors.
|
||||||
|
|
||||||
|
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 main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type options struct {
|
||||||
|
// Flags only used for generating behaviors
|
||||||
|
schemaPath string
|
||||||
|
resource string
|
||||||
|
area string
|
||||||
|
|
||||||
|
// Flags only used for linking behaviors
|
||||||
|
testdata string
|
||||||
|
listMissing bool
|
||||||
|
|
||||||
|
// Flags shared between CLI tools
|
||||||
|
behaviorsDir string
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseFlags() *options {
|
||||||
|
o := &options{}
|
||||||
|
|
||||||
|
flag.StringVar(&o.schemaPath, "schema", "", "Path to the OpenAPI schema")
|
||||||
|
flag.StringVar(&o.resource, "resource", ".*", "Resource name")
|
||||||
|
flag.StringVar(&o.area, "area", "default", "Area name to use")
|
||||||
|
|
||||||
|
flag.StringVar(&o.testdata, "testdata", "../testdata/conformance.yaml", "YAML file containing test linkage data")
|
||||||
|
flag.BoolVar(&o.listMissing, "missing", true, "Only list behaviors missing tests")
|
||||||
|
|
||||||
|
flag.StringVar(&o.behaviorsDir, "dir", "../behaviors", "Path to the behaviors directory")
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
o := parseFlags()
|
||||||
|
action := flag.Arg(0)
|
||||||
|
if action == "gen" {
|
||||||
|
gen(o)
|
||||||
|
} else if action == "link" {
|
||||||
|
link(o)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Unknown argument %s\n", action)
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -29,24 +28,7 @@ import (
|
|||||||
"k8s.io/kubernetes/test/conformance/behaviors"
|
"k8s.io/kubernetes/test/conformance/behaviors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type options struct {
|
func link(o *options) {
|
||||||
behaviorsDir string
|
|
||||||
testdata string
|
|
||||||
listMissing bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseFlags() *options {
|
|
||||||
o := &options{}
|
|
||||||
flag.StringVar(&o.behaviorsDir, "behaviors", "../behaviors/", "Path to the behaviors directory")
|
|
||||||
flag.StringVar(&o.testdata, "testdata", "../testdata/conformance.yaml", "YAML file containing test linkage data")
|
|
||||||
flag.BoolVar(&o.listMissing, "missing", true, "Only list behaviors missing tests")
|
|
||||||
flag.Parse()
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
o := parseFlags()
|
|
||||||
|
|
||||||
var behaviorFiles []string
|
var behaviorFiles []string
|
||||||
behaviorsMapping := make(map[string][]string)
|
behaviorsMapping := make(map[string][]string)
|
||||||
var conformanceDataList []behaviors.ConformanceData
|
var conformanceDataList []behaviors.ConformanceData
|
||||||
@ -66,6 +48,7 @@ func main() {
|
|||||||
fmt.Printf("%v", err)
|
fmt.Printf("%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
fmt.Printf("%v", behaviorFiles)
|
||||||
|
|
||||||
for _, behaviorFile := range behaviorFiles {
|
for _, behaviorFile := range behaviorFiles {
|
||||||
var suite behaviors.Suite
|
var suite behaviors.Suite
|
||||||
@ -87,6 +70,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conformanceYaml, err := ioutil.ReadFile(o.testdata)
|
conformanceYaml, err := ioutil.ReadFile(o.testdata)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = yaml.Unmarshal(conformanceYaml, &conformanceDataList)
|
err = yaml.Unmarshal(conformanceYaml, &conformanceDataList)
|
||||||
if err != nil {
|
if err != nil {
|
@ -1,32 +0,0 @@
|
|||||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["kubetestlink.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/test/conformance/kubetestlink",
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
deps = [
|
|
||||||
"//test/conformance/behaviors:go_default_library",
|
|
||||||
"//vendor/gopkg.in/yaml.v2:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_binary(
|
|
||||||
name = "kubetestlink",
|
|
||||||
embed = [":go_default_library"],
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user