From dd1fcfd663fdf2266cc8d4740ec81a57c151ce3e Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Tue, 27 Feb 2024 18:01:33 +0100 Subject: [PATCH 1/8] flexible_gpu_link: accept 'allocated' state for unlink Signed-off-by: Matthias Gatto --- outscale/resource_outscale_flexible_gpu_link.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/outscale/resource_outscale_flexible_gpu_link.go b/outscale/resource_outscale_flexible_gpu_link.go index e664e328a..815163ad5 100644 --- a/outscale/resource_outscale_flexible_gpu_link.go +++ b/outscale/resource_outscale_flexible_gpu_link.go @@ -174,7 +174,8 @@ func resourceOutscaleOAPIFlexibleGpuLinkDelete(d *schema.ResourceData, meta inte if len(*resp.FlexibleGpus) != 1 { return fmt.Errorf("Unable to find Flexible GPU") } - if (*resp.FlexibleGpus)[0].GetState() != "detaching" { + if (*resp.FlexibleGpus)[0].GetState() != "detaching" && + (*resp.FlexibleGpus)[0].GetState() != "allocated" { return fmt.Errorf("Unable to unlink Flexible GPU") } } From 355529a62d3529d5ff225085fe1caf5842c10042 Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Thu, 29 Feb 2024 12:01:41 +0100 Subject: [PATCH 2/8] add local-test.sh Signed-off-by: Matthias Gatto --- .github/workflows/others_testacc.yml | 7 +++++++ local-test.sh | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 local-test.sh diff --git a/.github/workflows/others_testacc.yml b/.github/workflows/others_testacc.yml index ec80555b6..e3d425350 100644 --- a/.github/workflows/others_testacc.yml +++ b/.github/workflows/others_testacc.yml @@ -34,6 +34,13 @@ jobs: uses: actions/setup-go@v5 with: go-version: 'stable' + - name: local tests + run: | + wget https://github.com/outscale/osc-ricochet-2/releases/download/v0.2.0/osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz + tar -xvf osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz + ./ricochet-2 & + ./local-test.sh + - name: Build go test run: make test env: diff --git a/local-test.sh b/local-test.sh new file mode 100755 index 000000000..81129d19a --- /dev/null +++ b/local-test.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +export TEST_QUOTA="true" +export OSC_ENDPOINT_API="http://127.0.0.1:3000" +#OUTSCALE_ACCESSKEYID`, `OUTSCALE_SECRETKEYID`, `OUTSCALE_REGION`, `OUTSCALE_ACCOUNT` and `OUTSCALE_IMAGEID +export OUTSCALE_SECRETKEYID="0000001111112222223333334444445555555666" +export OUTSCALE_ACCESSKEYID="11112211111110000000" +export OUTSCALE_REGION="eu-west-2" +export OUTSCALE_IMAGEID="ami-ffffff00" +export OUTSCALE_ACCOUNT="00000000" +set -e +TF_LOG=DEBUG make testacc TESTARGS='-run=TestAccVM_withFlexibleGpuLink_basic' From 013a7d47417bea9ddccbf42a4070bbf79f1eaaac Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Mon, 4 Mar 2024 16:40:41 +0100 Subject: [PATCH 3/8] fix TestAccOthers_Volume_io1Type Signed-off-by: Matthias Gatto --- outscale/resource_outscale_volume_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/outscale/resource_outscale_volume_test.go b/outscale/resource_outscale_volume_test.go index b302d3b34..545d00cff 100644 --- a/outscale/resource_outscale_volume_test.go +++ b/outscale/resource_outscale_volume_test.go @@ -187,7 +187,7 @@ func test_IO1VolumeTypeConfig(region string) string { return fmt.Sprintf(` resource "outscale_volume" "test-io1" { subregion_name = "%sa" - volume_type = "gp2" + volume_type = "io1" size = 10 iops = 100 } From 6c26ae850745f44a3159847f1e66aa44acc38100 Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Mon, 4 Mar 2024 16:41:19 +0100 Subject: [PATCH 4/8] fix local tests for new ricochet-2 Signed-off-by: Matthias Gatto --- local-test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/local-test.sh b/local-test.sh index 81129d19a..321f0a520 100755 --- a/local-test.sh +++ b/local-test.sh @@ -1,12 +1,16 @@ #!/bin/sh export TEST_QUOTA="true" +export IS_IO1_TEST_QUOTA="true" export OSC_ENDPOINT_API="http://127.0.0.1:3000" #OUTSCALE_ACCESSKEYID`, `OUTSCALE_SECRETKEYID`, `OUTSCALE_REGION`, `OUTSCALE_ACCOUNT` and `OUTSCALE_IMAGEID export OUTSCALE_SECRETKEYID="0000001111112222223333334444445555555666" export OUTSCALE_ACCESSKEYID="11112211111110000000" +export OSC_ACCESS_KEY="11112211111110000000" export OUTSCALE_REGION="eu-west-2" export OUTSCALE_IMAGEID="ami-ffffff00" export OUTSCALE_ACCOUNT="00000000" +export OUTSCALE_KEYPAIR="my_craft" set -e +TF_LOG=DEBUG make testacc TESTARGS='-run=TestAccOthers_Volume_io1Type' TF_LOG=DEBUG make testacc TESTARGS='-run=TestAccVM_withFlexibleGpuLink_basic' From de3210142ac6978c19f2ca9c7173626776cb6ced Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Mon, 4 Mar 2024 16:42:15 +0100 Subject: [PATCH 5/8] load ricochet-2 config Signed-off-by: Matthias Gatto --- .github/workflows/others_testacc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/others_testacc.yml b/.github/workflows/others_testacc.yml index e3d425350..005f5f44b 100644 --- a/.github/workflows/others_testacc.yml +++ b/.github/workflows/others_testacc.yml @@ -38,7 +38,7 @@ jobs: run: | wget https://github.com/outscale/osc-ricochet-2/releases/download/v0.2.0/osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz tar -xvf osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz - ./ricochet-2 & + ./ricochet-2 ./ricochet.json & ./local-test.sh - name: Build go test From dcab25c76d5b0b8b8424e55e8ae1897a707779ce Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Thu, 7 Mar 2024 11:49:28 +0100 Subject: [PATCH 6/8] move local-test.sh to scripts/, add a Makefile rule for it Signed-off-by: Matthias Gatto --- .github/workflows/others_testacc.yml | 2 +- GNUmakefile | 5 +++++ local-test.sh => scripts/local-test.sh | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) rename local-test.sh => scripts/local-test.sh (62%) diff --git a/.github/workflows/others_testacc.yml b/.github/workflows/others_testacc.yml index 005f5f44b..6e0ca8a7d 100644 --- a/.github/workflows/others_testacc.yml +++ b/.github/workflows/others_testacc.yml @@ -39,7 +39,7 @@ jobs: wget https://github.com/outscale/osc-ricochet-2/releases/download/v0.2.0/osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz tar -xvf osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz ./ricochet-2 ./ricochet.json & - ./local-test.sh + make test-locally - name: Build go test run: make test diff --git a/GNUmakefile b/GNUmakefile index 66cfcf1dc..f7a71a096 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -60,6 +60,11 @@ test-compile: fi go test -c $(TEST) $(TESTARGS) +.PHONY: test-locally +test-locally: + "$(CURDIR)/scripts/local-test.sh" TestAccOthers_Volume_io1Type + "$(CURDIR)/scripts/local-test.sh" TestAccVM_withFlexibleGpuLink_basic + .PHONY: test-examples test-examples: @sh -c "'$(CURDIR)/scripts/test-examples.sh'" diff --git a/local-test.sh b/scripts/local-test.sh similarity index 62% rename from local-test.sh rename to scripts/local-test.sh index 321f0a520..7bc6e59fb 100755 --- a/local-test.sh +++ b/scripts/local-test.sh @@ -3,7 +3,6 @@ export TEST_QUOTA="true" export IS_IO1_TEST_QUOTA="true" export OSC_ENDPOINT_API="http://127.0.0.1:3000" -#OUTSCALE_ACCESSKEYID`, `OUTSCALE_SECRETKEYID`, `OUTSCALE_REGION`, `OUTSCALE_ACCOUNT` and `OUTSCALE_IMAGEID export OUTSCALE_SECRETKEYID="0000001111112222223333334444445555555666" export OUTSCALE_ACCESSKEYID="11112211111110000000" export OSC_ACCESS_KEY="11112211111110000000" @@ -11,6 +10,6 @@ export OUTSCALE_REGION="eu-west-2" export OUTSCALE_IMAGEID="ami-ffffff00" export OUTSCALE_ACCOUNT="00000000" export OUTSCALE_KEYPAIR="my_craft" + set -e -TF_LOG=DEBUG make testacc TESTARGS='-run=TestAccOthers_Volume_io1Type' -TF_LOG=DEBUG make testacc TESTARGS='-run=TestAccVM_withFlexibleGpuLink_basic' +TF_LOG=DEBUG make testacc TESTARGS="-run=$1" From e3365f6cf838c6445aa09f2000213ef2adae2d72 Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Thu, 7 Mar 2024 11:56:39 +0100 Subject: [PATCH 7/8] CONTRIBUTING.md: add ricochet-2 documentation Signed-off-by: Matthias Gatto --- CONTRIBUTING.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c7710d65..49cfda273 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,3 +45,19 @@ $ export OUTSCALE_ACCOUNT="" # i.e. "XXXXXXXXXXXX" ```sh $ make testacc ``` + +If you want, you can tests terraform locally using [ricochet-2](https://github.com/outscale/osc-ricochet-2/) +to do so, you need to get ricochet-2 [release](https://github.com/outscale/osc-ricochet-2/tags) +extract and start it: +``` +tar -xvf osc-ricochet-2_v0.2.0_x86_64-unknown-linux-musl.tar.gz +./ricochet-2 ./ricochet.json +``` +and in another terminal, either call `make test-locally`, or call the script manually +``` +# if you want TestAccVM_withFlexibleGpuLink_basic +scripts/local-test.sh TestAccVM_withFlexibleGpuLink_basic +``` + +Note that ricochet-2 been fearly new, doesn't support all Outscale Calls, and some tests will fails. +Also ricochet-2 work only on Linux for now. From cc574072f52929468ff39a24bab60e5f58cebb54 Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Fri, 15 Mar 2024 16:38:32 +0100 Subject: [PATCH 8/8] add utils in make fmt Signed-off-by: Matthias Gatto --- GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/GNUmakefile b/GNUmakefile index f7a71a096..82c655679 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -39,6 +39,7 @@ test-others: fmtcheck test-gen-cert .PHONY: fmt fmt: + gofmt -s -w ./utils/ gofmt -s -w ./main.go gofmt -s -w ./$(PKG_NAME)