Skip to content

Commit

Permalink
Updated test cases and added terraform scripts
Browse files Browse the repository at this point in the history
Signed-off-by: balasubramanian-s <balasubramanian.s@progress.com>
  • Loading branch information
balasubramanian-s committed Oct 10, 2024
1 parent bd195e7 commit bff0054
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ The following resources are available in the InSpec GCP Profile
| [google_resourcemanager_folder](docs/resources/google_resourcemanager_folder.md) | [google_resourcemanager_folders](docs/resources/google_resourcemanager_folders.md) |
| [google_resourcemanager_folder_iam_binding](docs/resources/google_resourcemanager_folder_iam_binding.md) | No Plural Resource |
| [google_resourcemanager_folder_iam_policy](docs/resources/google_resourcemanager_folder_iam_policy.md) | No Plural Resource |
| [google_run_job](docs/resources/google_run_job.md) | [google_run_jobs](docs/resources/google_run_jobs.md) |
| [google_run_service](docs/resources/google_run_service.md) | [google_run_services](docs/resources/google_run_services.md) |
| [google_runtime_config_config](docs/resources/google_runtime_config_config.md) | [google_runtime_config_configs](docs/resources/google_runtime_config_configs.md) |
| [google_runtime_config_config_iam_binding](docs/resources/google_runtime_config_config_iam_binding.md) | No Plural Resource |
Expand Down
15 changes: 7 additions & 8 deletions docs/resources/google_run_job.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A `google_run_job` is used to test a Google Job resource

## Examples
```
describe google_run_job(name: ' value_name') do
describe google_run_job(name: 'projects/{project}/locations/{location}/jobs/{value_name}') do
it { should exist }
its('name') { should cmp 'value_name' }
its('uid') { should cmp 'value_uid' }
Expand All @@ -41,10 +41,9 @@ describe google_run_job(name: ' value_name') do
its('start_execution_token') { should cmp 'value_startexecutiontoken' }
its('run_execution_token') { should cmp 'value_runexecutiontoken' }
its('etag') { should cmp 'value_etag' }
end
describe google_run_job(name: "does_not_exit") do
describe google_run_job(name: "projects/{project}/locations/{location}/jobs/{does_not_exit}") do
it { should_not exist }
end
```
Expand All @@ -64,11 +63,11 @@ Properties that can be accessed from the `google_run_job` resource:

* `labels`: Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component, environment, state, etc. For more information, visit https://cloud.google.com/resource-manager/docs/creating-managing-labels or https://cloud.google.com/run/docs/configuring/labels. Cloud Run API v2 does not support labels with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system labels in v1 now have a corresponding field in v2 Job.

* `additional_properties`:
* `additional_properties`:

* `annotations`: Unstructured key value map that may be set by external tools to store and arbitrary metadata. They are not queryable and should be preserved when modifying objects. Cloud Run API v2 does not support annotations with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected on new resources. All system annotations in v1 now have a corresponding field in v2 Job. This field follows Kubernetes annotations' namespacing, limits, and rules.

* `additional_properties`:
* `additional_properties`:

* `create_time`: Output only. The creation time.

Expand Down Expand Up @@ -109,11 +108,11 @@ Properties that can be accessed from the `google_run_job` resource:

* `labels`: Unstructured key value map that can be used to organize and categorize objects. User-provided labels are shared with Google's billing system, so they can be used to filter, or break down billing charges by team, component, environment, state, etc. For more information, visit https://cloud.google.com/resource-manager/docs/creating-managing-labels or https://cloud.google.com/run/docs/configuring/labels. Cloud Run API v2 does not support labels with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system labels in v1 now have a corresponding field in v2 ExecutionTemplate.

* `additional_properties`:
* `additional_properties`:

* `annotations`: Unstructured key value map that may be set by external tools to store and arbitrary metadata. They are not queryable and should be preserved when modifying objects. Cloud Run API v2 does not support annotations with `run.googleapis.com`, `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev` namespaces, and they will be rejected. All system annotations in v1 now have a corresponding field in v2 ExecutionTemplate. This field follows Kubernetes annotations' namespacing, limits, and rules.

* `additional_properties`:
* `additional_properties`:

* `parallelism`: Specifies the maximum desired number of tasks the execution should run at given time. Must be <= task_count. When the job is run, if this field is 0 or unset, the maximum possible value will be used for that execution. The actual number of tasks running in steady state will be less than this number when there are fewer tasks waiting to be completed remaining, i.e. when the work left to do is less than max parallelism.

Expand Down Expand Up @@ -149,7 +148,7 @@ Properties that can be accessed from the `google_run_job` resource:

* `limits`: Only `memory` and `cpu` keys in the map are supported. Notes: * The only supported values for CPU are '1', '2', '4', and '8'. Setting 4 CPU requires at least 2Gi of memory. For more information, go to https://cloud.google.com/run/docs/configuring/cpu. * For supported 'memory' values and syntax, go to https://cloud.google.com/run/docs/configuring/memory-limits

* `additional_properties`:
* `additional_properties`:

