-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize IO time for getting all feature configs (#4002)
Co-authored-by: Leif Battermann <[email protected]> Co-authored-by: Matthias Fischmann <[email protected]>
- Loading branch information
1 parent
9fff6f9
commit 92be9fc
Showing
20 changed files
with
758 additions
and
425 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog.d/3-bug-fixes/wpb8713-get-feature-configs-end-point-performance
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 @@ | ||
Optimize getting all feature configs |
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,92 @@ | ||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} | ||
|
||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2024 Wire Swiss GmbH <[email protected]> | ||
-- | ||
-- This program is free software: you can redistribute it and/or modify it under | ||
-- the terms of the GNU Affero General Public License as published by the Free | ||
-- Software Foundation, either version 3 of the License, or (at your option) any | ||
-- later version. | ||
-- | ||
-- This program is distributed in the hope that it will be useful, but WITHOUT | ||
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
-- details. | ||
-- | ||
-- You should have received a copy of the GNU Affero General Public License along | ||
-- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
module Test.Wire.API.Team.Feature (tests) where | ||
|
||
import Imports | ||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
import Wire.API.Team.Feature | ||
|
||
tests :: TestTree | ||
tests = | ||
testGroup | ||
"Wire.API.Team.Feature" | ||
[ testCase "no lock status in DB" testComputeFeatureConfigForTeamUserLsIsNothing, | ||
testCase "feature is locked in DB" testComputeFeatureConfigForTeamUserLocked, | ||
testCase "feature is unlocked in DB but has no feature status" testComputeFeatureConfigForTeamUserUnlocked, | ||
testCase "feature is unlocked in DB and has feature status" testComputeFeatureConfigForTeamWithDbStatus | ||
] | ||
|
||
testComputeFeatureConfigForTeamUserLsIsNothing :: Assertion | ||
testComputeFeatureConfigForTeamUserLsIsNothing = do | ||
let mStatusDb = undefined | ||
let mLockStatusDb = Nothing | ||
let defStatus = | ||
withStatus | ||
FeatureStatusEnabled | ||
LockStatusLocked | ||
ExposeInvitationURLsToTeamAdminConfig | ||
FeatureTTLUnlimited | ||
let expected = defStatus | ||
let actual = computeFeatureConfigForTeamUser @ExposeInvitationURLsToTeamAdminConfig mStatusDb mLockStatusDb defStatus | ||
actual @?= expected | ||
|
||
testComputeFeatureConfigForTeamUserLocked :: Assertion | ||
testComputeFeatureConfigForTeamUserLocked = do | ||
let mStatusDb = undefined | ||
let mLockStatusDb = Just LockStatusLocked | ||
let defStatus = | ||
withStatus | ||
FeatureStatusEnabled | ||
LockStatusLocked | ||
ExposeInvitationURLsToTeamAdminConfig | ||
FeatureTTLUnlimited | ||
let expected = defStatus | ||
let actual = computeFeatureConfigForTeamUser @ExposeInvitationURLsToTeamAdminConfig mStatusDb mLockStatusDb defStatus | ||
actual @?= expected | ||
|
||
testComputeFeatureConfigForTeamUserUnlocked :: Assertion | ||
testComputeFeatureConfigForTeamUserUnlocked = do | ||
let mStatusDb = Nothing | ||
let mLockStatusDb = Just LockStatusUnlocked | ||
let defStatus = | ||
withStatus | ||
FeatureStatusEnabled | ||
LockStatusLocked | ||
ExposeInvitationURLsToTeamAdminConfig | ||
FeatureTTLUnlimited | ||
let expected = defStatus & setLockStatus LockStatusUnlocked | ||
let actual = computeFeatureConfigForTeamUser @ExposeInvitationURLsToTeamAdminConfig mStatusDb mLockStatusDb defStatus | ||
actual @?= expected | ||
|
||
testComputeFeatureConfigForTeamWithDbStatus :: Assertion | ||
testComputeFeatureConfigForTeamWithDbStatus = do | ||
let mStatusDb = | ||
Just . forgetLock $ | ||
withStatus | ||
FeatureStatusDisabled | ||
LockStatusUnlocked | ||
ExposeInvitationURLsToTeamAdminConfig | ||
FeatureTTLUnlimited | ||
let mLockStatusDb = Just LockStatusUnlocked | ||
let defStatus = undefined | ||
let (Just expected) = withUnlocked <$> mStatusDb | ||
let actual = computeFeatureConfigForTeamUser @ExposeInvitationURLsToTeamAdminConfig mStatusDb mLockStatusDb defStatus | ||
actual @?= expected |
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
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
Oops, something went wrong.