Skip to content

Commit

Permalink
e2e: simplify emojivoto
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Apr 25, 2024
1 parent 8b2156d commit 33fcff2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 50 deletions.
2 changes: 1 addition & 1 deletion e2e/internal/kuberesource/resourcegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {
case "openssl":
resources, err = kuberesource.OpenSSL()
case "emojivoto":
resources, err = kuberesource.Emojivoto()
resources, err = kuberesource.Emojivoto(kuberesource.ServiceMeshDisabled)
default:
fmt.Printf("Error: unknown set: %s\n", set)
os.Exit(1)
Expand Down
50 changes: 2 additions & 48 deletions e2e/internal/kuberesource/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ func OpenSSL() ([]any, error) {
return resources, nil
}

// generateEmojivoto returns resources for deploying Emojivoto application.
func generateEmojivoto(smMode serviceMeshMode) ([]any, error) {
// Emojivoto returns resources for deploying Emojivoto application.
func Emojivoto(smMode serviceMeshMode) ([]any, error) {
ns := "edg-default"
var emojiSvcImage, emojiVotingSvcImage, emojiWebImage, emojiSvcHost, votingSvcHost string
smProxyEmoji := ServiceMeshProxy()
Expand Down Expand Up @@ -645,49 +645,3 @@ func PatchNamespaces(resources []any, namespace string) []any {
}
return resources
}

// EmojivotoDemo returns patched resources for deploying an Emojivoto demo.
func EmojivotoDemo(replacements map[string]string) ([]any, error) {
resources, err := generateEmojivoto(ServiceMeshDisabled)
if err != nil {
return nil, err
}
patched := PatchImages(resources, replacements)
patched = PatchNamespaces(patched, "default")
return patched, nil
}

// Emojivoto returns resources for deploying Emojivoto application.
func Emojivoto() ([]any, error) {
resources, err := generateEmojivoto(ServiceMeshDisabled)
if err != nil {
return nil, err
}

// Add coordinator
ns := "edg-default"
namespace := Namespace(ns)
coordinator := Coordinator(ns).DeploymentApplyConfiguration
coordinatorService := ServiceForDeployment(coordinator)
resources = append(resources, namespace, coordinator, coordinatorService)

return resources, nil
}

// EmojivotoIngressEgress returns resources for deploying Emojivoto application with
// the service mesh configured with ingress and egress proxies.
func EmojivotoIngressEgress() ([]any, error) {
resources, err := generateEmojivoto(ServiceMeshIngressEgress)
if err != nil {
return nil, err
}

// Add coordinator
ns := "edg-default"
namespace := Namespace(ns)
coordinator := Coordinator(ns).DeploymentApplyConfiguration
coordinatorService := ServiceForDeployment(coordinator)
resources = append(resources, namespace, coordinator, coordinatorService)

return resources, nil
}
6 changes: 5 additions & 1 deletion e2e/servicemesh/servicemesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ var imageReplacements map[string]string
func TestIngressEgress(t *testing.T) {
ct := contrasttest.New(t, imageReplacements)

resources, err := kuberesource.EmojivotoIngressEgress()
resources, err := kuberesource.Emojivoto(kuberesource.ServiceMeshIngressEgress)
require.NoError(t, err)

coordinator := kuberesource.Coordinator("").DeploymentApplyConfiguration
coordinatorService := kuberesource.ServiceForDeployment(coordinator)
resources = append(resources, coordinator, coordinatorService)

ct.Init(t, resources)

require.True(t, t.Run("generate", ct.Generate), "contrast generate needs to succeed for subsequent tests")
Expand Down

0 comments on commit 33fcff2

Please sign in to comment.