data source 부분을 보완하기 위해 기존에 작성되었던 코드를 참고했다.
nas volume을 참고하였다.
결과 비교
nas volume
=== RUN TestAccDataSourceNcloudNasVolume_vpc_basic
d: &{map[custom_ip_list:0xc00037d900 description:0xc00037dcc0 filter:0xc00037d040 id:0xc00037c500 is_encrypted_volume:0xc000380000 is_event_configuration:0xc00037c780 is_return_protection:0xc000380140 is_snapshot_configuration:0xc00037c8c0 mount_information:0xc000380a00 name:0xc0003803c0 nas_volume_no:0xc000380280 server_instance_no_list:0xc00037d680 snapshot_volume_size:0xc000380640 volume_allotment_protocol_type:0xc00037d400 volume_allotment_protocol_type_code:0xc00037c640 volume_name_postfix:0xc00037d180 volume_size:0xc00037d2c0 volume_total_size:0xc000380500 zone:0xc00037ca00] <nil> <nil> 0xc00091a600 map[] <nil> {{<nil>} <nil>} 0xc00098e800 0xc00077c510 0xc0000d11e0 false {1 {0 0}} false true}
DataSource: &{map[custom_ip_list:0xc0005ea000 description:0xc0005ea3c0 filter:0xc0005ad680 id:0xc0005acb40 is_encrypted_volume:0xc0005ea640 is_event_configuration:0xc0005acdc0 is_return_protection:0xc0005ea780 is_snapshot_configuration:0xc0005acf00 mount_information:0xc0005eb040 name:0xc0005eaa00 nas_volume_no:0xc0005ea8c0 server_instance_no_list:0xc0005adcc0 snapshot_volume_size:0xc0005eac80 volume_allotment_protocol_type:0xc0005ada40 volume_allotment_protocol_type_code:0xc0005acc80 volume_name_postfix:0xc0005ad7c0 volume_size:0xc0005ad900 volume_total_size:0xc0005eab40 zone:0xc0005ad040] 0 <nil> [] <nil> 0x13aeb00 <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> false}
msListMap: [map[custom_ip_list:[] description: is_encrypted_volume:false is_event_configuration:false is_return_protection:false is_snapshot_configuration:false mount_information:169.254.82.86:/n3114855_tfhy97c name:n3114855_tfhy97c nas_volume_no:19679035 server_instance_no_list:[] snapshot_volume_size:0 volume_allotment_protocol_type:NFS volume_size:500 volume_total_size:500 zone:KR-2]]
msListMap[0]: map[custom_ip_list:[] description: is_encrypted_volume:false is_event_configuration:false is_return_protection:false is_snapshot_configuration:false mount_information:169.254.82.86:/n3114855_tfhy97c name:n3114855_tfhy97c nas_volume_no:19679035 server_instance_no_list:[] snapshot_volume_size:0 volume_allotment_protocol_type:NFS volume_size:500 volume_total_size:500 zone:KR-2]
mssql
$ go test ./internal/service/cloudmssql/cloud_mssql_data_source_test.go -run=TestAccDataSourceNcloudMssql_vpc_basic -v -timeout 180m
=== RUN TestAccDataSourceNcloudMssql_vpc_basic
d: &{map[backup_file_retention_period:0xc0000d8280 backup_time:0xc0000d83c0 filter:0xc0000d9b80 id:0xc0000d7b80 image_product_code:0xc0000d8640 instance_no:0xc0000d8780 is_backup:0xc0000d8140 is_ha:0xc0000d7e00 is_multi_zone:0xc0000d8000 port:0xc0000d8500 server_instance_list:0xc0000d9540 service_name:0xc0000d7cc0 subnet_no:0xc0000da000 user_name:0xc0000da780 user_password:0xc0000dadc0 vpc_no:0xc0000d9e00] <nil> <nil> 0xc000151880 map[] <nil> {{<nil>} <nil>} 0xc00049d7a0 0xc000b9aa98 0xc000873ba0 false {1 {0 0}} false true}
DataSource: &{map[backup_file_retention_period:0xc0004c7a40 backup_time:0xc0004c7b80 filter:0xc0004fdb80 id:0xc0004a3680 image_product_code:0xc0004c7e00 instance_no:0xc0004cc000 is_backup:0xc0004c7900 is_ha:0xc0004a3cc0 is_multi_zone:0xc0004c5180 port:0xc0004c7cc0 server_instance_list:0xc0004fa780 service_name:0xc0004a37c0 subnet_no:0xc000091540 user_name:0xc0000a1b80 user_password:0xc0004c2b40 vpc_no:0xc00008e000] 0 <nil> [] <nil> <nil> <nil> <nil> <nil> <nil> 0x149d580 <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> false}
msListMap: [map[cloudMssqlInstanceNo:19672389 cloudMssqlInstanceStatusName:running cloudMssqlServiceName:tf-mssql-xo7hh]]
msListMap[0]: map[cloudMssqlInstanceNo:19672389 cloudMssqlInstanceStatusName:running cloudMssqlServiceName:tf-mssql-xo7hh]
cloud_mssql_data_source_test.go:20: Step 1/1 error: Check failed: Check 2/8 error: data.ncloud_mssql.test: Attribute "vpc_no" not set, but "vpc_no" is set in ncloud_mssql.mssql as "47104"
--- FAIL: TestAccDataSourceNcloudMssql_vpc_basic (3221.45s)
FAIL
FAIL command-line-arguments 3222.136s
FAIL
list 받아오는 쪽에 문제가 있는 것 같다.
코드 수정하기
getCloudMssqlList 부분의 request 부분을 수정했다.
결과 비교
list를 받아오는 결과이다.
nas volume
req: &{0xc00071f618 <nil> <nil> <nil> [0xc0004b8e80] <nil> <nil> <nil> <nil> <nil> <nil>}
req list: [0xc0004b8e80]
resp: &{0xc0004b9180 0xc0004b9190 0xc0004b91a0 0xc00015d4e0 [0xc0002742d0]}
list: [0xc0002e7900]
mssql
$ go test ./internal/service/cloudmssql/cloud_mssql_data_source_test.go -run=TestAccDataSourceNcloudMssql_vpc_basic -v -timeout 180m
=== RUN TestAccDataSourceNcloudMssql_vpc_basic
req: &{[0xc00081b2e0] <nil> <nil> <nil> 0xc00061b4d8 <nil> <nil> <nil> <nil> <nil>}
req list: [0xc00081b2e0]
resp: &{0xc00050f1f0 0xc00050f200 0xc00050f210 0xc00003b8d0 [0xc0002933f0]}
list: [0xc00065a700]
크게 차이가 없는 것으로 보아 sdk 개발이 안 된 것으로 판단되었다.
그리고 수정하면서 알게 된 것은 mssql instance를 잘 가져오지 못한다는 것을 알게 되었고, 이를 제대로 가져올 수 있도록 dataSourceNcloudMssqlRead 함수를 수정하였다.
이번, data source 코드를 수정하면서, data source에 대한 개념이 잘 안잡혀있었다는 것을 느꼈다....
그래도 점점 발전해나가는 것 같다
'💻 개발 > Terraform on NaverCloud' 카테고리의 다른 글
MSSQL 가이드 문서 pr 반영하기 (0) | 2023.09.23 |
---|---|
MSSQL 가이드 문서 작성하기 (0) | 2023.09.21 |
MSSQL 개발하기 (2) & pr 올리기 (0) | 2023.09.21 |
MSSQL Test 하기 (0) | 2023.09.11 |
MSSQL 개발하기 (1) (0) | 2023.09.09 |