Skip to content

chore: update kitchen config #2114

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

Conversation

wyardley
Copy link
Contributor

@wyardley wyardley commented Sep 25, 2024

With the test kitchen version (3.5) used by the tests, there are some parameters which have moved to new locations.

Follow the suggestions of kitchen doctor.

@wyardley wyardley requested review from ericyz, gtsorbo and a team as code owners September 25, 2024 05:48
@apeabody
Copy link
Collaborator

/gcbrun

@wyardley wyardley force-pushed the wyardley/chore/kitchen_doctor branch from e1bb643 to f46135c Compare September 25, 2024 16:05
@apeabody
Copy link
Collaborator

/gcbrun

@apeabody
Copy link
Collaborator

Hmm, I'll re-trigger just to be sure.

-----> Starting Test Kitchen (v3.5.0)
-----> Converging <stub-domains-local>...
$$$$$$ Reading the Terraform client version...
       Terraform v1.9.6
       on linux_amd64
       + provider registry.terraform.io/hashicorp/google v6.4.0
       + provider registry.terraform.io/hashicorp/kubernetes v2.32.0
       + provider registry.terraform.io/hashicorp/random v3.6.3
$$$$$$ Finished reading the Terraform client version.
$$$$$$ Verifying the Terraform client version is in the supported interval of >= 0.11.4, < 2.0.0...
$$$$$$ Finished verifying the Terraform client version.
$$$$$$ Selecting the kitchen-terraform-stub-domains-local Terraform workspace...
       Switched to workspace "kitchen-terraform-stub-domains-local".
$$$$$$ Finished selecting the kitchen-terraform-stub-domains-local Terraform workspace.
$$$$$$ Downloading the modules needed for the Terraform configuration...
$$$$$$ Finished downloading the modules needed for the Terraform configuration.
$$$$$$ Validating the Terraform configuration files...
       Success! The configuration is valid.
       
$$$$$$ Finished validating the Terraform configuration files.
$$$$$$ Building the infrastructure based on the Terraform configuration...
       
       Error: No value for required variable
       
         on variables.tf line 19:
         19: variable "project_id" {
       
       The root module input variable "project_id" is not set, and has no default
       value. Use a -var or -var-file command line argument to provide a value for
       this variable.
       
       Error: No value for required variable
       
         on variables.tf line 24:
         24: variable "name" {
       
       The root module input variable "name" is not set, and has no default value.
       Use a -var or -var-file command line argument to provide a value for this
       variable.
       
       Error: No value for required variable
       
         on variables.tf line 53:
         53: variable "network" {
       
       The root module input variable "network" is not set, and has no default
       value. Use a -var or -var-file command line argument to provide a value for
       this variable.
       
       Error: No value for required variable
       
         on variables.tf line 64:
         64: variable "subnetwork" {
       
       The root module input variable "subnetwork" is not set, and has no default
       value. Use a -var or -var-file command line argument to provide a value for
       this variable.
       
       Error: No value for required variable
       
         on variables.tf line 135:
        135: variable "ip_range_pods" {
       
       The root module input variable "ip_range_pods" is not set, and has no default
       value. Use a -var or -var-file command line argument to provide a value for
       this variable.
       
       Error: No value for required variable
       
         on variables.tf line 146:
        146: variable "ip_range_services" {
       
       The root module input variable "ip_range_services" is not set, and has no
       default value. Use a -var or -var-file command line argument to provide a
       value for this variable.
>>>>>> Expected process to exit with [0], but received '1'
---- Begin output of terraform apply -auto-approve -lock=true -lock-timeout=0s -input=false -no-color -parallelism=10 -refresh=true   ----
STDOUT: 
STDERR: Error: No value for required variable

  on variables.tf line 19:
  19: variable "project_id" {

The root module input variable "project_id" is not set, and has no default
value. Use a -var or -var-file command line argument to provide a value for
this variable.

Error: No value for required variable

  on variables.tf line 24:
  24: variable "name" {

The root module input variable "name" is not set, and has no default value.
Use a -var or -var-file command line argument to provide a value for this
variable.

Error: No value for required variable

  on variables.tf line 53:
  53: variable "network" {

The root module input variable "network" is not set, and has no default
value. Use a -var or -var-file command line argument to provide a value for
this variable.

Error: No value for required variable

  on variables.tf line 64:
  64: variable "subnetwork" {

The root module input variable "subnetwork" is not set, and has no default
value. Use a -var or -var-file command line argument to provide a value for
this variable.

Error: No value for required variable

  on variables.tf line 135:
 135: variable "ip_range_pods" {

The root module input variable "ip_range_pods" is not set, and has no default
value. Use a -var or -var-file command line argument to provide a value for
this variable.

Error: No value for required variable

  on variables.tf line 146:
 146: variable "ip_range_services" {

The root module input variable "ip_range_services" is not set, and has no
default value. Use a -var or -var-file command line argument to provide a
value for this variable.
---- End output of terraform apply -auto-approve -lock=true -lock-timeout=0s -input=false -no-color -parallelism=10 -refresh=true   ----
Ran terraform apply -auto-approve -lock=true -lock-timeout=0s -input=false -no-color -parallelism=10 -refresh=true   returned 1
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <stub-domains-local>.  Please see .kitchen/logs/stub-domains-local.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

@wyardley
Copy link
Contributor Author

I can repro that error locally, even without creds or a valid project setup... I'll take a look 🤔

@wyardley
Copy link
Contributor Author

kitchen-terraform is the latest version in the container too, so it's not an old version thing.
What's odd is that if I revert the changes either fully or in part, I still get this if I try to run kitchen converge shared-vpc-local or source /usr/local/bin/task_helper_functions.sh && kitchen_do converge shared-vpc-local

│ Error: No value for required variable
│ 
│   on variables.tf line 17:
│   17: variable "project_ids" {
│ 
│ The root module input variable "project_ids" is not set, and has no default
│ value. Use a -var or -var-file command line argument to provide a value for
│ this variable.
╵

Anyway, if you have any pointers as to where this may be going wrong or where these vars are supposed to come from (a var file somewhere?), I can investigate more, or we can close this if it's taking your time for no good reason.

@apeabody
Copy link
Collaborator

kitchen-terraform is the latest version in the container too, so it's not an old version thing. What's odd is that if I revert the changes either fully or in part, I still get this if I try to run kitchen converge shared-vpc-local or source /usr/local/bin/task_helper_functions.sh && kitchen_do converge shared-vpc-local

│ Error: No value for required variable
│ 
│   on variables.tf line 17:
│   17: variable "project_ids" {
│ 
│ The root module input variable "project_ids" is not set, and has no default
│ value. Use a -var or -var-file command line argument to provide a value for
│ this variable.
╵

Anyway, if you have any pointers as to where this may be going wrong or where these vars are supposed to come from (a var file somewhere?), I can investigate more, or we can close this if it's taking your time for no good reason.

Thanks @wyardley!

We strongly encourage that all new tests be written using CFT, rather than Kitchen, so it's been a while since I've used it significantly. However this inspec file might be useful for the variables: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/master/test/integration/stub_domains/inspec.yml

Ideally these Kitchen tests would be re-written using CFT, so keep that in mind before you invest a lot of time in this space. :)

@wyardley
Copy link
Contributor Author

wyardley commented Sep 25, 2024

We strongly encourage that all new tests be written using CFT, rather than Kitchen

Right, understood... was really just trying to fix what seemed to be a very simple deprecation warning, but if it ends up being too involved, probably not worth it. I've worked with test kitchen pretty extensively in the past, but haven't touched it for a couple of years.

That said, might be good to update the help text to make it more clear, as well as to provide links to whatever docs exist about the new framework.

From a quick look, it had seemed like maybe kitchen was still used for provisioning, and that the go tests were just called instead of inspec for verification, but maybe I misunderstood.

Either way, since kitchen-terraform is deprecated, totally understand the move to something else (also see #2108 -- while I'm mostly talking about unit testing with mocked provider or plan-only there, the native tests could be used for provisioning directly as well)

@wyardley
Copy link
Contributor Author

Also, I think the inspec config is for verification vs. planning? In this case, since there are no defaults set in https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/blob/master/test/fixtures/shared_vpc/variables.tf, I think kitchen is barfing because these required vars have no values, and I'm still not seeing where they come from.

FWIW, I ran the container and then ran
kitchen converge stub-domains-local --test-base-path=test/integration off of main (without these changes), after cleaning up various lockfiles and kitchen yaml configs from previous failed runs, and still get the same error. So still having trouble understanding how this works / worked before.

@apeabody
Copy link
Collaborator

We strongly encourage that all new tests be written using CFT, rather than Kitchen

Right, understood... was really just trying to fix what seemed to be a very simple deprecation warning, but if it ends up being too involved, probably not worth it. I've worked with test kitchen pretty extensively in the past, but haven't touched it for a couple of years.

That said, might be good to update the help text to make it more clear, as well as to provide links to whatever docs exist about the new framework.

From a quick look, it had seemed like maybe kitchen was still used for provisioning, and that the go tests were just called instead of inspec for verification, but maybe I misunderstood.

Either way, since kitchen-terraform is deprecated, totally understand the move to something else (also see #2108 -- while I'm mostly talking about unit testing with mocked provider or plan-only there, the native tests could be used for provisioning directly as well)

This repo might be the only that has both Kitchen and CFT (go) tests, so it gets a bit muddled. Here is a simple CFT only example: https://github.com/terraform-google-modules/terraform-google-cloud-storage/blob/master/build/int.cloudbuild.yaml

The prepare stage is used by both, but the init-all is CFT specific, while the create-all is for Kitchen. Here is the general documentation for the new style tests: https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/master/infra/blueprint-test

Even with the fairly old (3.5) test kitchen version used by the tests,
there are some parameters which have moved to new locations.

Follow the suggestions of `kitchen doctor`.
@wyardley wyardley force-pushed the wyardley/chore/kitchen_doctor branch from 85b2c14 to 626d129 Compare September 25, 2024 18:55
@apeabody
Copy link
Collaborator

/gcbrun

@apeabody
Copy link
Collaborator

/gcbrun

Copy link
Collaborator

@apeabody apeabody left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @wyardley!

@apeabody apeabody merged commit 6db1e00 into terraform-google-modules:master Sep 25, 2024
4 checks passed
@wyardley wyardley deleted the wyardley/chore/kitchen_doctor branch September 25, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants