diff --git a/.github/workflows/gitsecrets.yml b/.github/workflows/gitsecrets.yml index a3128341914..968ff3a17be 100644 --- a/.github/workflows/gitsecrets.yml +++ b/.github/workflows/gitsecrets.yml @@ -8,7 +8,7 @@ jobs: name: Git Secrets Scan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: Git Secrets Scan Script diff --git a/.github/workflows/gomod.yml b/.github/workflows/gomod.yml index cd53cda324a..58855af8c67 100644 --- a/.github/workflows/gomod.yml +++ b/.github/workflows/gomod.yml @@ -8,7 +8,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7d91115a920..fa1a46f38a9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -8,7 +8,7 @@ jobs: name: Linux unit tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 5b06e97a9e3..4be0285f3ca 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -8,7 +8,7 @@ jobs: name: Static Analysis runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: run static checks @@ -43,7 +43,7 @@ jobs: name: Static Analysis Init runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -62,7 +62,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: run static checks @@ -78,7 +78,7 @@ jobs: name: Cross platform build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -97,7 +97,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e4abeccd5d5..fd91c8b88f0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -8,7 +8,7 @@ jobs: name: Windows unit tests runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: path: src/github.com/aws/amazon-ecs-agent - name: get GO_VERSION @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ steps.get-go-version.outputs.GO_VERSION_WINDOWS }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: submodules: true path: src/github.com/aws/amazon-ecs-agent diff --git a/agent/doctor/docker_runtime_healthcheck.go b/agent/doctor/docker_runtime_healthcheck.go index 45027d1181a..1bb2f9d2b35 100644 --- a/agent/doctor/docker_runtime_healthcheck.go +++ b/agent/doctor/docker_runtime_healthcheck.go @@ -25,6 +25,8 @@ import ( const systemPingTimeout = time.Second * 2 +var timeNow = time.Now + type dockerRuntimeHealthcheck struct { // HealthcheckType is the reported healthcheck type HealthcheckType string `json:"HealthcheckType,omitempty"` @@ -45,12 +47,13 @@ type dockerRuntimeHealthcheck struct { } func NewDockerRuntimeHealthcheck(client dockerapi.DockerClient) *dockerRuntimeHealthcheck { - nowTime := time.Now() + nowTime := timeNow() return &dockerRuntimeHealthcheck{ HealthcheckType: doctor.HealthcheckTypeContainerRuntime, Status: doctor.HealthcheckStatusInitializing, TimeStamp: nowTime, StatusChangeTime: nowTime, + LastTimeStamp: nowTime, client: client, } } diff --git a/agent/doctor/docker_runtime_healthcheck_test.go b/agent/doctor/docker_runtime_healthcheck_test.go index b4ad49e5b9c..21eec1ae62e 100644 --- a/agent/doctor/docker_runtime_healthcheck_test.go +++ b/agent/doctor/docker_runtime_healthcheck_test.go @@ -19,8 +19,23 @@ func TestNewDockerRuntimeHealthCheck(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() mockDockerClient := mock_dockerapi.NewMockDockerClient(ctrl) - dockerRuntimeHealthCheck := NewDockerRuntimeHealthcheck(mockDockerClient) - assert.Equal(t, doctor.HealthcheckStatusInitializing, dockerRuntimeHealthCheck.Status) + + // Mock the time to have predictable values + mockTime := time.Now() + originalTimeNow := timeNow + timeNow = func() time.Time { return mockTime } + defer func() { timeNow = originalTimeNow }() + + expectedDockerRuntimeHealthcheck := &dockerRuntimeHealthcheck{ + HealthcheckType: doctor.HealthcheckTypeContainerRuntime, + Status: doctor.HealthcheckStatusInitializing, + TimeStamp: mockTime, + StatusChangeTime: mockTime, + LastTimeStamp: mockTime, + client: mockDockerClient, + } + actualDockerRuntimeHealthcheck := NewDockerRuntimeHealthcheck(mockDockerClient) + assert.Equal(t, expectedDockerRuntimeHealthcheck, actualDockerRuntimeHealthcheck) } func TestRunCheck(t *testing.T) {