Skip to content

Commit

Permalink
Utilise version test util (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Bruinhout authored Nov 22, 2022
1 parent 3e1243b commit 434193a
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions internal/elasticsearch/index/ilm_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package index_test

import (
"context"
"fmt"
"testing"

"github.com/elastic/terraform-provider-elasticstack/internal/acctest"
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
"github.com/elastic/terraform-provider-elasticstack/internal/versionutils"
"github.com/hashicorp/go-version"
sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestAccResourceILM(t *testing.T) {
),
},
{
SkipFunc: serverVersionLessThanTotalShardsPerNodeLimit,
SkipFunc: versionutils.CheckIfVersionIsUnsupported(totalShardsPerNodeVersionLimit),
Config: testAccResourceILMTotalShardsPerNode(policyName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "name", policyName),
Expand All @@ -77,18 +77,6 @@ func TestAccResourceILM(t *testing.T) {
},
})
}
func serverVersionLessThanTotalShardsPerNodeLimit() (bool, error) {
client, err := clients.NewAcceptanceTestingClient()
if err != nil {
return false, err
}
serverVersion, diags := client.ServerVersion(context.Background())
if diags.HasError() {
return false, fmt.Errorf("failed to parse the elasticsearch version %v", diags)
}

return serverVersion.LessThan(totalShardsPerNodeVersionLimit), nil
}

func testAccResourceILMCreate(name string) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 434193a

Please sign in to comment.