Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add file-server tools #72

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
all: help

# Run markdown lint
markdownlint:
@echo "Begin to markdownlint."
@./hack/markdownlint.sh
.PHONY: markdownlint
# Build file-server image.
docker-build-file-server:
@echo "Begin to use docker build file-server image."
docker build -t file-server:latest -f ./tools/file-server/Dockerfile .
.PHONY: docker-build-file-server

# Run code lint
lint: markdownlint
@echo "Begin to golangci-lint."
@golangci-lint run
.PHONY: lint

# Run markdown lint
markdownlint:
@echo "Begin to markdownlint."
@./hack/markdownlint.sh
.PHONY: markdownlint

# Clear compiled files
clean:
@go clean
@rm -rf bin .go .cache
.PHONY: clean

help:
@echo "make docker-build-file-server build file-server image"
@echo "make lint run code lint"
@echo "make markdownlint run markdown lint"
@echo "make clean clean"
1 change: 1 addition & 0 deletions benchmark/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/dragonflyoss/perf-tests/benchmark
go 1.22.4

require (
github.com/google/uuid v1.4.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
Expand Down
2 changes: 2 additions & 0 deletions benchmark/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand Down
3 changes: 3 additions & 0 deletions benchmark/pkg/backend/file_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"fmt"
"net/url"
"path"

"github.com/google/uuid"
)

type FileSizeLevel string
Expand Down Expand Up @@ -58,6 +60,7 @@ func (f *fileServer) GetFileURL(fileSizeLevel FileSizeLevel, tag string) (*url.U
// Add tag query parameter.
query := u.Query()
query.Set("tag", tag)
query.Set("uuid", uuid.New().String())
u.RawQuery = query.Encode()
return u, nil
}
2 changes: 1 addition & 1 deletion benchmark/pkg/dragonfly/dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (d *dragonfly) downloadFileByProxy(ctx context.Context, podExec *util.PodEx

// getClientPods returns the client pods.
func (d *dragonfly) getClientPods(ctx context.Context) ([]string, error) {
pods, err := util.GetPods(ctx, d.namespace, "app=client")
pods, err := util.GetPods(ctx, d.namespace, "component=client")
if err != nil {
logrus.Errorf("failed to get pods: %v", err)
return nil, err
Expand Down
19 changes: 19 additions & 0 deletions tools/file-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM nginx:alpine

RUN dd if=/dev/zero of=/usr/share/nginx/html/nano bs=1 count=1

RUN dd if=/dev/zero of=/usr/share/nginx/html/micro bs=1K count=10

RUN dd if=/dev/zero of=/usr/share/nginx/html/small bs=1M count=1

RUN dd if=/dev/zero of=/usr/share/nginx/html/medium bs=1M count=10

RUN dd if=/dev/zero of=/usr/share/nginx/html/large bs=1G count=1

RUN dd if=/dev/zero of=/usr/share/nginx/html/xlarge bs=1G count=10

RUN dd if=/dev/zero of=/usr/share/nginx/html/xxlarge bs=1G count=30

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
40 changes: 40 additions & 0 deletions tools/file-server/file-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
apiVersion: v1
kind: Service
metadata:
name: file-server
spec:
selector:
app: dragonfly
component: file-server
type: ClusterIP
ports:
- name: nginx
port: 80
protocol: TCP
targetPort: 80

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: file-server
spec:
serviceName: file-server
selector:
matchLabels:
app: dragonfly
component: file-server
replicas: 1
template:
metadata:
labels:
app: dragonfly
component: file-server
spec:
containers:
- name: file-server
image: dragonflyoss/file-server:latest
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 80
Loading