Skip to content

Commit

Permalink
[CLOUD-144] Update acceptance tests and examples for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
maismail authored Jan 4, 2023
1 parent 0f910c0 commit f459606
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BREAKING CHANGES:
ENHANCEMENTS:
* datasource/aws_instance_profile_policy: Deprecate `enable_eks_and_ecr` attribute to use `enable_eks` and `enable_ecr` instead
* datasource/azure_user_assigned_identity_permissions: Deprecate `enable_aks_and_acr` attribute to use `enable_aks` and `enable_acr` instead
* Update acceptance tests and examples for new release

BUG FIXES:

Expand Down
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ sweep:
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
go test ./hopsworksai -v -sweep="all" $(SWEEPARGS) -timeout 60m

cleanupacc:
@echo "Cleanup acceptance test resources"
./test-fixtures/cleanup-acceptance-tests.sh

.PHONY: build testacc generate test fmt lint sweep coverage
3 changes: 1 addition & 2 deletions acceptance-test.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ pipeline {
always {
junit 'report.xml'
sh '''
cd test-fixtures
terraform destroy -auto-approve || terraform destroy -auto-approve
make cleanupacc
'''
}
}
Expand Down
3 changes: 2 additions & 1 deletion docs/data-sources/aws_instance_profile_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ data "hopsworksai_aws_instance_profile_policy" "policy" {
# remove eks and ecr permissions
data "hopsworksai_aws_instance_profile_policy" "policy" {
enable_eks_and_ecr = false
enable_eks = false
enable_ecr = false
}
```

Expand Down
13 changes: 13 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ data "hopsworksai_instance_type" "smallest_worker" {
region = module.azure.location
}
resource "azurerm_container_registry" "acr" {
name = "tfhopsworksbasic"
resource_group_name = module.azure.resource_group
location = module.azure.location
sku = "Premium"
admin_enabled = false
retention_policy {
enabled = true
days = 7
}
}
resource "hopsworksai_cluster" "cluster" {
name = "tf-hopsworks-cluster"
ssh_key = module.azure.ssh_key_pair_name
Expand All @@ -205,6 +217,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = module.azure.storage_account_name
}
acr_registry_name = azurerm_container_registry.acr.name
}
rondb {
Expand Down
3 changes: 2 additions & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = "mystorage"
}
acr_registry_name = "registry-name"
}
rondb {
Expand Down Expand Up @@ -123,7 +124,7 @@ resource "hopsworksai_cluster" "cluster" {
- `tags` (Map of String) The list of custom tags to be attached to the cluster.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `update_state` (String) The action you can use to start or stop the cluster. It has to be one of these values [none, start, stop]. Defaults to `none`.
- `version` (String) The version of the cluster. For existing clusters, you can change this attribute to upgrade to a newer version of Hopsworks. If the upgrade process ended up in an error state, you can always rollback to the old version by resetting this attribute to the old version. Defaults to `3.0.0`.
- `version` (String) The version of the cluster. For existing clusters, you can change this attribute to upgrade to a newer version of Hopsworks. If the upgrade process ended up in an error state, you can always rollback to the old version by resetting this attribute to the old version. Defaults to `3.1.0`.
- `workers` (Block Set) The configurations of worker nodes. You can add as many as you want of this block to create workers with different configurations. (see [below for nested schema](#nestedblock--workers))

### Read-Only
Expand Down
13 changes: 13 additions & 0 deletions examples/complete/azure/autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ data "hopsworksai_instance_type" "small_worker" {
min_cpus = 4
}

resource "azurerm_container_registry" "acr" {
name = "tfhopsworksbasic"
resource_group_name = module.azure.resource_group
location = module.azure.location
sku = "Premium"
admin_enabled = false
retention_policy {
enabled = true
days = 7
}
}

resource "hopsworksai_cluster" "cluster" {
name = "tf-hopsworks-cluster"
ssh_key = module.azure.ssh_key_pair_name
Expand All @@ -73,6 +85,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = module.azure.storage_account_name
}
acr_registry_name = azurerm_container_registry.acr.name
}

rondb {
Expand Down
13 changes: 13 additions & 0 deletions examples/complete/azure/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ data "hopsworksai_instance_type" "large_worker" {
min_cpus = 4
}

resource "azurerm_container_registry" "acr" {
name = "tfhopsworksbasic"
resource_group_name = module.azure.resource_group
location = module.azure.location
sku = "Premium"
admin_enabled = false
retention_policy {
enabled = true
days = 7
}
}

resource "hopsworksai_cluster" "cluster" {
name = "tf-hopsworks-cluster"
ssh_key = module.azure.ssh_key_pair_name
Expand Down Expand Up @@ -82,6 +94,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = module.azure.storage_account_name
}
acr_registry_name = azurerm_container_registry.acr.name
}

rondb {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ data "hopsworksai_aws_instance_profile_policy" "policy" {

# remove eks and ecr permissions
data "hopsworksai_aws_instance_profile_policy" "policy" {
enable_eks_and_ecr = false
enable_eks = false
enable_ecr = false
}
13 changes: 13 additions & 0 deletions examples/provider/provider_azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ data "hopsworksai_instance_type" "smallest_worker" {
region = module.azure.location
}

resource "azurerm_container_registry" "acr" {
name = "tfhopsworksbasic"
resource_group_name = module.azure.resource_group
location = module.azure.location
sku = "Premium"
admin_enabled = false
retention_policy {
enabled = true
days = 7
}
}

resource "hopsworksai_cluster" "cluster" {
name = "tf-hopsworks-cluster"
ssh_key = module.azure.ssh_key_pair_name
Expand All @@ -76,6 +88,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = module.azure.storage_account_name
}
acr_registry_name = azurerm_container_registry.acr.name
}

rondb {
Expand Down
1 change: 1 addition & 0 deletions examples/resources/hopsworksai_cluster/resource_azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ resource "hopsworksai_cluster" "cluster" {
container {
storage_account = "mystorage"
}
acr_registry_name = "registry-name"
}

rondb {
Expand Down
5 changes: 2 additions & 3 deletions hopsworksai/data_source_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func testAccClusterDataSourceConfig(cloud api.CloudProvider, rName string, suffi
%s
tags = {
"%s" = "%s"
"Test" = "TestAccClusterDataSource_basic"
%s
}
}
Expand All @@ -74,8 +74,7 @@ func testAccClusterDataSourceConfig(cloud api.CloudProvider, rName string, suffi
testCollectLogs(cloud),
testRonDBConfig(cloud),
testAccClusterCloudConfigAttributes(cloud, 0, false),
default_CLUSTER_TAG_KEY,
default_CLUSTER_TAG_VALUE,
testAccDefaultTags(),
rName,
rName,
)
Expand Down
5 changes: 2 additions & 3 deletions hopsworksai/data_source_clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func testAccClustersDataSourceConfig(cloud api.CloudProvider, rName string, suff
tags = {
"ListClusters" = "%s"
"%s" = "%s"
"Test" = "TestAccClustersDataSource_basic"
%s
}
}
Expand All @@ -118,8 +118,7 @@ func testAccClustersDataSourceConfig(cloud api.CloudProvider, rName string, suff
testRonDBConfig(cloud),
testAccClusterCloudConfigAttributes(cloud, 1, false),
cloud.String(),
default_CLUSTER_TAG_KEY,
default_CLUSTER_TAG_VALUE,
testAccDefaultTags(),
rName,
rName,
)
Expand Down
17 changes: 14 additions & 3 deletions hopsworksai/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
const (
env_API_KEY = "HOPSWORKSAI_API_KEY"

env_TEST_RUN_SUFFIX = "TF_HOPSWORKSAI_TEST_SUFFIX"
env_AWS_SKIP = "TF_HOPSWORKSAI_AWS_SKIP"
env_AWS_REGION = "TF_HOPSWORKSAI_AWS_REGION"
env_AWS_SSH_KEY = "TF_HOPSWORKSAI_AWS_SSH_KEY"
Expand All @@ -36,6 +37,7 @@ const (
env_AZURE_VIRTUAL_NETWORK_NAME = "TF_HOPSWORKSAI_AZURE_VIRTUAL_NETWORK_NAME"
env_AZURE_SUBNET_NAME = "TF_HOPSWORKSAI_AZURE_SUBNET_NAME"
env_AZURE_SECURITY_GROUP_NAME = "TF_HOPSWORKSAI_AZURE_SECURITY_GROUP_NAME"
env_AZURE_ACR_REGISTRY_NAME = "TF_HOPSWORKSAI_AZURE_ACR_REGISTRY_NAME"

num_AWS_BUCKETS_NEEDED = 11
)
Expand Down Expand Up @@ -70,7 +72,7 @@ func parallelTest(t *testing.T, cloud api.CloudProvider, test resource.TestCase)
func testAccPreCheck(t *testing.T) func() {
return func() {
testCheckEnv(t, "", env_API_KEY)

testCheckEnv(t, "", env_TEST_RUN_SUFFIX)
if !isAWSAccSkipped() {
testCheckEnv(t, fmt.Sprintf("You can skip AWS tests by setting %s=true", env_AWS_SKIP),
env_AWS_REGION,
Expand All @@ -96,7 +98,8 @@ func testAccPreCheck(t *testing.T) func() {
env_AZURE_USER_ASSIGNED_IDENTITY_NAME,
env_AZURE_VIRTUAL_NETWORK_NAME,
env_AZURE_SUBNET_NAME,
env_AZURE_SECURITY_GROUP_NAME)
env_AZURE_SECURITY_GROUP_NAME,
env_AZURE_ACR_REGISTRY_NAME)
}
}
}
Expand Down Expand Up @@ -169,7 +172,8 @@ func testAccClusterCloudConfigAttributes(cloud api.CloudProvider, bucketIndex in
storage_account = "%s"
}
user_assigned_managed_identity = "%s"
`, os.Getenv(env_AZURE_LOCATION), os.Getenv(env_AZURE_RESOURCE_GROUP), os.Getenv(env_AZURE_STORAGE_ACCOUNT), os.Getenv(env_AZURE_USER_ASSIGNED_IDENTITY_NAME))
acr_registry_name = "%s"
`, os.Getenv(env_AZURE_LOCATION), os.Getenv(env_AZURE_RESOURCE_GROUP), os.Getenv(env_AZURE_STORAGE_ACCOUNT), os.Getenv(env_AZURE_USER_ASSIGNED_IDENTITY_NAME), os.Getenv(env_AZURE_ACR_REGISTRY_NAME))
var networkConfig = ""
if setNetwork {
networkConfig = fmt.Sprintf(`
Expand All @@ -190,6 +194,13 @@ func testAccClusterCloudConfigAttributes(cloud api.CloudProvider, bucketIndex in
return ""
}

