Skip to content

Commit

Permalink
refactor test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanchajanya committed Mar 22, 2023
1 parent 7aa1be8 commit 32093c4
Show file tree
Hide file tree
Showing 11 changed files with 1,213 additions and 1,233 deletions.
5 changes: 2 additions & 3 deletions test/compatibility/core/api_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Package core contains compatibility testing framework core types and functions
package core

// RuntimeAPIName describes all the runtime api functions
// RuntimeAPIName describes all the Runtime APIs
type RuntimeAPIName string

const (
Expand All @@ -28,7 +28,7 @@ const (
RemoveCurrentServerAPIName RuntimeAPIName = "RemoveCurrentServer"
)

// APIArgumentType describes all the arguments types for runtime api functions
// APIArgumentType describes all the arguments types required for Runtime APIs
type APIArgumentType string

const (
Expand Down Expand Up @@ -63,7 +63,6 @@ const (
Version0254 RuntimeVersion = "v0.25.4"
Version0280 RuntimeVersion = "v0.28.0"
VersionLatest RuntimeVersion = "latest"
Version100 RuntimeVersion = "v1.0.0"
)

// SupportedRuntimeVersions Current supported runtime library versions
Expand Down
398 changes: 55 additions & 343 deletions test/compatibility/framework/compatibilitytests/context/context_test.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

467 changes: 88 additions & 379 deletions test/compatibility/framework/compatibilitytests/server/server_test.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions test/compatibility/framework/validators/testcase_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ func ValidateAPIsOutput(apis []*core.API, stdout string) {

for _, api := range apis {
for _, log := range logs[api.Name] {
if log.APIResponse.ResponseType == core.StringResponse {
switch log.APIResponse.ResponseType {
case core.StringResponse:
actual := fmt.Sprintf("%v", log.APIResponse.ResponseBody)
expected := api.Output.Content
gomega.Expect(actual).To(gomega.Equal(expected))
} else if log.APIResponse.ResponseType == core.MapResponse {
case core.MapResponse:
actual := log.APIResponse.ResponseBody
// Convert string represented struct to map string interface
var expected map[string]interface{}
Expand All @@ -44,7 +45,7 @@ func ValidateAPIsOutput(apis []*core.API, stdout string) {
} else {
gomega.Expect(ValidateMaps(actual.(map[string]interface{}), expected)).To(gomega.Equal(true))
}
} else if log.APIResponse.ResponseType == core.ErrorResponse {
case core.ErrorResponse:
// Check for errors
actual := log.APIResponse.ResponseBody
expected := api.Output.Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ import (

// Route to runtime API method call based on passed command value
var apiHandlers = map[core.RuntimeAPIName]func(*core.API) *core.APIResponse{
// Context APIs
core.SetContextAPIName: triggerSetContextAPI,
core.GetContextAPIName: triggerGetContextAPI,
core.RemoveContextAPIName: triggerDeleteContextAPI,
core.DeleteContextAPIName: triggerDeleteContextAPI,
core.SetCurrentContextAPIName: triggerSetCurrentContextAPI,
core.GetCurrentContextAPIName: triggerGetCurrentContextAPI,
core.RemoveCurrentContextAPIName: triggerRemoveCurrentContextAPI,
core.SetServerAPIName: triggerSetServerAPI,
core.AddServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
core.GetServerAPIName: triggerGetServerAPI,
core.RemoveServerAPIName: triggerRemoveServerAPI,
core.DeleteServerAPIName: triggerRemoveServerAPI,
core.SetCurrentServerAPIName: triggerSetCurrentServerAPI,
core.GetCurrentServerAPIName: triggerGetCurrentServerAPI,
core.RemoveCurrentServerAPIName: triggerRemoveCurrentServerAPI,

// Server APIs
core.SetServerAPIName: triggerSetServerAPI,
core.AddServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
core.GetServerAPIName: triggerGetServerAPI,
core.RemoveServerAPIName: triggerRemoveServerAPI,
core.DeleteServerAPIName: triggerRemoveServerAPI,
core.SetCurrentServerAPIName: triggerSetCurrentServerAPI,
core.GetCurrentServerAPIName: triggerGetCurrentServerAPI,
core.RemoveCurrentServerAPIName: triggerRemoveCurrentServerAPI,
}

// triggerAPIs trigger runtime apis and construct logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

// Route to runtime API method call based on passed command value
var apiHandlers = map[core.RuntimeAPIName]func(*core.API) *core.APIResponse{
// Server APIs
core.SetServerAPIName: triggerSetServerAPI,
core.AddServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (

// Route to runtime API method call based on passed command value
var apiHandlers = map[core.RuntimeAPIName]func(*core.API) *core.APIResponse{
// Context APIs
core.AddContextAPIName: triggerAddContextAPI,
core.SetContextAPIName: triggerAddContextAPI,
core.GetContextAPIName: triggerGetContextAPI,
core.RemoveContextAPIName: triggerRemoveContextAPI,
core.DeleteContextAPIName: triggerRemoveContextAPI,
core.SetCurrentContextAPIName: triggerSetCurrentContextAPI,
core.GetCurrentContextAPIName: triggerGetCurrentContextAPI,

// Server APIs
core.AddServerAPIName: triggerAddServerAPI,
core.SetServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ import (

// Route to runtime API method call based on passed command value
var apiHandlers = map[core.RuntimeAPIName]func(*core.API) *core.APIResponse{
// Context APIs
core.SetContextAPIName: triggerSetContextAPI,
core.GetContextAPIName: triggerGetContextAPI,
core.RemoveContextAPIName: triggerDeleteContextAPI,
core.DeleteContextAPIName: triggerDeleteContextAPI,
core.SetCurrentContextAPIName: triggerSetCurrentContextAPI,
core.GetCurrentContextAPIName: triggerGetCurrentContextAPI,
core.RemoveCurrentContextAPIName: triggerRemoveCurrentContextAPI,
core.SetServerAPIName: triggerSetServerAPI,
core.AddServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
core.GetServerAPIName: triggerGetServerAPI,
core.RemoveServerAPIName: triggerRemoveServerAPI,
core.DeleteServerAPIName: triggerRemoveServerAPI,
core.SetCurrentServerAPIName: triggerSetCurrentServerAPI,
core.GetCurrentServerAPIName: triggerGetCurrentServerAPI,
core.RemoveCurrentServerAPIName: triggerRemoveCurrentServerAPI,
// Server APIs
core.SetServerAPIName: triggerSetServerAPI,
core.AddServerAPIName: triggerSetServerAPI,
core.PutServerAPIName: triggerSetServerAPI,
core.GetServerAPIName: triggerGetServerAPI,
core.RemoveServerAPIName: triggerRemoveServerAPI,
core.DeleteServerAPIName: triggerRemoveServerAPI,
core.SetCurrentServerAPIName: triggerSetCurrentServerAPI,
core.GetCurrentServerAPIName: triggerGetCurrentServerAPI,
core.RemoveCurrentServerAPIName: triggerRemoveCurrentServerAPI,
}

// triggerAPIs trigger runtime apis and construct logs
Expand Down

0 comments on commit 32093c4

Please sign in to comment.