Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: simplify emojivoto #391

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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