Skip to content

Commit

Permalink
Add Config v0.90.0 API tests (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanchajanya authored Oct 3, 2023
1 parent 1da8552 commit 56fc188
Show file tree
Hide file tree
Showing 56 changed files with 6,547 additions and 2,158 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ build-compatibility-test-plugins: ## Builds all runtime compatibility test plugi
cd ./test/compatibility/testplugins/runtime-test-plugin-v0_11_6 && ${GO} mod tidy && GOOS=$(OS) GOARCH=$(ARCH) ${GO} build -o ../bin
cd ./test/compatibility/testplugins/runtime-test-plugin-v0_25_4 && ${GO} mod tidy && GOOS=$(OS) GOARCH=$(ARCH) ${GO} build -o ../bin
cd ./test/compatibility/testplugins/runtime-test-plugin-v0_28_0 && ${GO} mod tidy && GOOS=$(OS) GOARCH=$(ARCH) ${GO} build -o ../bin
cd ./test/compatibility/testplugins/runtime-test-plugin-v0_90 && ${GO} mod tidy && GOOS=$(OS) GOARCH=$(ARCH) ${GO} build -o ../bin
cd ./test/compatibility/testplugins/runtime-test-plugin-latest && ${GO} mod tidy && GOOS=$(OS) GOARCH=$(ARCH) ${GO} build -o ../bin

# The below command runs the compatibility tests using ginkgo and filter the logs as per regex and exit code with '0' representing success and non-zero values indicating test failures
Expand Down
2 changes: 2 additions & 0 deletions test/compatibility/core/api_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const (
Version0116 RuntimeVersion = "v0.11.6"
Version0254 RuntimeVersion = "v0.25.4"
Version0280 RuntimeVersion = "v0.28.0"
Version090 RuntimeVersion = "v0.90.0"
VersionLatest RuntimeVersion = "latest"
)

Expand All @@ -104,6 +105,7 @@ var SupportedRuntimeVersions = []RuntimeVersion{
Version0116,
Version0254,
Version0280,
Version090,
VersionLatest,
}

Expand Down
3 changes: 3 additions & 0 deletions test/compatibility/core/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
pluginV0116 = "runtime-test-plugin-v0_11_6"
pluginV0254 = "runtime-test-plugin-v0_25_4"
pluginV0280 = "runtime-test-plugin-v0_28_0"
pluginV090 = "runtime-test-plugin-v0_90"
pluginLatest = "runtime-test-plugin-latest"
)

Expand Down Expand Up @@ -52,6 +53,8 @@ func makeRuntimeTestPluginCommand(version RuntimeVersion) string {
return fmt.Sprintf("%v/%v test", pluginRoot, pluginV0254)
case Version0280:
return fmt.Sprintf("%v/%v test", pluginRoot, pluginV0280)
case Version090:
return fmt.Sprintf("%v/%v test", pluginRoot, pluginV090)
case VersionLatest:
return fmt.Sprintf("%v/%v test", pluginRoot, pluginLatest)
default:
Expand Down
13 changes: 13 additions & 0 deletions test/compatibility/core/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ func TestConstructTestPluginCmd(t *testing.T) {
pluginCmd: pluginLatest,
err: "",
},
{
version: Version090,
apis: []*API{
{
Name: SetContextAPI,
Version: Version090,
Arguments: map[APIArgumentType]interface{}{},
Output: nil,
},
},
pluginCmd: pluginV090,
err: "",
},
}

