Skip to content

Commit

Permalink
Merge pull request #336 from dell/e2e-fsgroup-fix
Browse files Browse the repository at this point in the history
E2E FSGroup Test Fix
  • Loading branch information
rishabhatdell authored Oct 15, 2024
2 parents 0949130 + 0e135de commit 2346d8a
Show file tree
Hide file tree
Showing 12 changed files with 565 additions and 678 deletions.
41 changes: 41 additions & 0 deletions test/e2e-fsgroup/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
#
# Copyright © 2020-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Makefile for FSGroup e2e Tests

# Variables
GINKGO_BIN_PATH = /root/go/bin/ginkgo
GINKGO_INSTALL_CMD = go install github.com/onsi/ginkgo/v2/ginkgo
GINKGO_DEST_PATH = /usr/bin/ginkgo

# Default target to run all tasks
.PHONY: all
all: install-ginkgo run-tests

# Target to install Ginkgo v2, verify the installation, and move the binary
.PHONY: install-ginkgo
install-ginkgo:
@echo "Installing Ginkgo v2..."
$(GINKGO_INSTALL_CMD)
@echo "Verifying Ginkgo installation..."
$(GINKGO_BIN_PATH) version
@echo "Moving Ginkgo binary to /usr/bin..."
sudo mv $(GINKGO_BIN_PATH) $(GINKGO_DEST_PATH)

# Target to run FSGroup e2e tests
.PHONY: run-tests
run-tests:
@echo "Running FSGroup e2e tests..."
./run.sh
108 changes: 108 additions & 0 deletions test/e2e-fsgroup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# FSGroup e2e Tests

## Prerequisites
Ensure that you have Go installed on your system to install Ginkgo.

## Using the Makefile

This project includes a `Makefile` to automate the installation of Ginkgo, verify its installation, and run the FSGroup e2e tests. You can use the following commands to perform these tasks:

### Install Ginkgo v2 and Run Tests

To install Ginkgo, verify the installation, move the binary to a more accessible location, and run the FSGroup tests, run:
```bash
make all
```

### Individual Makefile Targets

You can also run each step separately using the following commands:

- **Install Ginkgo v2, verify the installation, and move the binary:**
```bash
make install-ginkgo
```

- **Run FSGroup e2e tests:**
```bash
make run-tests
```

## Manual Installation Steps

If you prefer to install Ginkgo manually, follow these steps:

### Installing Ginkgo v2

To install Ginkgo, use the following command:
```bash
go install github.com/onsi/ginkgo/v2/ginkgo
```

### Verify Installation

After installation, check the Ginkgo version with:
```bash
/root/go/bin/ginkgo version
```

You should see output similar to:
```
Ginkgo Version 2.x.x
```

### Move the Ginkgo Binary

Move the Ginkgo binary to a more accessible location:
```bash
mv /root/go/bin/ginkgo /usr/bin/ginkgo
```

## Running Tests

Install PowerFlex csi-driver, update `e2e-values.yaml` and run the following command to execute FSGroup tests:

```bash
./run.sh
```

### Understanding the `--focus` Flag

The `--focus` flag filters the tests, looking for string matches in `Describe()` Ginkgo nodes. For example, in the file `fs.go`, you might see:

```go
ginkgo.Describe("Volume Filesystem Group Test", ginkgo.Label("csi-fsg"), ginkgo.Label("csi-fs"), ginkgo.Serial, func() {
// Test implementation
})
```

## Test File Overview

### `fs.go`

This file creates a StorageClass, PersistentVolumeClaim (PVC) with that StorageClass, and a Pod that mounts this PVC, setting the `fsGroup` as specified.

- All necessary variables are declared in `e2e-values.yaml`.
- Helper methods to interact with Kubernetes are located in `utils.go`.
- Default timeouts for Kubernetes operations are defined in the E2E framework. CRUD operations are executed through:
```go
fpod "k8s.io/kubernetes/test/e2e/framework/pod"
fpv "k8s.io/kubernetes/test/e2e/framework/pv"
fss "k8s.io/kubernetes/test/e2e/framework/statefulset"
```

### `fs_scaleup_scaledown.go`

This file includes more complex tests that utilize a StatefulSet to create a Pod and expose a PVC/PV. It scales pods and cordons a pod while using a YAML file to set up the StatefulSet, Pod, and PVC.

### Important Notes

- In case of errors, a timeout will activate, waiting for operations (e.g., 5 minutes for Pod creation, 10 minutes for StatefulSet).
- Cleanup occurs after each test upon success.
- Use `getEvents` for details and troubleshooting when needed.

## Test Structure

- The Ginkgo test suite is initialized in `suite_test.go` using `RunSpecs`.
- `ginkgo.Describe` defines a suite of scenarios, covering both happy paths and error conditions.
- `ginkgo.BeforeEach` specifies a setup method that runs before each test.
78 changes: 0 additions & 78 deletions test/e2e-fsgroup/README.txt

This file was deleted.

3 changes: 1 addition & 2 deletions test/e2e-fsgroup/e2e-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ e2eCSIDriverName: "csi-vxflexos.dellemc.com"
scParamStoragePoolKey: "storagepool"
scParamStoragePoolValue: "sample"

scParamFsTypeKey: "FsType"
scParamFsTypeKey: "csi.storage.k8s.io/fstype"
scParamFsTypeValue: "ext4"

scParamStorageSystemKey: "systemID"

scParamStorageSystemValue: "sample"

diskSize: "8Gi"
Expand Down
Loading

0 comments on commit 2346d8a

Please sign in to comment.