all-tests.dh 7.95 KB
Newer Older
1
  λ(dataDir : Text)
2 3
→ λ(manifestDir : Text)
→ λ(isTest : Bool)
Valentin Reis's avatar
Valentin Reis committed
4
→ let assetDir = dataDir ++ "test_assets/"
Valentin Reis's avatar
Valentin Reis committed
5
  
Valentin Reis's avatar
Valentin Reis committed
6
  let types = ./dhrunlib/types.dh
Valentin Reis's avatar
Valentin Reis committed
7
  
Valentin Reis's avatar
Valentin Reis committed
8
  let argotypes = ./argolib/types.dh
Valentin Reis's avatar
Valentin Reis committed
9
  
Valentin Reis's avatar
Valentin Reis committed
10
  let argo = ./argolib/package.dh
Valentin Reis's avatar
Valentin Reis committed
11
  
12
  let message = "HelloWorld"
Valentin Reis's avatar
Valentin Reis committed
13
  
14
  let cn = "testContainer"
Valentin Reis's avatar
Valentin Reis committed
15
  
Valentin Reis's avatar
Valentin Reis committed
16
  let idCmd = let id = λ(a : Type) → λ(x : a) → x in id types.Cmd
Valentin Reis's avatar
Valentin Reis committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  
  let dhrunTemplate =
          { cmds =
              [] : List types.Cmd
          , verbose =
              True
          , cleaning =
              True
          , workdir =
              "./_output"
          , pre =
              [] : List Text
          , post =
              [] : List Text
          }
        : types.Config
  
Valentin Reis's avatar
Valentin Reis committed
34 35 36 37 38 39
  let makeExtended =
          λ(daemonArg : argotypes.MkDaemon)
        → λ(daemonOverrides : types.Cmd → types.Cmd)
        → λ(runArg : argotypes.MkRun)
        → λ(runOverrides : types.Cmd → types.Cmd)
        → λ(extraCmds : List types.Cmd)
Valentin Reis's avatar
Valentin Reis committed
40 41
        →   dhrunTemplate
          ⫽ { cmds =
Valentin Reis's avatar
Valentin Reis committed
42 43 44 45 46
                  [ daemonOverrides (argo.nrmd.mk daemonArg)
                  , runOverrides (argo.run.mk runArg)
                  ]
                # extraCmds
            }
Valentin Reis's avatar
Valentin Reis committed
47
  
48 49 50 51 52
  let manifests =
        { basic =
            manifestDir ++ "basic.yml"
        , perf =
            manifestDir ++ "perfwrap.yml"
53 54
        , singularity =
            manifestDir ++ "singularity.yml"
55
        }
Valentin Reis's avatar
Valentin Reis committed
56
  
57 58 59 60 61
  let ifTest =
          λ(t : Type)
        → λ(default : t)
        → λ(value : t)
        → if isTest then value else default
Valentin Reis's avatar
Valentin Reis committed
62
  
63
  let ifTestList = ifTest (List Text) ([] : List Text)
Valentin Reis's avatar
Valentin Reis committed
64
  
65
  let withDaemon =
66 67
          λ(daemonArg : argotypes.MkDaemon)
        → λ(runArg : argotypes.MkRun)
68 69
        → λ(runOverrides : types.Cmd → types.Cmd)
        → λ(extraCmds : List types.Cmd)
Valentin Reis's avatar
Valentin Reis committed
70
        → makeExtended
71
          (   daemonArg
72 73 74 75
            ⫽ { daemonavoids =
                  ifTestList [ "Traceback", "ValueError" ]
              , powercap =
                  < NoCap = {=} | Cap : Text > : argotypes.Powercap
76 77
              }
          )
Valentin Reis's avatar
Valentin Reis committed
78 79
          idCmd
          (   runArg
80 81 82 83 84 85 86 87 88 89 90 91 92 93
            ⫽ { cmdavoids =
                  runArg.cmdavoids # ifTestList [ "Traceback", "ValueError" ]
              }
          )
          (   λ(c : types.Cmd)
            → runOverrides
              (   c
                ⫽ { timeout =
                      ifTest
                      (Optional Natural)
                      ([] : Optional Natural)
                      ([ 600 ] : Optional Natural)
                  }
              )
Valentin Reis's avatar
Valentin Reis committed
94
          )
