Skip to content

Commit

Permalink
Merge branch 'wireapp:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
offsoc authored Oct 18, 2024
2 parents 38b3c5c + 0f192f8 commit 8264602
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 58 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ ci:
cr: c db-migrate
./dist/run-services

crm: c db-migrate
./dist/run-services -m

# Run integration from new test suite
# Usage: make devtest
# Usage: TEST_INCLUDE=test1,test2 make devtest
Expand All @@ -134,7 +137,7 @@ devtest:
ghcid --command 'cabal repl integration' --test='Testlib.Run.mainI []'

.PHONY: sanitize-pr
sanitize-pr:
sanitize-pr:
make lint-all-shallow
make git-add-cassandra-schema
@git diff-files --quiet -- || ( echo "There are unstaged changes, please take a look, consider committing them, and try again."; exit 1 )
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/fix-nginx-paths
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nginz/local-conf: Update list of endpoints
1 change: 1 addition & 0 deletions changelog.d/5-internal/inbucket
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dockerephemeral: Use inbucket for SMTP
1 change: 1 addition & 0 deletions changelog.d/5-internal/make-crm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Makefile: Add target `crm` to run services tuned for manual usage
6 changes: 4 additions & 2 deletions deploy/dockerephemeral/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ services:

basic_smtp: # needed for demo setup
container_name: demo_wire_smtp
image: ixdotai/smtp:v0.5.2
image: inbucket/inbucket:latest
ports:
- 127.0.0.1:2500:25
- 127.0.0.1:2500:2500
- 127.0.0.1:1100:1100
- 127.0.0.1:9000:9000
networks:
- demo_wire