* `cpu_idle`: Determines whether CPU is only allocated during requests (true by default). However, if ResourceRequirements is set, the caller must explicitly set this field to true to preserve the default behavior.

Expand Down
4 changes: 3 additions & 1 deletion docs/resources/google_run_jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ A `google_run_jobs` is used to test a Google Job resource

## Examples
```
describe google_run_jobs(parent: ' value_parent') do
describe google_run_jobs(parent: 'projects/{project}/locations/{location}') do
it { should exist }
its('names') { should include 'value_name' }
its('creators') { should include 'value_creator' }
end
```

Expand Down
4 changes: 2 additions & 2 deletions libraries/google_run_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def exists?
end

def to_s
"Job #{@params[:]}"
"Job #{@params[:name]}"
end

private
Expand All @@ -114,6 +114,6 @@ def product_url(_ = nil)
end

def resource_base_url
'{{+name}}'
'{{name}}'
end
end
2 changes: 1 addition & 1 deletion libraries/google_run_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ def product_url(_ = nil)
end

def resource_base_url
'{{+parent}}/jobs'
'{{parent}}/jobs'
end
end
19 changes: 18 additions & 1 deletion test/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ variable "dataproc_metastore_federation" {
variable "data_fusion_instance" {
type = any
}

variable "cloud_run_jobs" {
type = any
}
resource "google_compute_ssl_policy" "custom-ssl-policy" {
name = var.ssl_policy["name"]
min_tls_version = var.ssl_policy["min_tls_version"]
Expand Down Expand Up @@ -2228,3 +2230,18 @@ resource "google_data_fusion_instance" "data_fusion_instance" {
region = var.data_fusion_instance.location
type = var.data_fusion_instance.type
}

resource "google_cloud_run_v2_job" "default" {
name = var.cloud_run_jobs.name
location = var.cloud_run_jobs.location
deletion_protection = var.cloud_run_jobs.deletion_protection
project = var.gcp_project_id

template {
template {
containers {
image = var.cloud_run_jobs.image
}
}
}
}
6 changes: 6 additions & 0 deletions test/integration/configuration/mm-attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -745,3 +745,9 @@ data_fusion_instance:
name: "inspec-instance"
location: "us-central1"
type: "DEVELOPER"

cloud_run_jobs:
name: "inspec-tutorial1-20230915-182543"
location: "us-central1"
deletion_protection: "false"
image: "us-central1-docker.pkg.dev/ppradhan/nas/balasubs_tutorial1_20230915_182543:latest"
16 changes: 8 additions & 8 deletions test/integration/verify/controls/google_run_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

job = input('job', value: {
"name": "value_name",
"parent": "value_parent",
"uid": "value_uid",
"generation": "value_generation",
"create_time": "value_createtime",
"name": "projects/ppradhan/locations/us-central1/jobs/inspec-tutorial1-20230915-182543",
"parent": "projects/ppradhan/locations/us-central1",
"uid": "605bd3e1-4bf0-4a9d-85ea-23eae08f51dc",
"generation": "1",
"create_time": "2024-10-10T13:34:58.675033Z",
"client": "cloud-console",
"update_time": "value_updatetime",
"delete_time": "value_deletetime",
"expire_time": "value_expiretime",
"creator": "value_creator",
"last_modifier": "value_lastmodifier",
"client": "value_client",
"client_version": "value_clientversion",
"launch_stage": "value_launchstage",
"observed_generation": "value_observedgeneration",
"launch_stage": "GA",
"observed_generation": "1",
"start_execution_token": "value_startexecutiontoken",
"run_execution_token": "value_runexecutiontoken",
"etag": "value_etag"
Expand Down
20 changes: 10 additions & 10 deletions test/integration/verify/controls/google_run_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

job = input('job', value: {
"name": "value_name",
"parent": "value_parent",
"uid": "value_uid",
"generation": "value_generation",
"create_time": "value_createtime",
job = input('job', value: {
"name": "projects/ppradhan/locations/us-central1/jobs/inspec-tutorial1-20230915-182543",
"parent": "projects/ppradhan/locations/us-central1",
"uid": "605bd3e1-4bf0-4a9d-85ea-23eae08f51dc",
"generation": "1",
"create_time": "2024-10-10T13:34:58.675033Z",
"client": "cloud-console",
"update_time": "value_updatetime",
"delete_time": "value_deletetime",
"expire_time": "value_expiretime",
"creator": "value_creator",
"last_modifier": "value_lastmodifier",
"client": "value_client",
"client_version": "value_clientversion",
"launch_stage": "value_launchstage",
"observed_generation": "value_observedgeneration",
"launch_stage": "GA",
"observed_generation": "1",
"start_execution_token": "value_startexecutiontoken",
"run_execution_token": "value_runexecutiontoken",
"etag": "value_etag"
Expand All @@ -39,7 +39,7 @@
impact 1.0
title 'google_run_jobs resource test'

describe google_run_jobs(parent: job['parent']) do
describe google_run_jobs(parent: job['parent']) do
it { should exist }
end
end

0 comments on commit bff0054

Please sign in to comment.