for _, tt := range tests {
Expand Down
34 changes: 33 additions & 1 deletion test/compatibility/core/parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,39 @@ func TestParseRuntimeAPIsFromFile(t *testing.T) {
apiYaml string
expectedAPIs []API
}{

{
`- name: SetContext
version: latest
arguments:
context: |
name: context-one
target: kubernetes
globalOpts:
endpoint: test-endpoint
setCurrent: false
output:
result: success
content: ""
`,
[]API{
{
Name: SetContextAPI,
Version: Version090,
Arguments: map[APIArgumentType]interface{}{
Context: `name: context-one
target: kubernetes
globalOpts:
endpoint: test-endpoint
`,
SetCurrent: false,
},
Output: &Output{
Result: Success,
Content: "",
},
},
},
},
{
`- name: SetContext
version: latest
Expand Down
7 changes: 7 additions & 0 deletions test/compatibility/core/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ func TestValidRuntimeVersion(t *testing.T) {
assert.Equal(t, true, actual)
}

func TestValidRuntimeVersionV090(t *testing.T) {
version090 := &RuntimeAPIVersion{RuntimeVersion: "v0.90.0"}
actual, err := version090.Validate()
assert.Nil(t, err)
assert.Equal(t, true, actual)
}

func TestInvalidRuntimeVersion(t *testing.T) {
version101 := &RuntimeAPIVersion{RuntimeVersion: "v1.0.1"}
actual, err := version101.Validate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const (
Version0116 RuntimeVersion = "v0.11.6"
Version0254 = "v0.25.4"
Version0280 = "v0.28.0"
Version090 = "v0.90.0"
VersionLatest = "latest"
)

Expand Down
1 change: 1 addition & 0 deletions test/compatibility/docs/cross-version-api-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ const (
Version0110 RuntimeVersion = "v0.11.0"
Version0250 RuntimeVersion = "v0.25.0"
Version0280 RuntimeVersion = "v0.28.0"
Version090 RuntimeVersion = "v0.90.0"
VersionLatest RuntimeVersion = "latest"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ func TestNewSetCLIDiscoverySourceCommand(t *testing.T) {
cmd *core.Command
err string
}{
{
&SetCLIDiscoverySourceInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: core.Version090,
},
PluginDiscoveryOpts: &types.PluginDiscoveryOpts{
OCI: &types.OCIDiscoveryOpts{
Name: CompatibilityTestsSourceName,
Image: CompatibilityTestsSourceImage,
},
},
}, nil,
&core.Command{
APIs: []*core.API{
{
Name: core.SetCLIDiscoverySourceAPI,
Version: core.Version090,
Arguments: map[core.APIArgumentType]interface{}{
core.DiscoverySource: source,
},
Output: &core.Output{
ValidationStrategy: "",
Result: core.Success,
Content: "",
},
},
},
}, "",
},
{
&SetCLIDiscoverySourceInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
Expand Down Expand Up @@ -73,6 +102,40 @@ func TestNewGetCLIDiscoverySourceCommand(t *testing.T) {
cmd *core.Command
err string
}{
{
&GetCLIDiscoverySourceInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: core.Version090,
},
DiscoverySourceName: CompatibilityTestsSourceName,
}, &GetCLIDiscoverySourceOutputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: core.Version0280,
},
PluginDiscoveryOpts: &types.PluginDiscoveryOpts{
OCI: &types.OCIDiscoveryOpts{
Name: CompatibilityTestsSourceName,
Image: CompatibilityTestsSourceImage,
},
},
},
&core.Command{
APIs: []*core.API{
{
Name: core.GetCLIDiscoverySourceAPI,
Version: core.Version090,
Arguments: map[core.APIArgumentType]interface{}{
core.Name: CompatibilityTestsSourceName,
},
Output: &core.Output{
ValidationStrategy: "",
Result: core.Success,
Content: source,
},
},
},
}, "",
},
{
&GetCLIDiscoverySourceInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
Expand Down Expand Up @@ -150,6 +213,30 @@ func TestNewDeleteCLIDiscoverySourceCommand(t *testing.T) {
},
}, "",
},
{
&DeleteCLIDiscoverySourceInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: core.Version090,
},
DiscoverySourceName: CompatibilityTestsSourceName,
}, nil,
&core.Command{
APIs: []*core.API{
{
Name: core.DeleteCLIDiscoverySourceAPI,
Version: core.Version090,
Arguments: map[core.APIArgumentType]interface{}{
core.Name: CompatibilityTestsSourceName,
},
Output: &core.Output{
ValidationStrategy: "",
Result: core.Success,
Content: "",
},
},
},
}, "",
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func DefaultCLIDiscoverySourcePerVersion(version core.RuntimeVersion) *CfgCLIDis
WithOCIDiscoveryOpts(oci),
WithContextType(types.CtxTypeTMC),
)
case core.VersionLatest, core.Version0280:
case core.VersionLatest, core.Version090, core.Version0280:
return NewCfgCLIDiscoverySourcesArgs(
WithOCIDiscoveryOpts(oci),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (opts *SetCLIDiscoverySourceInputOptions) Validate() (bool, error) {
}

switch opts.RuntimeVersion {
case core.VersionLatest, core.Version0280, core.Version0116:
case core.VersionLatest, core.Version090, core.Version0280, core.Version0116:
err = opts.PluginDiscoveryOpts.ValidPluginDiscovery()
if err != nil {
return false, err
Expand Down Expand Up @@ -65,7 +65,7 @@ func (opts *GetCLIDiscoverySourceOutputOptions) Validate() (bool, error) {
}

switch opts.RuntimeVersion {
case core.VersionLatest, core.Version0280, core.Version0116:
case core.VersionLatest, core.Version090, core.Version0280, core.Version0116:
err = opts.PluginDiscoveryOpts.ValidPluginDiscovery()
if err != nil {
return false, err
Expand Down
Loading

0 comments on commit 56fc188

Please sign in to comment.