-
-
Notifications
You must be signed in to change notification settings - Fork 86
agent: move subscriptions to pending when reconnecting servers #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
2069b86
adde613
4924573
ba1e551
11b725d
849f545
9f1a9a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ tRcvQueuesTests = do | |
| it "getDelSessQueues" getDelSessQueuesTest | ||
| describe "queue transfer" $ do | ||
| it "getDelSessQueues-batchAddQueues preserves total length" removeSubsTest | ||
| it "activeToPendingQueues" activeToPendingTest | ||
|
|
||
| checkDataInvariant :: RQ.TRcvQueues -> IO Bool | ||
| checkDataInvariant trq = atomically $ do | ||
|
|
@@ -76,7 +77,7 @@ batchIdempotentTest = do | |
| atomically $ RQ.batchAddQueues trq qs | ||
| checkDataInvariant trq `shouldReturn` True | ||
| readTVarIO (RQ.getRcvQueues trq) `shouldReturn` qs' | ||
| fmap L.nub <$> readTVarIO (RQ.getConnections trq) `shouldReturn`cs' -- connections get duplicated, but that doesn't appear to affect anybody | ||
| fmap L.nub <$> readTVarIO (RQ.getConnections trq) `shouldReturn` cs' -- connections get duplicated, but that doesn't appear to affect anybody | ||
|
|
||
| deleteConnTest :: IO () | ||
| deleteConnTest = do | ||
|
|
@@ -163,6 +164,33 @@ removeSubsTest = do | |
| atomically $ RQ.getDelSessQueues (0, "smp://1234-w==@beta", Just "c3") aq >>= RQ.batchAddQueues pq . fst | ||
| atomically (totalSize aq pq) `shouldReturn` (4, 4) | ||
|
|
||
| activeToPendingTest :: IO () | ||
| activeToPendingTest = do | ||
| aq <- atomically RQ.empty | ||
| let qs1 = | ||
| [ dummyRQ 0 "smp://1234-w==@alpha" "c1", | ||
| dummyRQ 0 "smp://1234-w==@alpha" "c2" | ||
| ] | ||
| atomically $ RQ.batchAddQueues aq qs1 | ||
|
|
||
| pq <- atomically RQ.empty | ||
| let qs2 = | ||
| [ dummyRQ 0 "smp://1234-w==@beta" "c3", | ||
| dummyRQ 1 "smp://1234-w==@beta" "c4" | ||
| ] | ||
| atomically $ RQ.batchAddQueues pq qs2 | ||
|
|
||
| atomically (totalSize aq pq) `shouldReturn` (4, 4) | ||
|
|
||
| prevActive <- atomically $ RQ.activeToPendingQueues aq pq | ||
| atomically (totalSize aq pq) `shouldReturn` (4, 4) | ||
| M.keys <$> readTVarIO (RQ.getConnections aq) `shouldReturn` [] | ||
| M.keys <$> readTVarIO (RQ.getConnections pq) `shouldReturn` ["c1", "c2", "c3", "c4"] | ||
| -- M.keys prevActive `shouldMatchList` [(0, "smp://1234-w==@alpha", ""), (0, "smp://1234-w==@alpha", "")] | ||
|
||
| M.keys prevActive `shouldMatchList` [(0, "smp://1234-w==@alpha", "c1"), (0, "smp://1234-w==@alpha", "c2")] | ||
| checkDataInvariant aq `shouldReturn` True | ||
| checkDataInvariant pq `shouldReturn` True | ||
|
|
||
| totalSize :: RQ.TRcvQueues -> RQ.TRcvQueues -> STM (Int, Int) | ||
| totalSize a b = do | ||
| qsizeA <- M.size <$> readTVar (RQ.getRcvQueues a) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.