forked from antrea-io/antrea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wenqi Qiu <[email protected]>
- Loading branch information
Showing
3 changed files
with
27 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,14 @@ | ||
package framework | ||
|
||
import ( | ||
utils2 "antrea.io/antrea/test/performance/framework/utils" | ||
"fmt" | ||
corev1 "k8s.io/api/core/v1" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRenderService(t *testing.T) { | ||
var err error | ||
defer func() { | ||
fmt.Println(err) | ||
}() | ||
obj, err := utils2.ReadYamlFile("../../assets/service/service.yaml") | ||
if err != nil { | ||
err = fmt.Errorf("error reading Service template: %+v", err) | ||
return | ||
} | ||
|
||
fmt.Println(obj, "0000") | ||
|
||
service, ok := obj.(*corev1.Service) | ||
if !ok { | ||
err = fmt.Errorf("error converting to Unstructured: %+v", err) | ||
return | ||
} | ||
fmt.Println(service) | ||
obj, err := unmarshallService("../assets/service/service.yaml") | ||
assert.NoError(t, err, "error reading Service template") | ||
fmt.Println(obj) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"k8s.io/klog/v2" | ||
|
||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/serializer/yaml" | ||
) | ||
|
||
func ReadYamlFile(yamlFile string) (runtime.Object, error) { | ||
klog.InfoS("ReadYamlFile", "yamlFile", yamlFile) | ||
podBytes, err := ioutil.ReadFile(yamlFile) | ||
if err != nil { | ||
return nil, fmt.Errorf("error reading YAML file: %+v", err) | ||
} | ||
|
||
decoder := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme) | ||
obj, _, err := decoder.Decode(podBytes, nil, nil) | ||
if err != nil { | ||
return nil, fmt.Errorf("error decoding YAML file: %+v", err) | ||
} | ||
return obj, nil | ||
} |