@@ -1008,11 +1008,46 @@ func TestAgent_Metadata(t *testing.T) {
1008
1008
})
1009
1009
1010
1010
t .Run ("Many" , func (t * testing.T ) {
1011
+ t .Parallel ()
1012
+ script := "echo -n hello"
1013
+ if runtime .GOOS == "windows" {
1014
+ script = "powershell " + script
1015
+ }
1016
+ //nolint:dogsled
1017
+ _ , client , _ , _ , _ := setupAgent (t , agentsdk.Manifest {
1018
+ Metadata : []codersdk.WorkspaceAgentMetadataDescription {
1019
+ {
1020
+ Key : "greeting" ,
1021
+ Interval : 1 ,
1022
+ Script : script ,
1023
+ },
1024
+ },
1025
+ }, 0 )
1026
+
1027
+ var gotMd map [string ]agentsdk.PostMetadataRequest
1028
+ require .Eventually (t , func () bool {
1029
+ gotMd = client .getMetadata ()
1030
+ return len (gotMd ) == 1
1031
+ }, testutil .WaitShort , testutil .IntervalMedium )
1032
+
1033
+ collectedAt1 := gotMd ["greeting" ].CollectedAt
1034
+ assert .Equal (t , "hello" , gotMd ["greeting" ].Value )
1035
+
1036
+ if ! assert .Eventually (t , func () bool {
1037
+ gotMd = client .getMetadata ()
1038
+ return gotMd ["greeting" ].CollectedAt .After (collectedAt1 )
1039
+ }, testutil .WaitShort , testutil .IntervalMedium ) {
1040
+ t .Fatalf ("expected metadata to be collected again" )
1041
+ }
1042
+ })
1043
+
1044
+ t .Run ("ManyTiming" , func (t * testing.T ) {
1011
1045
if runtime .GOOS == "windows" {
1012
1046
// Shell scripting in Windows is a pain, and we have already tested
1013
- // that the OS logic works in the simpler "Once" test above .
1047
+ // that the OS logic works in the simpler tests .
1014
1048
t .Skip ()
1015
1049
}
1050
+ testutil .SkipIfNotTiming (t )
1016
1051
t .Parallel ()
1017
1052
1018
1053
dir := t .TempDir ()
0 commit comments