Skip to content

Commit

Permalink
Merge pull request #3745 from twz123/inttest-ap-single
Browse files Browse the repository at this point in the history
Use a real single node in the ap-single inttest
  • Loading branch information
twz123 authored Nov 24, 2023
2 parents 78c36e7 + 9f8a9f4 commit 5a2444e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions inttest/ap-single/single_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package single
import (
"fmt"
"testing"
"time"

apconst "github.com/k0sproject/k0s/pkg/autopilot/constant"
appc "github.com/k0sproject/k0s/pkg/autopilot/controller/plans/core"
Expand All @@ -39,24 +38,24 @@ type plansSingleControllerSuite struct {
// SetupTest prepares the controller and filesystem, getting it into a consistent
// state which we can run tests against.
func (s *plansSingleControllerSuite) SetupTest() {
ctx := s.Context()
s.Require().NoError(s.WaitForSSH(s.ControllerNode(0), 2*time.Minute, 1*time.Second))
ctx, nodeName, require := s.Context(), s.ControllerNode(0), s.Require()

// Move the k0s binary to a new location, so we can check the binary location detection
ssh, err := s.SSH(s.Context(), s.ControllerNode(0))
s.Require().NoError(err)
ssh, err := s.SSH(ctx, nodeName)
require.NoError(err)
defer ssh.Disconnect()
_, err = ssh.ExecWithOutput(ctx, "cp /dist/k0s /tmp/k0s")
s.Require().NoError(err)
require.NoError(ssh.Exec(ctx, "cp /dist/k0s /tmp/k0s", common.SSHStreams{}))

s.Require().NoError(s.InitController(0, "--disable-components=metrics-server"))
s.Require().NoError(s.WaitJoinAPI(s.ControllerNode(0)))
require.NoError(s.InitController(0, "--single", "--disable-components=metrics-server"))

client, err := s.ExtensionsClient(s.ControllerNode(0))
s.Require().NoError(err)
client, err := s.KubeClient(nodeName)
require.NoError(err)
require.NoError(s.WaitForNodeReady(nodeName, client))

s.Require().NoError(aptest.WaitForCRDByName(ctx, client, "plans"))
s.Require().NoError(aptest.WaitForCRDByName(ctx, client, "controlnodes"))
xClient, err := s.ExtensionsClient(nodeName)
require.NoError(err)
require.NoError(aptest.WaitForCRDByName(ctx, xClient, "plans"))
require.NoError(aptest.WaitForCRDByName(ctx, xClient, "controlnodes"))
}

// TestApply applies a well-formed `plan` yaml, and asserts that all of the correct values
Expand Down Expand Up @@ -98,7 +97,7 @@ spec:

// The plan has enough information to perform a successful update of k0s, so wait for it.
plan, err := aptest.WaitForPlanState(s.Context(), client, apconst.AutopilotName, appc.PlanCompleted)
s.Require().NoError(err)
s.Require().NoError(err, "While waiting for plan to complete")

s.Equal(1, len(plan.Status.Commands))
cmd := plan.Status.Commands[0]
Expand Down

0 comments on commit 5a2444e

Please sign in to comment.