func testAccDefaultTags() string {
return fmt.Sprintf(`
"Run" = "%s"
"%s" = "%s"
`, os.Getenv(env_TEST_RUN_SUFFIX), default_CLUSTER_TAG_KEY, default_CLUSTER_TAG_VALUE)
}

func testAccResourceDataSourceCheckAllAttributes(resourceName string, dataSourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
Expand Down
5 changes: 2 additions & 3 deletions hopsworksai/resource_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func testAccBackupConfig(cloud api.CloudProvider, rName string, suffix string, e
%s
tags = {
"%s" = "%s"
"Test" = "%s"
%s
}
}
Expand All @@ -170,9 +170,8 @@ func testAccBackupConfig(cloud api.CloudProvider, rName string, suffix string, e
testRonDBConfig(cloud),
testAccClusterCloudConfigAttributes(cloud, bucketIndex, setNetwork),
extraConfig,
default_CLUSTER_TAG_KEY,
default_CLUSTER_TAG_VALUE,
test,
testAccDefaultTags(),
backupConfig,
)
}
Expand Down
2 changes: 1 addition & 1 deletion hopsworksai/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func clusterSchema() map[string]*schema.Schema {
Description: "The version of the cluster. For existing clusters, you can change this attribute to upgrade to a newer version of Hopsworks. If the upgrade process ended up in an error state, you can always rollback to the old version by resetting this attribute to the old version.",
Type: schema.TypeString,
Optional: true,
Default: "3.0.0",
Default: "3.1.0",
},
"head": {
Description: "The configurations of the head node of the cluster.",
Expand Down
Loading

0 comments on commit f459606

Please sign in to comment.