mirror of
https://github.com/labring/sealos.git
synced 2026-09-24 15:46:19 +08:00
fix e2e apply test with infra && fix wrong ssh.fetch interface method implementation (#3560)
This commit is contained in:
@@ -3,12 +3,12 @@ name: E2E Apply Test
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request_target:
|
||||
types: [ opened, synchronize, reopened, labeled ]
|
||||
types: [ labeled ]
|
||||
|
||||
jobs:
|
||||
call_ci_workflow:
|
||||
uses: ./.github/workflows/import-patch-image.yml
|
||||
if: ${{ contains(github.event.pull_request.labels.*.name, 'need-e2e-apply-test') }}
|
||||
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'need-e2e-apply-test' }}
|
||||
with:
|
||||
arch: amd64,arm64
|
||||
e2e: true
|
||||
@@ -19,6 +19,7 @@ jobs:
|
||||
permissions:
|
||||
issues: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [ arm64, amd64 ]
|
||||
outputs:
|
||||
@@ -43,26 +44,28 @@ jobs:
|
||||
- name: Install ginkgo && Run e2e apply test
|
||||
id: apply_test
|
||||
shell: bash
|
||||
env:
|
||||
SEALOS_E2E_TEST_IMAGE_NAME: hub.sealos.cn/labring/kubernetes:v1.25.6
|
||||
SEALOS_E2E_TEST_PATCH_IMAGE_TAR: /tmp/sealos/images/patch-${{ matrix.arch }}.tar.gz
|
||||
SEALOS_E2E_TEST_PATCH_IMAGE_NAME: ghcr.io/labring/sealos-patch:${{ env.GIT_COMMIT_SHORT_SHA }}-${{ matrix.arch }}
|
||||
SEALOS_E2E_TEST_SEALOS_BIN_PATH: /tmp/sealos/bin/sealos
|
||||
ALIYUN_ACCESS_KEY_ID: ${{ secrets.E2E_ALIYUN_ACCESS_KEY_ID }}
|
||||
ALIYUN_ACCESS_KEY_SECRET: ${{ secrets.E2E_ALIYUN_ACCESS_KEY_SECRET }}
|
||||
ALIYUN_RESOURCE_GROUP_ID: ${{ secrets.E2E_ALIYUN_RESOURCE_GROUP_ID }}
|
||||
ALIYUN_REGION_ID: ${{ secrets.E2E_ALIYUN_REGION_ID }}
|
||||
run: |
|
||||
set -ex
|
||||
sudo chmod a+x /tmp/e2e.test
|
||||
sudo su
|
||||
chmod a+x /tmp/e2e.test
|
||||
gzip /tmp/sealos/images/patch-${{ matrix.arch }}.tar
|
||||
sudo export SEALOS_E2E_TEST_IMAGE_NAME="hub.sealos.cn/labring/kubernetes:v1.25.6" \
|
||||
SEALOS_E2E_TEST_PATCH_IMAGE_TAR="/tmp/sealos/images/patch-${{ matrix.arch }}.tar.gz" \
|
||||
SEALOS_E2E_TEST_PATCH_IMAGE_NAME="ghcr.io/labring/sealos-patch:${{ env.GIT_COMMIT_SHORT_SHA }}-${{ matrix.arch }}" \
|
||||
SEALOS_E2E_TEST_SEALOS_BIN_PATH="/tmp/sealos/bin/sealos" \
|
||||
ALIYUN_ACCESS_KEY_ID="${{ secrets.E2E_ALIYUN_ACCESS_KEY_ID }}" \
|
||||
ALIYUN_ACCESS_KEY_SECRET="${{ secrets.E2E_ALIYUN_ACCESS_KEY_SECRET }}" \
|
||||
ALIYUN_RESOURCE_GROUP_ID="${{ secrets.E2E_ALIYUN_RESOURCE_GROUP_ID }}" \
|
||||
ALIYUN_REGION_ID="${{ secrets.E2E_ALIYUN_REGION_ID }}"
|
||||
sudo /tmp/e2e.test --ginkgo.v --ginkgo.focus="E2E_sealos_apply_infra_test"
|
||||
/tmp/e2e.test --ginkgo.v --ginkgo.focus="E2E_sealos_apply_infra_test"
|
||||
echo 'test_result=success' >> "$GITHUB_OUTPUT"
|
||||
issue_commit:
|
||||
needs: [ e2e_apply_test ]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'need-e2e-apply-test') }} #success() || failure()
|
||||
if: ${{ always() && github.event.label.name == 'need-e2e-apply-test' }} #success() || failure()
|
||||
steps:
|
||||
- name: Add comment to PR with test status
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ func (c *Client) Fetch(host, src, dst string) error {
|
||||
return err
|
||||
}
|
||||
defer created.Close()
|
||||
_, err = io.Copy(rfp, created)
|
||||
_, err = io.Copy(created, rfp)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/labring/sealos/test/e2e/suites/operators"
|
||||
|
||||
"github.com/labring/sealos/test/e2e/testhelper/utils"
|
||||
|
||||
"github.com/labring/sealos/pkg/types/v1beta1"
|
||||
@@ -121,6 +123,22 @@ func (a *Applier) initImage() {
|
||||
}
|
||||
err = a.RemoteSealosCmd.ImageLoad(a.Infra.PatchImageTar)
|
||||
utils.CheckErr(err)
|
||||
images, err := operators.NewFakeImage(a.RemoteSealosCmd).ListImages(false)
|
||||
utils.CheckErr(err)
|
||||
logger.Info("images:", images)
|
||||
patchImageName := ""
|
||||
for _, image := range images {
|
||||
for i := range image.Names {
|
||||
if strings.Contains(image.Names[i], "sealos-patch") {
|
||||
patchImageName = image.Names[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if patchImageName != "" {
|
||||
a.Infra.PatchImageName = patchImageName
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = a.RemoteSealosCmd.ImagePull(&cmd2.PullOptions{
|
||||
ImageRefs: []string{a.Infra.PatchImageName},
|
||||
|
||||
@@ -18,6 +18,7 @@ package infra
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/labring/sealos/test/e2e/testhelper/utils"
|
||||
|
||||
@@ -48,9 +49,9 @@ func NewFakeInfra() *FakeInfra {
|
||||
|
||||
func (f *FakeInfra) PreSetEnv() {
|
||||
f.ImageName = settings.GetEnvWithDefault(settings.TestImageName, settings.DefaultTestImageName)
|
||||
f.ImageTar = settings.GetEnvWithDefault(settings.TestImageTar, settings.DefaultTestImageTar)
|
||||
f.PatchImageName = settings.GetEnvWithDefault(settings.TestPatchImageName, settings.DefaultPatchImageName)
|
||||
f.PatchImageTar = settings.GetEnvWithDefault(settings.TestPatchImageTar, settings.DefaultPatchImageTar)
|
||||
f.ImageTar = os.Getenv(settings.TestImageTar)
|
||||
f.PatchImageTar = os.Getenv(settings.TestPatchImageTar)
|
||||
f.PatchImageName = os.Getenv(settings.TestPatchImageName)
|
||||
f.InfraDriver = settings.GetEnvWithDefault(settings.TestInfra, settings.DefaultInfraDriver)
|
||||
f.TestDir = settings.GetEnvWithDefault(settings.TestDir, settings.DefaultTestDir)
|
||||
f.ClusterName = settings.GetEnvWithDefault(settings.TestClusterName, settings.DefaultTestClusterName)
|
||||
|
||||
@@ -31,7 +31,7 @@ type fakeImageClient struct {
|
||||
*cmd.SealosCmd
|
||||
}
|
||||
|
||||
func newFakeImage(sealosCmd *cmd.SealosCmd) FakeImageInterface {
|
||||
func NewFakeImage(sealosCmd *cmd.SealosCmd) FakeImageInterface {
|
||||
return &fakeImageClient{
|
||||
SealosCmd: sealosCmd,
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewFakeClient(clusterName string) *FakeClient {
|
||||
}
|
||||
localCmd := cmd.NewSealosCmd(settings.E2EConfig.SealosBinPath, &cmd.LocalCmd{})
|
||||
return &FakeClient{
|
||||
Image: newFakeImage(localCmd),
|
||||
Image: NewFakeImage(localCmd),
|
||||
CRI: newCRIClient(localCmd),
|
||||
Cluster: newClusterClient(localCmd, clusterName),
|
||||
Cert: newCertClient(localCmd, clusterName),
|
||||
|
||||
Reference in New Issue
Block a user