Skip to content

Commit 35c69f1

Browse files
committed
Make the sharding group a cli parameter
It will be different for every pod.
1 parent 1ce5189 commit 35c69f1

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

charts/integration/templates/configmap.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,4 @@ data:
306306
integrationTestHostName: integration-headless.{{ .Release.Namespace }}.svc.cluster.local
307307
cellsEventQueue: cells_events
308308
shardingGroupCount: {{ .Values.config.shardingGroupCount }}
309-
shardingGroup: {{ .Values.config.shardingGroup }}
310309
maxUserNo: {{ .Values.config.maxUserNo }}

charts/integration/templates/integration-integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ spec:
183183
- |
184184
set -euo pipefail
185185
186-
if TEST_INCLUDE=testBench integration --config /etc/wire/integration/integration.yaml; then
186+
if TEST_INCLUDE=testBench integration --config /etc/wire/integration/integration.yaml --sharding-group {{ .Values.config.shardingGroup }}; then
187187
exit_code=$?
188188
else
189189
exit_code=$?

integration/test/Testlib/Env.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ serviceHostPort m Stern = m.stern
4545
serviceHostPort m FederatorInternal = m.federatorInternal
4646
serviceHostPort m WireServerEnterprise = m.wireServerEnterprise
4747

48-
mkGlobalEnv :: FilePath -> Codensity IO GlobalEnv
49-
mkGlobalEnv cfgFile = do
48+
mkGlobalEnv :: FilePath -> Word -> Codensity IO GlobalEnv
49+
mkGlobalEnv cfgFile shardingGroup = do
5050
eith <- liftIO $ Yaml.decodeFileEither cfgFile
5151
intConfig <- liftIO $ case eith of
5252
Left err -> do
@@ -130,7 +130,7 @@ mkGlobalEnv cfgFile = do
130130
gCellsEventWatchersLock,
131131
gCellsEventWatchers,
132132
gShardingGroupCount = intConfig.shardingGroupCount,
133-
gShardingGroup = intConfig.shardingGroup,
133+
gShardingGroup = shardingGroup,
134134
gMaxUserNo = intConfig.maxUserNo
135135
}
136136
where

integration/test/Testlib/Options.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ data TestOptions = TestOptions
1010
excludeTests :: [String],
1111
listTests :: Bool,
1212
xmlReport :: Maybe FilePath,
13-
configFile :: String
13+
configFile :: String,
14+
shardingGroup :: Word
1415
}
1516

1617
parser :: Parser TestOptions
@@ -47,6 +48,13 @@ parser =
4748
<> help "Use configuration FILE"
4849
<> value "services/integration.yaml"
4950
)
51+
<*> option
52+
auto
53+
( long "sharding-group"
54+
<> short 's'
55+
<> help "The sharding group of this instance"
56+
<> value 0
57+
)
5058

5159
optInfo :: ParserInfo TestOptions
5260
optInfo =

integration/test/Testlib/Run.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ main = do
106106
opts <- getOptions
107107
let f = testFilter opts
108108
cfg = opts.configFile
109+
shardingGroup = opts.shardingGroup
109110

110111
allTests <- mkAllTests
111112
let tests =
@@ -115,10 +116,10 @@ main = do
115116
let qualifiedName = fromMaybe module_ (stripPrefix "Test." module_) <> "." <> name
116117
in (qualifiedName, summary, full, action)
117118

118-
if opts.listTests then doListTests tests else runTests tests opts.xmlReport cfg
119+
if opts.listTests then doListTests tests else runTests tests opts.xmlReport cfg shardingGroup
119120

120-
runTests :: [(String, x, y, App ())] -> Maybe FilePath -> FilePath -> IO ()
121-
runTests tests mXMLOutput cfg = do
121+
runTests :: [(String, x, y, App ())] -> Maybe FilePath -> FilePath -> Word -> IO ()
122+
runTests tests mXMLOutput cfg shardingGroup = do
122123
output <- newChan
123124
let displayOutput =
124125
readChan output >>= \case
@@ -163,7 +164,7 @@ runTests tests mXMLOutput cfg = do
163164
where
164165
mkEnvs :: FilePath -> Codensity IO (GlobalEnv, Env)
165166
mkEnvs fp = do
166-
g <- mkGlobalEnv fp
167+
g <- mkGlobalEnv fp shardingGroup
167168
e <- mkEnv Nothing g
168169
pure (g, e)
169170

integration/test/Testlib/RunServices.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ main = do
7171
let cp = proc "sh" (["-c", "exec \"$@\"", "--"] <> opts.runSubprocess)
7272
(_, _, _, ph) <- createProcess cp
7373
exitWith =<< waitForProcess ph
74+
-- The shardingGroup only matters for the testBench test; probably not here.
75+
shardingGroup = 0
7476

75-
runCodensity (mkGlobalEnv cfg >>= mkEnv Nothing) $ \env ->
77+
runCodensity (mkGlobalEnv cfg shardingGroup >>= mkEnv Nothing) $ \env ->
7678
runAppWithEnv env
7779
$ lowerCodensity
7880
$ do

integration/test/Testlib/Types.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ data IntegrationConfig = IntegrationConfig
148148
dnsMockServer :: DNSMockServerConfig,
149149
cellsEventQueue :: String,
150150
shardingGroupCount :: Word,
151-
shardingGroup :: Word,
152151
maxUserNo :: Word
153152
}
154153
deriving (Show, Generic)
@@ -171,7 +170,6 @@ instance FromJSON IntegrationConfig where
171170
<*> o .: fromString "dnsMockServer"
172171
<*> o .: fromString "cellsEventQueue"
173172
<*> o .: fromString "shardingGroupCount"
174-
<*> o .: fromString "shardingGroup"
175173
<*> o .: fromString "maxUserNo"
176174

177175
data ServiceMap = ServiceMap

services/integration.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,5 +332,4 @@ additionalElasticSearch: https://localhost:9201
332332
cellsEventQueue: cells_events
333333

334334
shardingGroupCount: 1
335-
shardingGroup: 0
336335
maxUserNo: 1000

0 commit comments

Comments
 (0)