Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Fix cloudflare_load_balancer acceptance tests #214

Merged
merged 4 commits into from
Feb 24, 2019

Conversation

radeksimko
Copy link
Contributor

This is to fix the following 6 test failures (and some others which are surfaced once the original problem w/ incorrect LB name is fixed).

=== RUN   TestAccCloudflareLoadBalancer_Basic
--- FAIL: TestAccCloudflareLoadBalancer_Basic (1.15s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.bbtsrbpzwp: 1 error(s) occurred:
        
        * cloudflare_load_balancer.bbtsrbpzwp: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-bbtsrbpzwp: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"
=== RUN   TestAccCloudflareLoadBalancer_CreateAfterManualDestroy
--- FAIL: TestAccCloudflareLoadBalancer_CreateAfterManualDestroy (1.14s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.d329b81ogm: 1 error(s) occurred:
        
        * cloudflare_load_balancer.d329b81ogm: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-d329b81ogm: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"
=== RUN   TestAccCloudflareLoadBalancer_GeoBalanced
--- FAIL: TestAccCloudflareLoadBalancer_GeoBalanced (1.15s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.w2qe47q6y7: 1 error(s) occurred:
        
        * cloudflare_load_balancer.w2qe47q6y7: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-w2qe47q6y7: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"
=== RUN   TestAccCloudflareLoadBalancer_Import
--- FAIL: TestAccCloudflareLoadBalancer_Import (1.13s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.39e90jidqz: 1 error(s) occurred:
        
        * cloudflare_load_balancer.39e90jidqz: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-39e90jidqz: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"
=== RUN   TestAccCloudflareLoadBalancer_SessionAffinity
--- FAIL: TestAccCloudflareLoadBalancer_SessionAffinity (1.14s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.71wotayjlm: 1 error(s) occurred:
        
        * cloudflare_load_balancer.71wotayjlm: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-session-affinity-71wotayjlm: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"
=== RUN   TestAccCloudflareLoadBalancer_Update
--- FAIL: TestAccCloudflareLoadBalancer_Update (1.14s)
    testing.go:527: Step 0 error: Error applying: 1 error(s) occurred:
        
        * cloudflare_load_balancer.pqkk7u7tvr: 1 error(s) occurred:
        
        * cloudflare_load_balancer.pqkk7u7tvr: error creating load balancer for zone: error from makeRequest: HTTP status 400: content "{\n  \"result\": null,\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": 1002,\n      \"message\": \"invalid hostname: tf-testacc-lb-pqkk7u7tvr: validation failed\"\n    }\n  ],\n  \"messages\": []\n}\n"

I'm not sure if the LB resource should just automatically stick the zone name at the end of LB name if it's missing, but that is IMO a discussion for a separate issue/PR. This is aiming to merely fix existing failing tests.

 - This avoid spurious diffs of this resource when `steering_policy` is not defined in config
   as demonstrated by this failing test:

```
--- FAIL: TestAccCloudflareLoadBalancer_CreateAfterManualDestroy (4.08s)
    testing.go:527: Step 1 error: After applying this step, the plan was not empty:

        DIFF:

        UPDATE: cloudflare_load_balancer.vmc92sw22l
          steering_policy: "off" => ""
```

 - We cannot set `Default` for this field because default value varies
   based on other settings (per API docs)
 - This helps us to detect any drifts (changes outside of Terraform)
   and make import work correctly, i.e. fix this test failure:

```
--- FAIL: TestAccCloudflareLoadBalancer_Import (2.90s)
    testing.go:527: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) {
        }

        (map[string]string) (len=1) {
         (string) (len=16) "session_affinity": (string) (len=4) "none"
        }
```
@radeksimko radeksimko added the kind/bug Categorizes issue or PR as related to a bug. label Feb 24, 2019
@ghost ghost added the size/XS label Feb 24, 2019
@radeksimko
Copy link
Contributor Author

Also I'm thinking we should perhaps update the docs (both API and Terraform) to make it clear that FQDN (incl. the zone) is expected.

@ghost ghost added the kind/documentation Categorizes issue or PR as related to documentation. label Feb 24, 2019
Copy link
Member

@jacobbednarz jacobbednarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love your work! 🙇

@jacobbednarz jacobbednarz merged commit 56b5a1b into master Feb 24, 2019
@jacobbednarz jacobbednarz deleted the t-fix-invalid-lb-names branch February 24, 2019 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/documentation Categorizes issue or PR as related to documentation. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants