Skip to content

Commit 5ba9b71

Browse files
t-karasovagcf-owl-bot[bot]partheatkarasyova
authored
docs(samples): add resources for interactive tutorials (#145)
* feat: Retail Interactive Tutorials. Product service code samples * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fail if GOOGLE_CLOUD_PROJECT_NUMBER is not set * remove endpoint * require GOOGLE_CLOUD_PROJECT environment variable * adjust filepaths samples testing * lint * update and move the tests resources setup files * Update create_test_resources.py * Update create_test_resources.py * fix typo * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]> Co-authored-by: t-karasova <[email protected]>
1 parent bbdcb0c commit 5ba9b71

13 files changed

+539
-31
lines changed

generated_samples/snippets/TEST_RESOURCES_SETUP_CLEANUP.md renamed to generated_samples/interactive-tutorials/TEST_RESOURCES_SETUP_CLEANUP.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@
33
## Required environment variables
44

55
To successfully import the catalog data for tests, the following environment variables should be set:
6-
- PROJECT_NUMBER
6+
- GOOGLE_CLOUD_PROJECT_NUMBER
7+
- GOOGLE_CLOUD_PROJECT_ID
78
- BUCKET_NAME
9+
- EVENTS_BUCKET_NAME
810
These values are stored in the Secret Manager and will be submitted as
911
docker environment variables before the test run.
1012

1113
The Secret Manager name is set in .kokoro/presubmit/common.cfg file, SECRET_MANAGER_KEYS variable.
1214

1315
## Import catalog data
1416

15-
There is a JSON file with valid products prepared in the `product` directory:
16-
`resources/products.json`.
17+
There are JSON files with valid products and user events prepared in `resources` directory:
18+
`samples/resources/products.json` and `samples/resources/user_events.json` respectively.
1719

1820
Run the `create_test_resources.py` to perform the following actions:
1921
- create the GCS bucket <BUCKET_NAME>,
20-
- upload the product data from `resources/products.json` file,
21-
- import products to the default branch of the Retail catalog.
22+
- upload the product data from `resources/products.json` file to products bucket,
23+
- import products to the default branch of the Retail catalog,
24+
- create the GCS bucket <EVENTS_BUCKET_NAME>,
25+
- upload the product data from `resources/user_events.json` file to events bucket,
26+
- create a BigQuery dataset and table `products`,
27+
- insert products from resources/products.json to the created products table,
28+
- create a BigQuery dataset and table `events`,
29+
- insert user events from resources/user_events.json to the created events table
30+
2231

2332
```
2433
$ python create_test_resources.py
@@ -33,6 +42,10 @@ Run the `remove_test_resources.py` to perform the following actions:
3342
- remove all objects from the GCS bucket <BUCKET_NAME>,
3443
- remove the <BUCKET_NAME> bucket,
3544
- delete all products from the Retail catalog.
45+
- remove all objects from the GCS bucket <EVENTS_BUCKET_NAME>,
46+
- remove the <EVENTS_BUCKET_NAME> bucket,
47+
- remove dataset `products` along with tables
48+
- remove dataset `user_events` along with tables
3649

3750
```
3851
$ python remove_test_resources.py
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[
2+
{
3+
"fields":[
4+
{
5+
"mode": "NULLABLE",
6+
"name": "currencyCode",
7+
"type": "STRING"
8+
},
9+
{
10+
"mode": "NULLABLE",
11+
"name": "revenue",
12+
"type": "FLOAT"
13+
}
14+
],
15+
"mode": "NULLABLE",
16+
"name": "purchaseTransaction",
17+
"type": "RECORD"
18+
},
19+
{
20+
"fields":[
21+
{
22+
"mode": "NULLABLE",
23+
"name": "quantity",
24+
"type": "INTEGER"
25+
},
26+
{
27+
"fields":[
28+
{
29+
"mode": "NULLABLE",
30+
"name": "id",
31+
"type": "STRING"
32+
}
33+
],
34+
"mode": "NULLABLE",
35+
"name": "product",
36+
"type": "RECORD"
37+
}
38+
],
39+
"mode": "REPEATED",
40+
"name": "productDetails",
41+
"type": "RECORD"
42+
},
43+
{
44+
"mode": "REQUIRED",
45+
"name": "eventTime",
46+
"type": "STRING"
47+
},
48+
{
49+
"mode": "REQUIRED",
50+
"name": "visitorId",
51+
"type": "STRING"
52+
},
53+
{
54+
"mode": "REQUIRED",
55+
"name": "eventType",
56+
"type": "STRING"
57+
},
58+
{
59+
"mode": "NULLABLE",
60+
"name": "searchQuery",
61+
"type": "STRING"
62+
},
63+
{
64+
"mode": "NULLABLE",
65+
"name": "cartId",
66+
"type": "STRING"
67+
},
68+
{
69+
"mode": "REPEATED",
70+
"name": "pageCategories",
71+
"type": "STRING"
72+
}
73+
]

0 commit comments

Comments
 (0)