You might need to prepare external server with a specific configuration before running a test. This can be achieved by creating a special context.
There are two ways to do so:
1. Create ECL Context containing directives stopping, starting server and preparing filesystem state.
Example:
ServerReset.ctx:
exec-process /bin/bash /etc/init.d/server stop
copy-file "/repository/server.config" "/tmp"
exec-process /bin/bash /etc/init.d/server start
You can make this approach reusable by creating an additional ECL
Context defining procedures "start" and "stop":
ServerProcedures.ctx:
proc "startServer" {exec-process /bin/bash /etc/init.d/server start}
proc "stopServer" {exec-process /bin/bash /etc/init.d/server stop}
ServerShortMemory.ctx:
stopServer
copy-file "/repository/serverShortMemory.config" "/tmp" -name "server.config"
startServer
ServerPort8080.ctx:
stopServer
copy-file "/repository/serverPort8080.config" "/tmp" -name "server.config"
startServer
Of course you are free to use external scripts to manage files too
(using exec-process). write-lines command could be used to create
small configuration files.
2. Create Folder Context and use it between two ECL contexts:
Example:
ServerStop.ctx:
exec-process /bin/bash /etc/init.d/server stop
ServerConfig.ctx (Folder Context):
/tmp/server.config
ServerStart.ctx:
exec-process /bin/bash /etc/init.d/server start
Likewise, alternative configurations can be supplied by replacing
ServerConfig.ctx.
While these approaches are (almost) functionally equivalent, you might
try them both to find out which one would be more convenient for your
use case.
You can reuse popular combinations of contexts by putting them into Group Context, this way you will only have to put thee or two contexts in very specific tests, using group context in conventional ones.