Skip to content

Commit

Permalink
More kubelet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedos committed Feb 26, 2025
1 parent 407ff22 commit 6ed7532
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions comp/core/workloadmeta/collectors/internal/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ func TestPodParser(t *testing.T) {
"cpu": resource.MustParse("100m"),
},
},
Env: []kubelet.EnvVar{
{
Name: "ExplicitEnvVar",
Value: "true",
},
{
Name: "ImplicitEnvVar",
Value: "",
ValueFrom: &struct{}{},
},
},
},
},
},
Expand Down Expand Up @@ -121,8 +132,10 @@ func TestPodParser(t *testing.T) {
Kind: "kubernetes_pod",
ID: "uniqueIdentifier",
},
Ports: []workloadmeta.ContainerPort{},
EnvVars: map[string]string{},
Ports: []workloadmeta.ContainerPort{},
EnvVars: map[string]string{
"ExplicitEnvVar": "true",
},
State: workloadmeta.ContainerState{
Health: "healthy",
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/kubernetes/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,10 @@ func (suite *KubeletTestSuite) TestContainerEnvVars() {
require.NotNil(suite.T(), nginxContainer)

expectedEnvVars := []EnvVar{
// Variable explicitly defined in the pod spec
{Name: "DEFINED_VAR", Value: "true"},
// Variable from an external source (eg. ConfigMap, Secret, Downward API, etc.)
{Name: "UNDEFINED_VAR", Value: "", ValueFrom: &struct{}{}},
}
assert.ElementsMatch(suite.T(), nginxContainer.Env, expectedEnvVars)
}
Expand Down

0 comments on commit 6ed7532

Please sign in to comment.