7
7
import subprocess
8
8
import webtest
9
9
10
- from dcicutils .env_utils import get_mirror_env_from_context , is_stg_or_prd_env
10
+ from dcicutils .env_utils import EnvUtils , get_mirror_env_from_context , is_stg_or_prd_env
11
11
from dcicutils .ff_utils import get_health_page
12
12
from dcicutils .log_utils import set_logging
13
+ from dcicutils .secrets_utils import assume_identity
14
+ from dcicutils .misc_utils import override_environ
13
15
from codeguru_profiler_agent import Profiler
14
16
from sentry_sdk .integrations .pyramid import PyramidIntegration
15
17
from sentry_sdk .integrations .sqlalchemy import SqlalchemyIntegration
@@ -125,6 +127,15 @@ def main(global_config, **local_config):
125
127
"""
126
128
This function returns a Pyramid WSGI application.
127
129
"""
130
+ # If running in production (not a unit test or local deploy), assume identity
131
+ # and resolve EnvUtils
132
+ if not local_config .get ('testing' , False ):
133
+ identity = assume_identity ()
134
+
135
+ # Assume GAC and load env utils (once)
136
+ with override_environ (** identity ):
137
+ # load env_utils
138
+ EnvUtils .init ()
128
139
129
140
settings = global_config
130
141
settings .update (local_config )
@@ -208,7 +219,9 @@ def main(global_config, **local_config):
208
219
config .registry ['aws_ipset' ] = netaddr .IPSet (
209
220
record ['ip_prefix' ] for record in aws_ip_ranges ['prefixes' ] if record ['service' ] == 'AMAZON' )
210
221
211
- if asbool (settings .get ('testing' , False )):
222
+ doing_testing = asbool (settings .get ('testing' , False ))
223
+
224
+ if doing_testing :
212
225
config .include ('.tests.testing_views' )
213
226
214
227
# Load upgrades last so that all views (including testing views) are
@@ -220,7 +233,7 @@ def main(global_config, **local_config):
220
233
if is_stg_or_prd_env (current_env ):
221
234
sentry_sdk .
init (
"https://[email protected] /5379985" ,
222
235
integrations = [PyramidIntegration (), SqlalchemyIntegration ()])
223
- elif current_env is not None :
236
+ elif current_env is not None and not doing_testing :
224
237
sentry_sdk .
init (
"https://[email protected] /5373642" ,
225
238
integrations = [PyramidIntegration (), SqlalchemyIntegration ()])
226
239
0 commit comments