Skip to content

Commit

Permalink
Integrate controllerworker test into autopilot matrix
Browse files Browse the repository at this point in the history
This way, the hard-coded k0s version in the test is no longer needed.

See: e5a271b ("Use dedicated leaspool for worker config component")
Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
  • Loading branch information
twz123 committed Jun 27, 2024
1 parent a01bc1c commit 6b63e42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ jobs:
fail-fast: false
matrix:
version: ${{fromJson(needs.prepare.outputs.autopilot-matrix)}}
smoke-suite:
- controllerworker
- ha3x3

name: "Autopilot tests :: ${{ matrix.version }}"
name: "Autopilot tests :: ${{ matrix.version }} :: ${{ matrix.smoke-suite }}"
needs: [prepare, build-k0s]
runs-on: ubuntu-22.04

Expand Down Expand Up @@ -309,13 +312,13 @@ jobs:
- name: Run inttest
run: |
make -C inttest check-ap-ha3x3 K0S_UPDATE_FROM_BIN="../k0s-$K0S_VERSION"
make -C inttest check-ap-${{ matrix.smoke-suite }} K0S_UPDATE_FROM_BIN="../k0s-$K0S_VERSION"
- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v4
with:
name: autopilot-tests-${{ matrix.version }}-files
name: autopilot-tests-${{ matrix.version }}-${{ matrix.smoke-suite }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
Expand Down
23 changes: 12 additions & 11 deletions inttest/ap-controllerworker/controllerworker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controllerworker

import (
"fmt"
"regexp"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -47,8 +48,6 @@ spec:
peerAddress: %s
`

const oldVersion = "v1.29.4+k0s.0"

// SetupTest prepares the controller and filesystem, getting it into a consistent
// state which we can run tests against.
func (s *controllerworkerSuite) SetupTest() {
Expand All @@ -65,14 +64,16 @@ func (s *controllerworkerSuite) SetupTest() {
require.NoError(err)
defer ssh.Disconnect()
s.PutFile(nodeName, "/tmp/k0s.yaml", fmt.Sprintf(k0sConfigWithMultiController, address, address))
// Install older version of k0s
downloadCmd := fmt.Sprintf("curl -sSfL get.k0s.sh | K0S_VERSION=%s sh", oldVersion)
out, err := ssh.ExecWithOutput(ctx, downloadCmd)
if err != nil {
s.T().Logf("error getting k0s: %s", out)

baseK0sVersion, err := ssh.ExecWithOutput(ctx, "/dist/k0s version")
s.Require().NoError(err)
baseKubernetesMajorMinorVersion, _, _ := strings.Cut(baseK0sVersion, "+")
if major, rest, _ := strings.Cut(baseKubernetesMajorMinorVersion, "."); rest != "" {
minor, _, _ := strings.Cut(rest, ".")
baseKubernetesMajorMinorVersion = major + "." + minor
}
require.NoError(err)
s.T().Logf("downloaded succesfully: %s", out)
s.T().Log("k0s base version: ", baseK0sVersion, ", base Kubernetes version: ", baseKubernetesMajorMinorVersion)

// Note that the token is intentionally empty for the first controller
args := []string{
"--debug",
Expand All @@ -84,7 +85,7 @@ func (s *controllerworkerSuite) SetupTest() {
s.PutFile(nodeName, "/tmp/token", joinToken)
args = append(args, "--token-file=/tmp/token")
}
out, err = ssh.ExecWithOutput(ctx, "k0s install controller "+strings.Join(args, " "))
out, err := ssh.ExecWithOutput(ctx, "cp -f /dist/k0s /usr/local/bin/k0s && /usr/local/bin/k0s install controller "+strings.Join(args, " "))
if err != nil {
s.T().Logf("error installing k0s: %s", out)
}
Expand All @@ -99,7 +100,7 @@ func (s *controllerworkerSuite) SetupTest() {

node, err := kc.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
require.NoError(err)
require.Equal("v1.29.4+k0s", node.Status.NodeInfo.KubeletVersion)
require.Regexp(fmt.Sprintf(`^%s\.[0-9]+\+k0s$`, regexp.QuoteMeta(baseKubernetesMajorMinorVersion)), node.Status.NodeInfo.KubeletVersion)

client, err := s.ExtensionsClient(s.ControllerNode(0))
s.Require().NoError(err)
Expand Down

0 comments on commit 6b63e42

Please sign in to comment.