Expand Down
23 changes: 23 additions & 0 deletions docs/src/developer/developer/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,26 @@ After all containers are up you can use these Makefile targets to run the tests
```
`TASTY_NUM_THREADS` can also be set to other values, it defaults to number of cores available.
## How to run the webapp locally against locally running backend
1. Clone the webapp from: https://github.com/wireapp/wire-webapp
2. Install these depedencies needed for the webapp:
1. nodejs
2. yarn
3. mkcert
3. Copy `.env.localhost` to `.env` and uncomment the local section
4. Run the webapp using:
```bash
yarn
yarn start
```
4. From wire-server repo start the dependencies using:
```bash
./deploy/dockerephemeral/run.sh
```
5. From wire-server repo start the backend using:
```bash
make crm
```
6. Go to http://localhost:8081 in the browser.
6 changes: 4 additions & 2 deletions hack/bin/cabal-run-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ run_integration_tests() {
then
cd "$TOP_LEVEL"
"$TOP_LEVEL/dist/run-services" \
"$TOP_LEVEL/dist/integration" \
"${@:2}"
-- \
"$TOP_LEVEL/dist/integration" \
"${@:2}"
else
service_dir="$TOP_LEVEL/services/$package"

cd "$service_dir"
"$TOP_LEVEL/dist/run-services" \
-- \
"$TOP_LEVEL/dist/$package-integration" \
-s "$service_dir/$package.integration.yaml" \
-i "$TOP_LEVEL/services/integration.yaml" \
Expand Down
17 changes: 17 additions & 0 deletions integration/test/Testlib/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ setField ::
setField selector v x = do
modifyField @a @Value selector (\_ -> pure (toJSON v)) x

-- | Merges fields if the old and new are both Objects or Arrays. Otherwise new
-- field overwrites the old completely
mergeField :: forall a b. (HasCallStack, MakesValue a, ToJSON b) => String -> b -> a -> App Value
mergeField selector v x = do
modifyField @a @Value
selector
( \case
Just (Object old) -> case toJSON v of
(Object new) -> pure $ Object (new <> old)
nonObjectNew -> pure nonObjectNew
Just (Array old) -> case toJSON v of
(Array new) -> pure $ Array (old <> new)
nonArrayNew -> pure nonArrayNew
_ -> pure (toJSON v)
)
x

member :: (HasCallStack, MakesValue a) => String -> a -> App Bool
member k x = KM.member (KM.fromString k) <$> (make x >>= asObject)

Expand Down
69 changes: 60 additions & 9 deletions integration/test/Testlib/RunServices.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Testlib.RunServices where
module Testlib.RunServices (main) where

import Control.Concurrent
import Control.Monad.Codensity
import Options.Applicative
import System.Directory
import System.Environment (getArgs)
import System.Exit (exitWith)
import System.Exit
import System.FilePath
import System.Posix (getWorkingDirectory)
import System.Process
Expand All @@ -31,23 +31,43 @@ findProjectRoot path = do
Nothing -> pure Nothing
Just p -> findProjectRoot p

data Opts = Opts
{ withManualTestingOverrides :: Bool,
runSubprocess :: [String]
}
deriving (Show)

optsParser :: Parser Opts
optsParser =
Opts
<$> switch
( long "with-manual-testing-overrides"
<> short 'm'
<> help "Run services with settings tuned for manual app usage (not recommended for running integration tests)"
)
<*> many
( strArgument
( metavar "COMMAND_WITH_ARGS"
<> help "When specified, the command will be run after services have started and service will be killed after the command exits"
)
)

main :: IO ()
main = do
cwd <- getWorkingDirectory
mbProjectRoot <- findProjectRoot cwd
opts <- execParser (info (optsParser <**> helper) fullDesc)
cfg <- case mbProjectRoot of
Nothing -> error "Could not find project root. Please make sure you call run-services from somewhere in wire-server."
Just projectRoot ->
pure $ joinPath [projectRoot, "services/integration.yaml"]

args <- getArgs

let run = case args of
let run = case opts.runSubprocess of
[] -> do
putStrLn "services started"
forever (threadDelay 1000000000)
forever (threadDelay maxBound)
_ -> do
let cp = proc "sh" (["-c", "exec \"$@\"", "--"] <> args)
let cp = proc "sh" (["-c", "exec \"$@\"", "--"] <> opts.runSubprocess)
(_, _, _, ph) <- createProcess cp
exitWith =<< waitForProcess ph

Expand All @@ -57,6 +77,37 @@ main = do
$ do
_modifyEnv <-
traverseConcurrentlyCodensity
(\r -> void $ startDynamicBackend r mempty)
( \r ->
void
$ if opts.withManualTestingOverrides
then startDynamicBackend r manualTestingOverrides
else startDynamicBackend r mempty
)
[backendA, backendB]
liftIO run

manualTestingOverrides :: ServiceOverrides
manualTestingOverrides =
let smtpEndpoint = object ["host" .= "localhost", "port" .= (2500 :: Int)]
authSettings =
object
[ "userTokenTimeout" .= (4838400 :: Int),
"sessionTokenTimeout" .= (86400 :: Int),
"accessTokenTimeout" .= (900 :: Int),
"providerTokenTimeout" .= (900 :: Int),
"legalHoldUserTokenTimeout" .= (4838400 :: Int),
"legalHoldAccessTokenTimeout" .= (900 :: Int)
]
in def
{ brigCfg =
mergeField "emailSMS.email.smtpEndpoint" smtpEndpoint
>=> setField "emailSMS.email.smtpConnType" "plain"
>=> removeField "emailSMS.email.sesQueue"
>=> removeField "emailSMS.email.sesEndpoint"
>=> mergeField "zauth.authSettings" authSettings
>=> setField @_ @Int "optSettings.setActivationTimeout" 3600
>=> setField @_ @Int "optSettings.setVerificationTimeout" 3600
>=> setField @_ @Int "optSettings.setTeamInvitationTimeout" 3600
>=> setField @_ @Int "optSettings.setUserCookieRenewAge" 1209600
>=> removeField "optSettings.setSuspendInactiveUsers"
}
Loading

0 comments on commit 8264602

Please sign in to comment.