-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Haskell to configure mithril in e2e tests
- Loading branch information
Showing
5 changed files
with
136 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Cardano.Launcher.Mithril where | ||
|
||
import qualified Data.ByteString as BS | ||
|
||
import Control.Monad.Extra | ||
( unlessM | ||
) | ||
import Network.HTTP.Simple | ||
( getResponseBody | ||
, httpBS | ||
, parseRequest | ||
) | ||
import Prelude | ||
import System.Directory | ||
( doesFileExist | ||
) | ||
import System.Info | ||
( arch | ||
, os | ||
) | ||
import System.Process | ||
( callProcess | ||
) | ||
|
||
-- | Download the latest snapshot node db into /db relative to the supplied dir. | ||
downloadLatestSnapshot :: FilePath -> FilePath -> IO () | ||
downloadLatestSnapshot outputParentDir mithril = do | ||
callProcess mithril ["cdb", "download", "latest", "--download-dir", outputParentDir] | ||
|
||
-- | Downloads the latest Mithril release package, | ||
-- extracts it, and returns the path to the mithril client executable. | ||
downloadMithril :: IO FilePath | ||
downloadMithril = do | ||
putStrLn $ "Downloading " <> mithrilPackage <> " from " <> downloadUrl | ||
req <- parseRequest downloadUrl | ||
response <- httpBS req | ||
BS.writeFile mithrilPackage (getResponseBody response) | ||
putStrLn $ "Downloaded " <> mithrilPackage | ||
|
||
-- Extract the gz archive using 7z. | ||
putStrLn $ "Extracting " <> mithrilPackage <> " using 7z..." | ||
callProcess "7z" ["x", mithrilPackage] | ||
|
||
-- Extract the tar archive. | ||
putStrLn $ "Extracting " <> mithrilTar <> " using tar..." | ||
callProcess "tar" ["xf", mithrilTar] -- TODO: skip interactive overwite check | ||
|
||
let clientPath = "mithril-client" <> if isWindows then ".exe" else "" | ||
unlessM (doesFileExist clientPath) $ | ||
fail $ unwords | ||
[ "downloadLatest: didn't find" | ||
, clientPath | ||
, "in mithril archive" | ||
] | ||
|
||
putStrLn $ "Mithril client available at: " <> clientPath | ||
return clientPath | ||
|
||
where | ||
isWindows = os == "mingw32" | ||
|
||
-- Define the platform and version. | ||
platform = osTag <> "-" <> osArch | ||
where | ||
|
||
osTag :: String | ||
osTag = case os of | ||
"darwin" -> "macos" | ||
"mingw32" -> "windows" | ||
other -> other | ||
|
||
osArch :: String | ||
osArch = case arch of | ||
"x86_64" -> "x64" | ||
other -> other | ||
|
||
version = "2450.0" | ||
mithrilTar = "mithril-" <> version <> "-" <> platform <> ".tar" | ||
mithrilPackage = mithrilTar <> ".gz" | ||
downloadUrl = "https://github.com/input-output-hk/mithril/releases/download/" | ||
<> version <> "/" <> mithrilPackage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,7 @@ | ||
set PATH=%PATH%;C:\Users\hal\AppData\Local\Microsoft\WinGet\Links | ||
|
||
REM ------------- mithril ------------- | ||
|
||
SET mithril-tar=mithril-2450.0-windows-x64.tar | ||
echo %mithril-tar% | ||
SET mithril-package=%mithril-tar%.gz | ||
echo %mithril-package% | ||
wget https://github.com/input-output-hk/mithril/releases/download/2450.0/%mithril-package% | ||
7z x .\%mithril-package% | ||
tar xf .\%mithril-tar% | ||
.\mithril-client.exe --version | ||
for /f "delims=" %%i in ('.\mithril-client.exe cdb snapshot list --json ^| jq -r .[0].digest') do set digest=%%i | ||
echo %digest% | ||
.\mithril-client.exe cdb download --download-dir . %digest% | ||
REM delete the old db folder | ||
REM this is stupid but will do for now | ||
mkdir %NODE_DB_DIR% | ||
rd /q /s %NODE_DB_DIR% | ||
REM move the new db folder entirely into the old db folder | ||
move .\db %NODE_DB_DIR% | ||
ls %NODE_DB_DIR% | ||
|
||
REM ------------- ruby tests ------------- | ||
|
||
cd test\e2e | ||
call bundle install | ||
call bundle exec rake get_latest_windows_tests[%BUILDKITE_BRANCH%,bins,any,latest] | ||
cd ..\.. | ||
|
||
echo %NODE_DB_DIR% | ||
echo %WALLET_DB_DIR% | ||
test\e2e\bins\cardano-wallet-integration-test-e2e.exe | ||
bins\cardano-wallet-integration-test-e2e.exe | ||
exit /b %ERRORLEVEL% |