Files
buzz/deploy/charts/buzz/tests/render_test.yaml
Kalvin C 7012d86d52 feat: configure S3 URL addressing style (#3400)
## Summary

- add one strict `BUZZ_S3_ADDRESSING_STYLE=path|virtual` setting shared
by media and Git/CAS storage
- preserve path-style defaults for bundled Compose/Helm MinIO while
supporting Railway's virtual-hosted bucket contract
- fail startup on invalid or non-Unicode values before dependency
connection, and validate the Helm value with the same two choices
- document operator mappings and why endpoint and bucket remain separate
for routing and SigV4 signing

## Best-practice rationale

AWS documents both URL forms and favors virtual-hosted addressing for
S3, while compatibility endpoints such as the bundled MinIO deployment
can require path style. `rust-s3` defaults to virtual/subdomain
addressing and provides `with_path_style()` for the explicit
compatibility case.

Some providers buckets only support as virtual-hosted bucket styles.
This PR therefore uses one explicit, provider-neutral switch rather than
endpoint heuristics or fallback behavior, while retaining `path` as
Buzz's backward-compatible default.

Sources:
-
https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
- https://docs.rs/rust-s3/0.37.0/s3/bucket/struct.Bucket.html
- https://docs.railway.com/storage-buckets#url-style
-
https://github.com/minio/minio/blob/master/docs/config/README.md#domain

## Validation

- `cargo fmt --all`
- `cargo check --workspace --all-targets`
- targeted `buzz-media` and `buzz-relay` parsing/client-construction
tests for defaults, strict errors, and both URL styles
- Helm unittest: 45/45 passed
- Compose config/render validation passed
- local MinIO path-mode relay startup passed the Git A3 conformance
probe and became ready
- unreachable object storage failed startup and readiness never opened
- push hooks completed the broader Rust and desktop suites successfully

---------

Signed-off-by: npub122y0pqkertljmedu303rl0aqrj3w8pvu43t6jxm6875lzg6f2pwqegc3xc <5288f082d91aff2de5bc8be23fbfa01ca2e3859cac57a91b7a3fa9f12349505c@buzz.block.builderlab.xyz>
Signed-off-by: Kalvin Chau <kalvin@block.xyz>
Co-authored-by: npub122y0pqkertljmedu303rl0aqrj3w8pvu43t6jxm6875lzg6f2pwqegc3xc <5288f082d91aff2de5bc8be23fbfa01ca2e3859cac57a91b7a3fa9f12349505c@buzz.block.builderlab.xyz>
2026-07-29 17:00:41 -07:00

321 lines
11 KiB
YAML

suite: production render
# Multi-template scope: needed so $.Template.BasePath lookups in deployment.yaml
# (e.g. checksum/secret include of secret-chart.yaml) resolve at render time.
templates:
- templates/deployment.yaml
- templates/secret-chart.yaml
- templates/serviceaccount.yaml
- templates/service.yaml
- templates/pvc-git.yaml
tests:
- it: renders cleanly in production profile (external pg/redis)
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
asserts:
- equal:
path: kind
value: Deployment
template: templates/deployment.yaml
- equal:
path: kind
value: ServiceAccount
template: templates/serviceaccount.yaml
- equal:
path: kind
value: Service
template: templates/service.yaml
- notContains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_S3_REGION
any: true
template: templates/deployment.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_S3_ADDRESSING_STYLE
value: "path"
template: templates/deployment.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_HUDDLE_AUDIO_AVAILABLE
value: "true"
template: templates/deployment.yaml
# Security default: media GET/HEAD reads must be auth-gated out of the
# box. A private attachment must never be publicly readable by URL/hash
# in an unmodified render. If this assertion fails, someone flipped the
# default — treat that as a security regression, not a config tweak.
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_REQUIRE_MEDIA_GET_AUTH
value: "true"
template: templates/deployment.yaml
- it: renders virtual-hosted S3 addressing for providers that require it
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: https://storage.railway.app
s3.bucket: buzz-media-example
s3.region: auto
s3.addressingStyle: virtual
s3.accessKey: a
s3.secretKey: s
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_S3_REGION
value: "auto"
template: templates/deployment.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_S3_ADDRESSING_STYLE
value: "virtual"
template: templates/deployment.yaml
- it: lets an explicit value opt out of media read auth for dev/public deployments
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
relay.requireMediaGetAuth: false
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_REQUIRE_MEDIA_GET_AUTH
value: "false"
template: templates/deployment.yaml
- it: lets an explicit value disable huddle audio in a single-replica render
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
relay.huddleAudioAvailable: false
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_HUDDLE_AUDIO_AVAILABLE
value: "false"
template: templates/deployment.yaml
- it: lets an explicit value enable huddle audio in HA when the operator owns external audio behavior
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
replicaCount: 3
persistence.git.accessMode: ReadWriteOnce
relay.huddleAudioAvailable: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_HUDDLE_AUDIO_AVAILABLE
value: "true"
template: templates/deployment.yaml
- it: renders HA cleanly with replicaCount=3 + RWO git + Redis (no RWM needed)
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
replicaCount: 3
persistence.git.accessMode: ReadWriteOnce
asserts:
- equal:
path: spec.replicas
value: 3
template: templates/deployment.yaml
- equal:
path: spec.accessModes[0]
value: ReadWriteOnce
template: templates/pvc-git.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: BUZZ_HUDDLE_AUDIO_AVAILABLE
value: "false"
template: templates/deployment.yaml
- it: mounts a per-pod emptyDir git scratch volume when persistence is disabled
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
replicaCount: 5
persistence.git.enabled: false
asserts:
- equal:
path: spec.replicas
value: 5
template: templates/deployment.yaml
# git-repos is still mounted (BUZZ_GIT_REPO_PATH must be a real dir)…
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: git-repos
mountPath: /var/lib/buzz/git
template: templates/deployment.yaml
# …but as a per-pod emptyDir, not a shared PVC (no multi-attach).
- contains:
path: spec.template.spec.volumes
content:
name: git-repos
emptyDir:
sizeLimit: 10Gi
template: templates/deployment.yaml
# No PVC is rendered at all when persistence is disabled.
- hasDocuments:
count: 0
template: templates/pvc-git.yaml
- it: preserves image defaults when Pod extensions are empty
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
asserts:
- notExists:
path: spec.template.spec.initContainers
template: templates/deployment.yaml
- notExists:
path: spec.template.spec.containers[0].command
template: templates/deployment.yaml
- notExists:
path: spec.template.spec.containers[0].args
template: templates/deployment.yaml
- it: appends generic Pod extensions and overrides the relay command
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
relay.command:
- /opt/wrapper/wrapper
relay.args:
- /usr/local/bin/buzz-relay
relay.extraVolumeMounts:
- name: wrapper
mountPath: /opt/wrapper
extraInitContainers:
- name: install-wrapper
image: example.com/wrapper-init:v1
args:
- /opt/wrapper/wrapper
env:
- name: LITERAL_TEMPLATE
value: '{{ .Release.Name }}'
securityContext:
runAsNonRoot: true
resources:
requests:
cpu: 10m
memory: 16Mi
volumeMounts:
- name: wrapper
mountPath: /opt/wrapper
extraVolumes:
- name: wrapper
emptyDir: {}
asserts:
- equal:
path: spec.template.spec.initContainers[0].name
value: install-wrapper
template: templates/deployment.yaml
- equal:
path: spec.template.spec.initContainers[0].securityContext.runAsNonRoot
value: true
template: templates/deployment.yaml
# Extension fragments are deliberately rendered with toYaml, not tpl.
- equal:
path: spec.template.spec.initContainers[0].env[0].value
value: '{{ .Release.Name }}'
template: templates/deployment.yaml
- equal:
path: spec.template.spec.containers[0].command
value:
- /opt/wrapper/wrapper
template: templates/deployment.yaml
- equal:
path: spec.template.spec.containers[0].args
value:
- /usr/local/bin/buzz-relay
template: templates/deployment.yaml
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: wrapper
mountPath: /opt/wrapper
template: templates/deployment.yaml
- contains:
path: spec.template.spec.volumes
content:
name: wrapper
emptyDir: {}
template: templates/deployment.yaml
- it: appends generic init containers after the bundled MinIO readiness gate
release:
name: rel
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
postgresql.enabled: true
redis.enabled: true
minio.enabled: true
extraInitContainers:
- name: install-wrapper
image: example.com/wrapper-init:v1
asserts:
- equal:
path: spec.template.spec.initContainers[0].name
value: wait-for-bucket
template: templates/deployment.yaml
- equal:
path: spec.template.spec.initContainers[1].name
value: install-wrapper
template: templates/deployment.yaml