aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/integration_test.yaml
blob: be9b78b933d38dec0ea21be8a4a8e0dc4578a94a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: CSI Integration Tests

on:
  push:
    branches: [master]
  pull_request:
  workflow_dispatch:

jobs:
  integration-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.25'

      - name: Build CSI driver
        run: |
          go build -o _output/seaweedfs-csi-driver ./cmd/seaweedfs-csi-driver
          go build -o _output/seaweedfs-mount ./cmd/seaweedfs-mount

      - name: Create kind cluster
        uses: helm/kind-action@v1.10.0
        with:
          cluster_name: csi-test

      - name: Build and load Docker images
        run: |
          # Build CSI driver image
          docker build -t seaweedfs-csi-driver:test -f cmd/seaweedfs-csi-driver/Dockerfile .
          kind load docker-image seaweedfs-csi-driver:test --name csi-test
          
          # Build mount service image  
          docker build -t seaweedfs-mount:test -f cmd/seaweedfs-mount/Dockerfile .
          kind load docker-image seaweedfs-mount:test --name csi-test

      - name: Deploy SeaweedFS
        run: |
          # Deploy SeaweedFS using a simple manifest
          kubectl apply -f - <<EOF
          apiVersion: v1
          kind: Namespace
          metadata:
            name: seaweedfs
          ---
          apiVersion: v1
          kind: Service
          metadata:
            name: seaweedfs
            namespace: seaweedfs
          spec:
            ports:
              - name: master
                port: 9333
              - name: volume
                port: 8080
              - name: filer
                port: 8888
              - name: filer-grpc
                port: 18888
              - name: s3
                port: 8333
            selector:
              app: seaweedfs
          ---
          apiVersion: apps/v1
          kind: Deployment
          metadata:
            name: seaweedfs
            namespace: seaweedfs
          spec:
            replicas: 1
            selector:
              matchLabels:
                app: seaweedfs
            template:
              metadata:
                labels:
                  app: seaweedfs
              spec:
                containers:
                  - name: seaweedfs
                    image: chrislusf/seaweedfs:latest
                    args:
                      - server
                      - -dir=/data
                      - -s3
                      - -filer
                      - -master.peers=none
                      - -volume.max=10
                      - -master.volumeSizeLimitMB=64
                    ports:
                      - containerPort: 9333
                      - containerPort: 8080
                      - containerPort: 8888
                      - containerPort: 18888
                      - containerPort: 8333
                    volumeMounts:
                      - name: data
                        mountPath: /data
                volumes:
                  - name: data
                    emptyDir: {}
          EOF
          
          # Wait for SeaweedFS to be ready
          kubectl wait --for=condition=available --timeout=120s deployment/seaweedfs -n seaweedfs
          kubectl get pods -n seaweedfs
          
          # Wait for SeaweedFS filer to be responsive
          echo "Waiting for SeaweedFS filer to be ready..."
          for i in {1..30}; do
            if kubectl exec -n seaweedfs deploy/seaweedfs -- wget -q -O- http://localhost:8888/; then
              echo "SeaweedFS filer is ready"
              exit 0
            fi
            echo "Waiting for filer... ($i/30)"
            sleep 2
          done
          echo "SeaweedFS filer did not become ready in time"
          exit 1

      - name: Deploy CSI Driver
        run: |
          # Deploy CSI driver with test images and correct filer address
          # The seaweedfs-csi.yaml deploys to 'default' namespace
          cat deploy/kubernetes/seaweedfs-csi.yaml | \
            sed 's|chrislusf/seaweedfs-csi-driver:dev|seaweedfs-csi-driver:test|g' | \
            sed 's|chrislusf/seaweedfs-mount:dev|seaweedfs-mount:test|g' | \
            sed 's|SEAWEEDFS_FILER:8888|seaweedfs.seaweedfs.svc.cluster.local:8888|g' | \
            kubectl apply -f -
          
          # Wait for CSI driver pods to be ready (fail fast if they don't start)
          sleep 15
          kubectl wait --for=condition=ready pod -l app=seaweedfs-controller --timeout=120s
          kubectl wait --for=condition=ready pod -l app=seaweedfs-node --timeout=120s
          kubectl wait --for=condition=ready pod -l app=seaweedfs-mount --timeout=120s
          kubectl get pods -l 'app in (seaweedfs-controller,seaweedfs-node,seaweedfs-mount)'

      - name: Create StorageClass and test PVC
        run: |
          # Create StorageClass
          kubectl apply -f - <<EOF
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata:
            name: seaweedfs-csi
          provisioner: seaweedfs-csi-driver
          volumeBindingMode: Immediate
          reclaimPolicy: Delete
          EOF
          
          # Create test PVC
          kubectl apply -f - <<EOF
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            name: test-pvc
          spec:
            accessModes:
              - ReadWriteMany
            resources:
              requests:
                storage: 1Gi
            storageClassName: seaweedfs-csi
          EOF
          
          # Wait for PVC to be bound
          kubectl wait --for=jsonpath='{.status.phase}'=Bound pvc/test-pvc --timeout=60s || {
            echo "PVC not bound, checking events..."
            kubectl describe pvc test-pvc
            kubectl logs -l app=seaweedfs-controller --tail=50
            exit 1
          }

      - name: Run functional test
        run: |
          # Create a test pod that uses the PVC
          kubectl apply -f - <<EOF
          apiVersion: v1
          kind: Pod
          metadata:
            name: test-pod
          spec:
            containers:
              - name: test
                image: busybox
                command: ["sleep", "3600"]
                volumeMounts:
                  - name: data
                    mountPath: /data
            volumes:
              - name: data
                persistentVolumeClaim:
                  claimName: test-pvc
          EOF
          
          # Wait for pod to be ready
          kubectl wait --for=condition=ready pod/test-pod --timeout=120s || {
            echo "Pod not ready, checking status..."
            kubectl describe pod test-pod
            kubectl logs -l app=seaweedfs-node --tail=100
            exit 1
          }
          
          # Test write
          kubectl exec test-pod -- sh -c 'echo "Hello SeaweedFS CSI" > /data/test.txt'
          
          # Test read
          kubectl exec test-pod -- cat /data/test.txt | grep "Hello SeaweedFS CSI"
          
          # Test file listing
          kubectl exec test-pod -- ls -la /data/
          
          echo "✅ Functional test passed!"

      - name: Cleanup
        if: always()
        run: |
          kubectl delete pod test-pod --ignore-not-found
          kubectl delete pvc test-pvc --ignore-not-found

      - name: Collect logs on failure
        if: failure()
        run: |
          echo "=== CSI Controller Logs ==="
          kubectl logs -l app=seaweedfs-controller --tail=200 || true
          echo "=== CSI Node Logs ==="
          kubectl logs -l app=seaweedfs-node --tail=200 || true
          echo "=== Mount Service Logs ==="
          kubectl logs -l app=seaweedfs-mount --tail=200 || true
          echo "=== SeaweedFS Logs ==="
          kubectl logs -n seaweedfs -l app=seaweedfs --tail=200 || true
          echo "=== All Pods ==="
          kubectl get pods -A
          echo "=== Events ==="
          kubectl get events --sort-by='.lastTimestamp' | tail -50