95
          extraCmds
Valentin Reis's avatar
Valentin Reis committed
96
  
97 98 99
  let withDaemonNoExtras =
          λ(runArg : argotypes.MkRun)
        → λ(runOverrides : types.Cmd → types.Cmd)
100
        → withDaemon argo.nrmd.defarg runArg runOverrides ([] : List types.Cmd)
Valentin Reis's avatar
Valentin Reis committed
101
  
102 103 104 105
  let withDaemonExtraListen =
          λ(filter : Text)
        → λ(doFilter : Bool)
        → λ(runArg : argotypes.MkRun)
106 107
        → λ(runOverrides : types.Cmd → types.Cmd)
        → withDaemon
108
          argo.nrmd.defarg
109 110 111
          runArg
          runOverrides
          [ argo.listen.mk
112
            (argo.listen.defarg cn ⫽ { filter = filter, doFilter = doFilter })
113
          ]
Valentin Reis's avatar
Valentin Reis committed
114
  
Valentin Reis's avatar
Valentin Reis committed
115
  let withDaemonExtraProgresstest = withDaemonExtraListen "progress" True
Valentin Reis's avatar
Valentin Reis committed
116
  
117
  let mkrun =
118 119 120
          λ(manifest : Text)
        → λ(name : Text)
        → argo.run.defarg name manifest cn : argotypes.MkRun
Valentin Reis's avatar
Valentin Reis committed
121
  
122
  let basicRun = mkrun manifests.basic : Text → argotypes.MkRun
Valentin Reis's avatar
Valentin Reis committed
123
  
124
  let perfRun = mkrun manifests.perf : Text → argotypes.MkRun
Valentin Reis's avatar
Valentin Reis committed
125
  
126
  let singularityRun = mkrun manifests.singularity : Text → argotypes.MkRun
Valentin Reis's avatar
Valentin Reis committed
127
  
