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