Skip to content

Commit

Permalink
feat: add smoke test (#872)
Browse files Browse the repository at this point in the history
Co-authored-by: jiayongfei <yongfeijia@tencent.com>
  • Loading branch information
JiaYongfei and jiayongfei committed Nov 3, 2020
1 parent 5aa4d70 commit 40a8975
Show file tree
Hide file tree
Showing 11 changed files with 617 additions and 143 deletions.
64 changes: 45 additions & 19 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,58 @@ on:
- master
env:
VERSION: ${{ github.sha }}
PROVIDERRESVERSION: v1.18.3-1
KUBECONFIG: ${{ secrets.KUBECONFIG }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
SECRET_ID: ${{ secrets.SECRET_ID }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
REGION: ${{ secrets.REGION }}
CREATE_INSTANCES_PARAM: ${{ secrets.CREATE_INSTANCES_PARAM }}
PASSWORD: ${{ secrets.PASSWORD }}
NEED_DELETE: ${{ secrets.NEED_DELETE }}
jobs:
image:
name: build tke image
runs-on: self-hosted
steps:
- name: checkout
uses: actions/checkout@v2
- name: build and push platform image
if: contains(toJson(github.event.pull_request.labels.*.name), 'platform')
run: |
make push IMAGES="tke-platform-api tke-platform-controller" VERSION=${{ github.sha }}
platform:
name: platform test
- name: checkout
uses: actions/checkout@v2
- name: build and push platform image
if: contains(toJson(github.event.pull_request.labels.*.name), 'platform')
run: |
make push IMAGES="tke-platform-api tke-platform-controller" VERSION=${{ github.sha }}
platform1:
name: platform test - 1.18.3
needs: image
if: contains(toJson(github.event.pull_request.labels.*.name), 'platform')
# if: contains(toJson(github.event.pull_request.labels.*.name), 'platform')
runs-on: self-hosted
env:
K8SVERSION: 1.18.3
steps:
- name: printversion
env:
LABELNAME_CONTEXT: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
echo "$LABELNAME_CONTEXT"
- name: e2e test
run: |
go test -timeout 40m -v tkestack.io/tke/test/e2e/cluster
- name: printversion
env:
LABELNAME_CONTEXT: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
echo "$LABELNAME_CONTEXT"
- name: e2e test
run: |
go test -timeout 40m -v tkestack.io/tke/test/e2e/platform
platform2:
name: platform test - 1.16.9
needs: image
# if: contains(toJson(github.event.pull_request.labels.*.name), 'platform')
runs-on: self-hosted
env:
K8SVERSION: 1.16.9
steps:
- name: printversion
env:
LABELNAME_CONTEXT: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
echo "$LABELNAME_CONTEXT"
- name: e2e test
run: |
go test -timeout 40m -v tkestack.io/tke/test/e2e/platform
business:
name: business test
needs: image
Expand All @@ -46,4 +72,4 @@ jobs:
env:
LABELNAME_CONTEXT: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
echo "$LABELNAME_CONTEXT"
echo "$LABELNAME_CONTEXT"
11 changes: 9 additions & 2 deletions test/e2e/certs/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"fmt"
"io/ioutil"
"k8s.io/klog"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -56,6 +57,7 @@ func (c *TkeCert) InitTmpDir(namespace string) {
}

func (c *TkeCert) ClearTmpDir() {
klog.Info("Clear temp dir: ", c.tmpDir)
os.RemoveAll(c.tmpDir)
}

Expand Down Expand Up @@ -150,14 +152,19 @@ func (c *TkeCert) WriteKubeConfig(host string, port int, namespace string) error
return err
}

klog.Info("Kubeconfig file path: ", c.GetKubeConfigFile())
return files.WriteFileWithDir(c.tmpDir, constants.KubeconfigFileBaseName, data, 0644)
}

func (c *TkeCert) GetKubeConfig() (*restclient.Config, error) {
kubeconfig, err := files.ReadFileWithDir(c.tmpDir, constants.KubeconfigFileBaseName)
kubeConfig, err := files.ReadFileWithDir(c.tmpDir, constants.KubeconfigFileBaseName)
if err != nil {
return nil, err
}

return clientcmd.RESTConfigFromKubeConfig(kubeconfig)
return clientcmd.RESTConfigFromKubeConfig(kubeConfig)
}

func (c *TkeCert) GetKubeConfigFile() string {
return c.tmpDir + "/" + constants.KubeconfigFileBaseName
}

0 comments on commit 40a8975

Please sign in to comment.