128
  in  { setpower =
Valentin Reis's avatar
Valentin Reis committed
129
          dhrunTemplate ⫽ { cmds = [ argo.nrmd.default, argo.setpower.default ] }
130 131 132 133 134 135 136 137 138
      , kill =
            dhrunTemplate
          ⫽ { cmds =
                [ argo.nrmd.default
                , argo.kill.default cn
                , argo.run.mk (basicRun "sleep" ⫽ { args = [ "13" ] })
                ]
            }
      , list =
Valentin Reis's avatar
Valentin Reis committed
139
          dhrunTemplate ⫽ { cmds = [ argo.nrmd.default, argo.list.default ] }
Valentin Reis's avatar
Valentin Reis committed
140
      , run =
Valentin Reis's avatar
Valentin Reis committed
141
          withDaemonNoExtras (basicRun "true") idCmd
142
      , pwd =
143
          let somedir = "toto"
Valentin Reis's avatar
Valentin Reis committed
144
          
145 146 147
          in  withDaemonNoExtras
              (basicRun "pwd" ⫽ { cmdwants = [ somedir ] : List Text })
              (λ(x : types.Cmd) → x ⫽ { otherwd = [ somedir ] : Optional Text })
148
      , exitcode =
149 150 151
          withDaemonNoExtras
          (basicRun "false")
          (λ(x : types.Cmd) → x ⫽ { exitcode = [ +1 ] : Optional Integer })
152
      , hello =
153 154 155
          withDaemonNoExtras
          (   basicRun "echo"
            ⫽ { args = [ message ], cmdwants = [ message ] : List Text }
156
          )
Valentin Reis's avatar
Valentin Reis committed
157
          idCmd
158
      , listen =
159 160 161
          withDaemonExtraListen
          ","
          False
162
          (basicRun "sleep" ⫽ { args = [ "1" ] })
Valentin Reis's avatar
Valentin Reis committed
163
          idCmd
164
      , power =
165 166 167
          withDaemonExtraListen
          "power"
          True
168
          (basicRun "sleep" ⫽ { args = [ "15" ] })
Valentin Reis's avatar
Valentin Reis committed
169
          idCmd
170
      , performance =
171 172 173
          withDaemonExtraListen
          "performance"
          True
Valentin Reis's avatar
Valentin Reis committed
174 175
          (perfRun "sleep" ⫽ { args = [ "15" ] })
          idCmd
176 177 178 179 180 181
      , run-singularity =
          withDaemon
          (argo.nrmd.defarg ⫽ { singularity = True })
          (singularityRun "true")
          idCmd
          ([] : List types.Cmd)
182
      , qmcpack =
Valentin Reis's avatar
Valentin Reis committed
183 184
          withDaemonExtraProgresstest
          (   basicRun "mpiexec"
185 186
            ⫽ { args =
                  [ if isTest then "2" else "24"
187
                  , "qmcpack"
188
                  , assetDir ++ "/simple-H2O.xml"
189
                  ]
190 191 192 193
              , cmdavoids =
                  [ "Error", "error", "ERROR" ]
              }
          )
Valentin Reis's avatar
Valentin Reis committed
194
          idCmd
195
      , lammps =
Valentin Reis's avatar
Valentin Reis committed
196 197
          withDaemonExtraProgresstest
          (   basicRun "mpiexec"
198
            ⫽ { args =
199 200 201 202 203 204
                  [ "-n"
                  , if isTest then "2" else "24"
                  , "-bind-to"
                  , "core"
                  , "lmp_mpi"
                  , "-i"
205
                  , assetDir ++ "/modified.lj"
206
                  ]
207 208 209 210
              , cmdavoids =
                  [ "Error", "error", "ERROR" ]
              }
          )
Valentin Reis's avatar
Valentin Reis committed
211
          idCmd
212
      , openmc =
Valentin Reis's avatar
Valentin Reis committed
213 214
            withDaemonExtraProgresstest
            (   basicRun "mpiexec"
215
              ⫽ { args =
216
                    [ "-n", if isTest then "2" else "24", "openmc" ]
217 218 219 220
                , cmdavoids =
                    [ "Error", "error", "ERROR" ]
                , passvars =
                    [ "OPENMC_CROSS_SECTIONS" ]
221 222
                }
            )
Valentin Reis's avatar
Valentin Reis committed
223 224 225 226
            idCmd
          ⫽ { pre =
                [ "cp --no-preserve=mode -r " ++ assetDir ++ "openmc/* ." ]
            }
227
      , amg =
Valentin Reis's avatar
Valentin Reis committed
228 229
          withDaemonExtraProgresstest
          (   basicRun "mpiexec"
230
            ⫽ { args =
231 232 233 234 235 236 237 238 239 240 241 242 243 244
                  [ "-n"
                  , if isTest then "2" else "24"
                  , "amg"
                  , "-problem"
                  , "2"
                  , "-n"
                  , "90"
                  , "90"
                  , "90"
                  , "-P"
                  , "2"
                  , if isTest then "1" else "12"
                  , "1"
                  ]
245 246 247 248 249 250 251
              , cmdavoids =
                  [ "Error", "error", "ERROR" ]
              }
          )
          (   λ(x : types.Cmd)
            → x ⫽ { vars = [ { varname = "OMP_NUM_THREADS", value = "1" } ] }
          )
252
      , stream =
Valentin Reis's avatar
Valentin Reis committed
253 254
          withDaemonExtraProgresstest
          (   basicRun "stream_c"
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
            ⫽ { args =
                  [] : List Text
              , cmdavoids =
                  [ "Error", "error", "ERROR" ]
              }
          )
          (   λ(x : types.Cmd)
            →   x
              ⫽ { vars =
                    [ { varname =
                          "OMP_NUM_THREADS"
                      , value =
                          if isTest then "2" else "24"
                      }
                    , { varname = "OMP_PLACES", value = "cores" }
                    ]
                }
          )
273
      }