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
1 change: 1 addition & 0 deletions build.assets/charts/Dockerfile-distroless
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ FROM $BASE_IMAGE
COPY --from=teleport /opt/staging /
COPY --from=staging /opt/staging/root /
COPY --from=staging /opt/staging/status /var/lib/dpkg/status.d
ENV TELEPORT_TOOLS_VERSION=off
ENTRYPOINT ["/usr/bin/dumb-init", "/usr/local/bin/teleport", "start", "-c", "/etc/teleport/teleport.yaml"]
31 changes: 21 additions & 10 deletions integration/autoupdate/tools/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -60,8 +59,13 @@ func TestUpdate(t *testing.T) {
err := updater.Update(ctx, testVersions[0])
require.NoError(t, err)

tshPath, err := updater.ToolPath("tsh", testVersions[0])
require.NoError(t, err)
tctlPath, err := updater.ToolPath("tctl", testVersions[0])
require.NoError(t, err)

// Verify that the installed version is equal to requested one.
cmd := exec.CommandContext(ctx, filepath.Join(toolsDir, "tctl"), "version")
cmd := exec.CommandContext(ctx, tctlPath, "version")
out, err := cmd.Output()
require.NoError(t, err)

Expand All @@ -71,7 +75,7 @@ func TestUpdate(t *testing.T) {

// Execute version command again with setting the new version which must
// trigger re-execution of the same command after downloading requested version.
cmd = exec.CommandContext(ctx, filepath.Join(toolsDir, "tsh"), "version")
cmd = exec.CommandContext(ctx, tshPath, "version")
cmd.Env = append(
os.Environ(),
fmt.Sprintf("%s=%s", teleportToolsVersion, testVersions[1]),
Expand Down Expand Up @@ -101,6 +105,9 @@ func TestParallelUpdate(t *testing.T) {
err := updater.Update(ctx, testVersions[0])
require.NoError(t, err)

tshPath, err := updater.ToolPath("tsh", testVersions[0])
require.NoError(t, err)

// By setting the limit request next test http serving file going blocked until unlock is sent.
lock := make(chan struct{})
limitedWriter.SetLimitRequest(limitRequest{
Expand All @@ -110,8 +117,8 @@ func TestParallelUpdate(t *testing.T) {

outputs := make([]bytes.Buffer, 3)
errChan := make(chan error, 3)
for i := 0; i < len(outputs); i++ {
cmd := exec.Command(filepath.Join(toolsDir, "tsh"), "version")
for i := range outputs {
cmd := exec.Command(tshPath, "version")
cmd.Stdout = &outputs[i]
cmd.Stderr = &outputs[i]
cmd.Env = append(
Expand Down Expand Up @@ -139,7 +146,7 @@ func TestParallelUpdate(t *testing.T) {

// Wait till process finished with exit code 0, but we still should get progress
// bar in output content.
for i := 0; i < cap(outputs); i++ {
for range cap(outputs) {
select {
case <-time.After(5 * time.Second):
require.Fail(t, "failed to wait till the process is finished")
Expand All @@ -149,7 +156,7 @@ func TestParallelUpdate(t *testing.T) {
}

var progressCount int
for i := 0; i < cap(outputs); i++ {
for i := range cap(outputs) {
matches := pattern.FindStringSubmatch(outputs[i].String())
require.Len(t, matches, 2)
assert.Equal(t, testVersions[1], matches[1])
Expand All @@ -173,9 +180,11 @@ func TestUpdateInterruptSignal(t *testing.T) {
)
err := updater.Update(ctx, testVersions[0])
require.NoError(t, err)
tshPath, err := updater.ToolPath("tsh", testVersions[0])
require.NoError(t, err)

var output bytes.Buffer
cmd := exec.Command(filepath.Join(toolsDir, "tsh"), "version")
cmd := exec.Command(tshPath, "version")
cmd.Stdout = &output
cmd.Stderr = &output
cmd.Env = append(
Expand Down Expand Up @@ -237,9 +246,11 @@ func TestUpdateForOSSBuild(t *testing.T) {
)
err := updater.Update(ctx, testVersions[0])
require.NoError(t, err)
tshPath, err := updater.ToolPath("tsh", testVersions[0])
require.NoError(t, err)

// Verify that requested update is ignored by OSS build and version wasn't updated.
cmd := exec.CommandContext(ctx, filepath.Join(toolsDir, "tsh"), "version")
cmd := exec.CommandContext(ctx, tshPath, "version")
cmd.Env = append(
os.Environ(),
fmt.Sprintf("%s=%s", teleportToolsVersion, testVersions[1]),
Expand All @@ -253,7 +264,7 @@ func TestUpdateForOSSBuild(t *testing.T) {

// Next update is set with the base URL env variable, must download new version.
t.Setenv(autoupdate.BaseURLEnvVar, baseURL)
cmd = exec.CommandContext(ctx, filepath.Join(toolsDir, "tsh"), "version")
cmd = exec.CommandContext(ctx, tshPath, "version")
cmd.Env = append(
os.Environ(),
fmt.Sprintf("%s=%s", teleportToolsVersion, testVersions[1]),
Expand Down
Loading
Loading