As a Gmail admin, one of your tasks is creating rules to manage spam, email content, and email attachments for your organization. You might need new rules when you add a G Suite service or feature, or when you’re setting up security for Gmail.
When creating rules, you usually have to change and test them several times to make sure they work correctly for your organization. Each time you change a rule, it can take up to 24 hours for the change to take effect across your entire organization.
We recommend you try out new rules in a test environment with only a few users. A small test environment lets you test rules more quickly than testing them across your entire organization. After you verify the rules in a test environment, you can apply them to the entire organization.
Use some or all of these best practices to minimize the time it takes to test new and changed rules:
Best practices for rules test environment
Create a test environment with a few users. A small test environment lets you quickly update rules, and verify how they affect email flow and delivery. The size of the environment where the rule is used directly affects how long it takes for the rule to update. Learn more about what affects the speed of rule updates.
Use one of these types of test environments:
- Secondary test domain (recommended): Create a secondary test domain with 2–50 users. A test domain provides the most flexibility when creating rules. You can test how new rules affect an entire domain. Assign Super Admin privileges to any admin testing rules in this domain, so they can test without restrictions.
- Test organizational unit: Create a test organizational unit with 2–24 users. Read how parent organizational units can affect tests.
Set up the test domain just like your primary domain. If you use a secondary test domain, set it up like your primary domain so that rules behavior mimics what will happen in your primary domain.
Remove any extra rules from the test environment. Add only the rules you’re testing to the test environment. If you’ve tested rules in this environment in the past, remove any old rules.
- Tests take longer because the test organizational units includes the rules from its parent. More rules increase the test time.
- It’s more difficult to isolate and identify which rules cause issues during tests, because child organizational units inherit rules from the parent.
We recommend you avoid testing rules with groups because:
- Rule update time corresponds to group size (number of members). It can be difficult to determine a Group’s size and predict how long it takes to update rules for a group.
- It’s more complex to test rules and isolate issues for nested groups.
Best practices for creating and testing rules
Test rules with real data. Test the same type of email attachments and content (including secure content) that you normally use in your organization.
Don’t use expressions with long strings or long lists. Avoid using expressions with more than 1000 characters, and lists with more than 1000 elements. Long expressions need more time to take effect than shorter expressions. Long expressions are also more likely to have errors that require troubleshooting.
Before applying rules to the test environment, check the rule syntax. Check the rule syntax with real data to get results similar to what you'll see in your organization:
- When you create or update a rule in the Admin console with Add setting, click Test expression to make sure the rule syntax is correct.
- Test your data with these pre-defined classifiers that trigger rules. (Opens Cloud DLP demo.)
Add only the rules you’re testing to the test environment. We recommend your test environment has only the rules you’re testing. Multiple rules and the order in which they’re applied can impact message behavior. If you need to test how a new rule interacts with rules already in your primary domain, copy the rule into a test organizational unit that is a child of the organizational unit that has existing rules.
Learn more about how multiple rules affect message behavior.
Don’t use group-based policies. Group-based policies often take up to 24 hours to take effect, even for smaller groups. When you add a new rule with Add Setting, uncheck Groups under the Account types to affect option.
Use a unique email subject line for each message used to test a rule. Unique subject lines help you identify which rules have been applied to test messages. Email log search lists messages by subject line. Each message entry indicates which rule was applied to the message.
Every time you update a rule, change the rule name. If you have to update and test a rule several times, the unique rule name indicates which version of the rule you’re testing. Email log search shows rules by name.
Best practices for verifying rules
Use Email log search to check which rules have been applied to test messages. Email log search lets you find test messages, and shows which rule was applied to each message.