Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions acceptance/clusters/vectorized/basic/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: redpanda.vectorized.io/v1alpha1
kind: Cluster
metadata:
name: basic
spec:
image: "redpandadata/redpanda"
version: "v25.2.1"
replicas: 1
resources:
requests:
cpu: "100m"
memory: 256Mi
limits:
cpu: "100m"
memory: 256Mi
configuration:
rpcServer:
port: 33145
kafkaApi:
- port: 9092
adminApi:
- port: 9644
schemaRegistryApi:
- port: 8081
developerMode: true
additionalCommandlineArguments:
dump-memory-diagnostics-on-alloc-failure-kind: all
abort-on-seastar-bad-alloc: ''
2 changes: 2 additions & 0 deletions acceptance/clusters/vectorized/sasl/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
- port: 9092
adminApi:
- port: 9644
schemaRegistryApi:
- port: 8081
developerMode: true
additionalCommandlineArguments:
dump-memory-diagnostics-on-alloc-failure-kind: all
Expand Down
2 changes: 1 addition & 1 deletion acceptance/features/role-crds.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@cluster:sasl
@cluster:sasl @variant:vectorized
Feature: Role CRDs
Background: Cluster available
Given cluster "sasl" is available
Expand Down
2 changes: 1 addition & 1 deletion acceptance/features/schema-crds.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@cluster:basic
@cluster:basic @variant:vectorized
Feature: Schema CRDs
Background: Cluster available
Given cluster "basic" is available
Expand Down
2 changes: 1 addition & 1 deletion acceptance/features/topic-crds.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@cluster:basic
@cluster:basic @variant:vectorized
Feature: Topic CRDs
Background: Cluster available
Given cluster "basic" is available
Expand Down
2 changes: 1 addition & 1 deletion acceptance/features/user-crds.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@cluster:sasl
@cluster:sasl @variant:vectorized
Feature: User CRDs
Background: Cluster available
Given cluster "sasl" is available
Expand Down
103 changes: 0 additions & 103 deletions acceptance/features/vectorized-role-crds.feature

This file was deleted.

4 changes: 4 additions & 0 deletions acceptance/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func ClusterTag(ctx context.Context, t framework.TestingT, args ...string) conte
require.Greater(t, len(args), 0, "clusters tags can only be used with additional arguments")
name := args[0]

if variant := t.Variant(); variant != "" {
name = filepath.Join(variant, name)
}

t.Logf("Installing cluster %q", name)
t.ApplyManifest(ctx, filepath.Join("clusters", name))
t.Logf("Finished installing cluster %q", name)
Expand Down
5 changes: 1 addition & 4 deletions acceptance/steps/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"context"
"fmt"
"math/rand/v2"
"strings"
"time"

"github.com/redpanda-data/common-go/rpadmin"
Expand All @@ -29,9 +28,7 @@ import (
)

func checkClusterAvailability(ctx context.Context, t framework.TestingT, version, clusterName string) {
version = strings.TrimSpace(version)

if version == "vectorized" {
if getVersion(t, version) == "vectorized" {
checkV1ClusterAvailability(ctx, t, clusterName)
return
}
Expand Down
40 changes: 31 additions & 9 deletions acceptance/steps/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,15 @@ func (c *clusterClients) checkSchema(ctx context.Context, schema string, exists
t.Logf("Pulling list of schema subjects from cluster")
schemaRegistry := c.SchemaRegistry(ctx)
subjects, err = schemaRegistry.Subjects(ctx)
require.NoError(t, err)
if err != nil {
// just retry on error, sometimes v1 stuff is slow to come up even after
// the broker is marked as healthy
return false
}

return exists == slices.Contains(subjects, schema)
}, 10*time.Second, 1*time.Second, message) {
require.NoError(t, err)
t.Errorf("Final list of schema subjects: %v", subjects)
}
}
Expand Down Expand Up @@ -293,7 +298,7 @@ func (c *clusterClients) checkRole(ctx context.Context, role string, exists bool
}

func versionedClientsForCluster(ctx context.Context, version, cluster string) *clusterClients {
version = strings.TrimSpace(version)
version = getVersion(framework.T(ctx), version)

framework.T(ctx).Logf("Got versioned cluster %q", version)

Expand Down Expand Up @@ -392,7 +397,7 @@ func v1ClientsForCluster(ctx context.Context, cluster string) *clusterClients {
return clients
}

func usersFromACLTable(t framework.TestingT, cluster string, table *godog.Table) []*redpandav1alpha2.User {
func usersFromACLTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User

for i, row := range table.Rows {
Expand All @@ -404,13 +409,13 @@ func usersFromACLTable(t framework.TestingT, cluster string, table *godog.Table)
name, acls := row.Cells[0].Value, row.Cells[1].Value
name, acls = strings.TrimSpace(name), strings.TrimSpace(acls)

users = append(users, userFromRow(t, cluster, name, "", "", acls))
users = append(users, userFromRow(t, version, cluster, name, "", "", acls))
}

return users
}

func usersFromAuthTable(t framework.TestingT, cluster string, table *godog.Table) []*redpandav1alpha2.User {
func usersFromAuthTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User

for i, row := range table.Rows {
Expand All @@ -422,13 +427,13 @@ func usersFromAuthTable(t framework.TestingT, cluster string, table *godog.Table
name, password, mechanism := row.Cells[0].Value, row.Cells[1].Value, row.Cells[2].Value
name, password, mechanism = strings.TrimSpace(name), strings.TrimSpace(password), strings.TrimSpace(mechanism)

users = append(users, userFromRow(t, cluster, name, password, mechanism, ""))
users = append(users, userFromRow(t, version, cluster, name, password, mechanism, ""))
}

return users
}

func usersFromFullTable(t framework.TestingT, cluster string, table *godog.Table) []*redpandav1alpha2.User {
func usersFromFullTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User

for i, row := range table.Rows {
Expand All @@ -440,13 +445,15 @@ func usersFromFullTable(t framework.TestingT, cluster string, table *godog.Table
name, password, mechanism, acls := row.Cells[0].Value, row.Cells[1].Value, row.Cells[2].Value, row.Cells[3].Value
name, password, mechanism, acls = strings.TrimSpace(name), strings.TrimSpace(password), strings.TrimSpace(mechanism), strings.TrimSpace(acls)

users = append(users, userFromRow(t, cluster, name, password, mechanism, acls))
users = append(users, userFromRow(t, version, cluster, name, password, mechanism, acls))
}

return users
}

func userFromRow(t framework.TestingT, cluster, name, password, mechanism, acls string) *redpandav1alpha2.User {
func userFromRow(t framework.TestingT, version, cluster, name, password, mechanism, acls string) *redpandav1alpha2.User {
version = getVersion(t, version)

user := &redpandav1alpha2.User{
ObjectMeta: metav1.ObjectMeta{
Namespace: t.Namespace(),
Expand All @@ -460,6 +467,12 @@ func userFromRow(t framework.TestingT, cluster, name, password, mechanism, acls
},
},
}

if version == "vectorized" {
user.Spec.ClusterSource.ClusterRef.Group = ptr.To("redpanda.vectorized.io")
user.Spec.ClusterSource.ClusterRef.Kind = ptr.To("Cluster")
}

if mechanism != "" || password != "" {
user.Spec.Authentication = &redpandav1alpha2.UserAuthenticationSpec{
Type: ptr.To(redpandav1alpha2.SASLMechanism(mechanism)),
Expand Down Expand Up @@ -619,3 +632,12 @@ func removeAllFinalizers(ctx context.Context, t framework.TestingT, gvk schema.G
}
}
}

func getVersion(t framework.TestingT, version string) string {
version = strings.TrimSpace(version)
if version != "" {
return version
}

return t.Variant()
}
45 changes: 44 additions & 1 deletion acceptance/steps/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ package steps
import (
"context"
"os"
"strings"

"github.com/cucumber/godog"
"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"

framework "github.com/redpanda-data/redpanda-operator/harpoon"
)
Expand All @@ -23,7 +25,7 @@ func iApplyKubernetesManifest(ctx context.Context, t framework.TestingT, manifes
file, err := os.CreateTemp("", "manifest-*.yaml")
require.NoError(t, err)

_, err = file.Write([]byte(manifest.Content))
_, err = file.Write(normalizeContent(t, manifest.Content))
require.NoError(t, err)
require.NoError(t, file.Close())

Expand All @@ -37,3 +39,44 @@ func iApplyKubernetesManifest(ctx context.Context, t framework.TestingT, manifes
func iInstallLocalCRDs(ctx context.Context, t framework.TestingT, directory string) {
t.ApplyManifest(ctx, directory)
}

func normalizeContent(t framework.TestingT, content string) []byte {
manifest := map[string]any{}
require.NoError(t, yaml.Unmarshal([]byte(content), &manifest))

if getVersion(t, "") == "vectorized" {
addStringValueAtPath(manifest, "redpanda.vectorized.io", "spec.cluster.clusterRef.group")
addStringValueAtPath(manifest, "Cluster", "spec.cluster.clusterRef.kind")
}

contentBytes, err := yaml.Marshal(manifest)
require.NoError(t, err)

return contentBytes
}

func addStringValueAtPath(manifest map[string]any, value string, path string) map[string]any {
keys := strings.Split(path, ".")

current := manifest
for i, key := range keys {
if i == len(keys)-1 {
break
}
found, ok := current[key]
if !ok {
// all but the final key must exist in the path
return manifest
}
cast, ok := found.(map[string]any)
if !ok {
return manifest
}
current = cast
}
if len(keys) > 0 {
last := keys[len(keys)-1]
current[last] = value
}
return manifest
}
Loading
Loading