Skip to content

Commit 730584b

Browse files
committed
[seaweed] add tests
Signed-off-by: IvanHunters <[email protected]>
1 parent 0e47e1e commit 730584b

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎hack/e2e-apps/bucket.bats‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bats
2+
3+
@test "Create and Verify Seeweedfs Bucket" {
4+
# Create the bucket resource
5+
name='test'
6+
kubectl apply -f - <<EOF
7+
apiVersion: apps.cozystack.io/v1alpha1
8+
kind: Bucket
9+
metadata:
10+
name: ${name}
11+
namespace: tenant-test
12+
spec: {}
13+
EOF
14+
15+
# Wait for the bucket to be ready
16+
kubectl -n tenant-test wait hr bucket-${name} --timeout=100s --for=condition=ready
17+
kubectl -n tenant-test wait bucketclaims.objectstorage.k8s.io bucket-${name} --timeout=300s --for=jsonpath='{.status.bucketReady}'
18+
kubectl -n tenant-test wait bucketaccesses.objectstorage.k8s.io bucket-${name} --timeout=300s --for=jsonpath='{.status.accessGranted}'
19+
20+
# Get and decode credentials
21+
kubectl -n tenant-test get secret bucket-${name} -ojsonpath='{.data.BucketInfo}' | base64 -d > bucket-test-credentials.json
22+
23+
# Get credentials from the secret
24+
ACCESS_KEY=$(jq -r '.spec.secretS3.accessKeyID' bucket-test-credentials.json)
25+
SECRET_KEY=$(jq -r '.spec.secretS3.accessSecretKey' bucket-test-credentials.json)
26+
BUCKET_NAME=$(jq -r '.spec.bucketName' bucket-test-credentials.json)
27+
28+
# Start port-forwarding
29+
bash -c 'timeout 100s kubectl port-forward service/seaweedfs-s3 -n tenant-root 8333:8333 > /dev/null 2>&1 &'
30+
31+
# Wait for port-forward to be ready
32+
timeout 30 sh -ec 'until nc -z localhost 8333; do sleep 1; done'
33+
34+
# Set up MinIO alias with error handling
35+
mc alias set local https://localhost:8333 $ACCESS_KEY $SECRET_KEY --insecure
36+
37+
# Upload file to bucket
38+
mc cp bucket-test-credentials.json $BUCKET_NAME/bucket-test-credentials.json
39+
40+
# Verify file was uploaded
41+
mc ls $BUCKET_NAME/bucket-test-credentials.json
42+
43+
# Clean up uploaded file
44+
mc rm $BUCKET_NAME/bucket-test-credentials.json
45+
46+
kubectl -n tenant-test delete bucket.apps.cozystack.io ${name}
47+
}

‎hack/e2e-install-cozystack.bats‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ EOF
123123

124124
@test "Configure Tenant and wait for applications" {
125125
# Patch root tenant and wait for its releases
126-
kubectl patch tenants/root -n tenant-root --type merge -p '{"spec":{"host":"example.org","ingress":true,"monitoring":true,"etcd":true,"isolated":true}}'
126+
kubectl patch tenants/root -n tenant-root --type merge -p '{"spec":{"host":"example.org","ingress":true,"monitoring":true,"etcd":true,"isolated":true, "seaweedfs": true}}'
127127

128-
timeout 60 sh -ec 'until kubectl get hr -n tenant-root etcd ingress monitoring tenant-root >/dev/null 2>&1; do sleep 1; done'
129-
kubectl wait hr/etcd hr/ingress hr/tenant-root -n tenant-root --timeout=2m --for=condition=ready
128+
timeout 60 sh -ec 'until kubectl get hr -n tenant-root etcd ingress monitoring seaweedfs tenant-root >/dev/null 2>&1; do sleep 1; done'
129+
kubectl wait hr/etcd hr/ingress hr/tenant-root hr/seaweedfs -n tenant-root --timeout=4m --for=condition=ready
130130

131131
if ! kubectl wait hr/monitoring -n tenant-root --timeout=2m --for=condition=ready; then
132132
flux reconcile hr monitoring -n tenant-root --force

‎packages/core/testing/images/e2e-sandbox/Dockerfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN curl -sSL "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_${TA
1919
&& chmod +x /usr/local/bin/yq
2020
RUN curl -sSL "https://fluxcd.io/install.sh" | bash
2121
RUN curl -sSL "https://github.com/cozystack/cozypkg/raw/refs/heads/main/hack/install.sh" | sh -s -- -v "${COZYPKG_VERSION}"
22-
22+
RUN curl https://dl.min.io/client/mc/release/${TARGETOS}-${TARGETARCH}/mc --create-dirs -o /usr/local/bin/mc \
23+
&& chmod +x /usr/local/bin/mc
2324
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
2425
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

0 commit comments

Comments
 (0)