Skip to content
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
91 changes: 79 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,40 @@ mv upgrade-ubuntu-latest-amd64 upgrade && chmod +x upgrade
- 数据准备多次执行应该具备幂等性,确保可以重复运行。
- 需要添加 `skip-clean-namespace` 的 Tag 确保执行后实例不被清理。

```feature
功能: gitlab 升级

@priority-high
@e2e
@prepare-17.8
@prepare-17.11
@gitlab-operator-prepare-upgrade
@skip-cleanup-namespace
@allure.label.case_id:gitlab-operator-prepare-upgrade
场景: 安装 gitlab 实例,准备数据
假定 命名空间 "gitlab-upgrade" 已存在
并且 集群已安装 ingress controller
当 已导入 "gitlab 实例" 资源
"""
yaml: ./testdata/values-gitlab-upgrade.yaml
onConflict: ignore
"""
并且 导入测试数据到 Gitlab 成功
"""
url: http://test-gitlab-upgrade.example.com
username: root
password: 07Apples@
timeout: 15m
importProjectPath: ./testdata/resources/test-upgrade-repo_export.tar.gz
"""
```

2. 检查升级数据。

- 和数据准备相对应,负责升级实例以及检查准备的数据是否丢失。
- 存在多次升级时,需要添加 `skip-clean-namespace` 的 Tag 确保执行后实例不被清理。


### 编写配置文件

将文件保存为 upgrade.yaml
Expand All @@ -61,18 +90,56 @@ operatorConfig:
namespace: gitlab-ce-operator # operator 部署 ns
name: gitlab-ce-operator # operator 名称
upgradePaths: # 定义升级路径,可以包含多个
- name: v17.8 upgrade to v17.11 # 升级名称
versions: # 定义升级路经
- name: v17.8 # 版本名称
testCommand: | # 执行测试指令
gitlab17.8.test --godog.concurrency=1 --godog.format=allure --godog.tags=@prepare
bundleVersion: v17.8.10 # bundle 版本号
channel: stable
- name: v17.11 # 版本名称
testCommand: |
gitlab17.11.test --godog.concurrency=1 --godog.format=allure --godog.tags=@upgrade --bdd.cleanup=false
bundleVersion: v17.11.1 # bundle 版本号
channel: stable
- name: v17.8 upgrade to v17.11 # 升级名称
versions: # 定义升级路经
- name: v17.8 # 版本名称
testCommand: |
[email protected] GODOG_ARGS="--godog.format=allure" make test
bundleVersion: v17.8.10
channel: stable
- name: v17.11 # 版本名称
testCommand: |
[email protected] GODOG_ARGS="--godog.format=allure --bdd.cleanup=false" make test
bundleVersion: v17.11.1
channel: stable
```

### 构建测试镜像

需要在测试镜像中添加升级测试的制品:

```dockerfile
FROM docker-mirrors.alauda.cn/library/golang:1.24-bookworm AS builder

WORKDIR /tools
RUN mkdir -p /tools/bin

COPY testing /app
ENV GOPROXY='https://build-nexus.alauda.cn/repository/golang/,direct'
RUN set -eux; \
cd /app && \
go test -c -o /tools/bin/gitlab.test ./

# add content
# renovate: datasource=github-releases depName=upgrade-test packageName=AlaudaDevops/upgrade-test
ARG UPGRADE_TEST_VERSION=v0.0.5
RUN if [ "$(arch)" = "arm64" ] || [ "$(arch)" = "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \
wget https://github.com/AlaudaDevops/upgrade-test/releases/download/${UPGRADE_TEST_VERSION}/upgrade-ubuntu-latest-${ARCH} && \
mv upgrade-ubuntu-latest-${ARCH} /tools/bin/upgrade && \
chmod +x /tools/bin/upgrade
# add end

FROM build-harbor.alauda.cn/devops/test-bdd:latest

COPY --from=builder /tools/bin/gitlab.test /tools/bin/gitlab.test
COPY --from=builder /tools/bin/upgrade /tools/bin/upgrade
COPY . /app

WORKDIR /app/testing
ENV TEST_COMMAND="gitlab.test"

ENTRYPOINT ["gitlab.test"]
CMD ["--godog.concurrency=2", "--godog.format=allure", "[email protected]"]
```

### 运行测试
Expand Down
5 changes: 5 additions & 0 deletions cmd/upgrade_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func (uc *UpgradeCommand) Execute() error {
}
uc.operator = op

if len(cfg.UpgradePaths) == 0 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

升级路径为空时,提示用户。

logger.Info("no upgrade paths found, skipping")
return nil
}

// Process upgrade paths
for _, path := range cfg.UpgradePaths {
if err := uc.process(ctx, path); err != nil {
Expand Down