Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/gitsecrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gomod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion agent/doctor/docker_runtime_healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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,
}
}
Expand Down
19 changes: 17 additions & 2 deletions agent/doctor/docker_runtime_healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading