You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PULUMI_TEST_MODE environment variable doesn't work for Python applications. Instead users must set a flag programmatically in their Python application as shown below (for posterity's sake).
The PULUMI_TEST_MODE environment variable should work for all supported Pulumi languages. We should also document this officially.
For reference:
import pulumi
import unittest
import asyncio
# Import the Pulumi SDK and turn on test mode *before* allocating anything.
pulumi.runtime.settings._set_test_mode_enabled(True) # This should be able to be set via PULUMI_TEST_MODE
pulumi.runtime.settings._set_project('webserver')
pulumi.runtime.settings._set_stack('test')
# Tests come next:
def async_test(coro):
def wrapper(*args, **kwargs):
loop = asyncio.new_event_loop()
loop.run_until_complete(coro(*args, **kwargs))
loop.close()
return wrapper
class InstanceTests(unittest.TestCase):
@async_test
async def test_no_internet_access(self):
# Now import the infrastructure module which will allocate our resource objects.
from infra import group, server
# Rendezvous with the resource's resulting ingress rules.
ingress_fut = asyncio.Future()
group.ingress.apply(lambda ig: ingress_fut.set_result(ig))
ingress = await ingress_fut
# Now loop through them and reject any that are open to the Internet (0.0.0.0/0).
for rule in ingress:
for cidr in rule['cidr_blocks']:
self.assertNotEqual('0.0.0.0/0', cidr)
The text was updated successfully, but these errors were encountered:
The
PULUMI_TEST_MODE
environment variable doesn't work for Python applications. Instead users must set a flag programmatically in their Python application as shown below (for posterity's sake).The
PULUMI_TEST_MODE
environment variable should work for all supported Pulumi languages. We should also document this officially.For reference:
The text was updated successfully, but these errors were encountered: