From 3568e6f7a9bbfbcdee957d5690fbd448a1aa8024 Mon Sep 17 00:00:00 2001 From: nigeljamesstevenson <105309450+nigeljamesstevenson@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:29:35 +0000 Subject: [PATCH] Revert "k6 perf tests: Fix parsing of COT/HPOS environment variable" --- .github/workflows/pr-build-and-e2e-tests.yml | 4 +- .../dev-fix-k6-perf-tests-hpos-env-var | 4 -- .../woocommerce/tests/performance/README.md | 4 +- .../performance/bin/init-sample-products.sh | 16 ++------ .../woocommerce/tests/performance/config.js | 6 +-- .../requests/merchant/add-order.js | 39 ++++++++++--------- .../requests/merchant/orders-filter.js | 10 ++--- .../requests/merchant/orders-heartbeat.js | 10 ++--- .../requests/merchant/orders-search.js | 10 ++--- .../performance/requests/merchant/orders.js | 10 ++--- 10 files changed, 53 insertions(+), 60 deletions(-) delete mode 100644 plugins/woocommerce/changelog/dev-fix-k6-perf-tests-hpos-env-var diff --git a/.github/workflows/pr-build-and-e2e-tests.yml b/.github/workflows/pr-build-and-e2e-tests.yml index e1e469cf630..0a2b8d2ae60 100644 --- a/.github/workflows/pr-build-and-e2e-tests.yml +++ b/.github/workflows/pr-build-and-e2e-tests.yml @@ -147,6 +147,8 @@ jobs: - name: Load docker images and start containers. working-directory: plugins/woocommerce + env: + ENABLE_HPOS: 0 run: | pnpm env:dev --filter=woocommerce pnpm env:performance-init --filter=woocommerce @@ -262,4 +264,4 @@ jobs: -f pr_number=$PR_NUMBER \ -f commit_sha=$COMMIT_SHA \ -f s3_root=public \ - --repo woocommerce/woocommerce-test-reports + --repo woocommerce/woocommerce-test-reports \ No newline at end of file diff --git a/plugins/woocommerce/changelog/dev-fix-k6-perf-tests-hpos-env-var b/plugins/woocommerce/changelog/dev-fix-k6-perf-tests-hpos-env-var deleted file mode 100644 index d001ef87157..00000000000 --- a/plugins/woocommerce/changelog/dev-fix-k6-perf-tests-hpos-env-var +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: dev - -Set default HPOS setting in k6 perf tests to enabled. diff --git a/plugins/woocommerce/tests/performance/README.md b/plugins/woocommerce/tests/performance/README.md index e12f10b04b4..2364ed7df08 100644 --- a/plugins/woocommerce/tests/performance/README.md +++ b/plugins/woocommerce/tests/performance/README.md @@ -80,9 +80,9 @@ admin_acc_login | set to true if site needs to use my account for admin login | customer_username | username for customer user | yes `__ENV.C_USER` customer_password | password for customer user | yes `__ENV.C_PW` customer_user_id | user id for customer user | yes `__ENV.C_UID` -hpos_enabled | Default is `true`. Set to false if HPOS is disabled in the test site. | yes `__ENV.HPOS` +cot_status | set to true if site is using order tables | yes `__ENV.COT` admin_orders_base_url | url part for order urls when posts table is used | no -hpos_admin_orders_base_url | url part for order urls when orders table is used | no +cot_admin_orders_base_url | url part for order urls when orders table is used | no addresses_customer_billing_* | billing address details for existing customer user | no addresses_guest_billing_* | billing address details for guest customer user | no payment_method | payment method (currently only `cod` supported) | no diff --git a/plugins/woocommerce/tests/performance/bin/init-sample-products.sh b/plugins/woocommerce/tests/performance/bin/init-sample-products.sh index 9e9f626658b..43642604361 100755 --- a/plugins/woocommerce/tests/performance/bin/init-sample-products.sh +++ b/plugins/woocommerce/tests/performance/bin/init-sample-products.sh @@ -1,6 +1,6 @@ #!/bin/bash -HPOS="${HPOS:-true}" +ENABLE_HPOS="${ENABLE_HPOS:-0}" echo "Initializing WooCommerce E2E" @@ -32,17 +32,9 @@ wp-env run tests-cli wp import wp-content/plugins/woocommerce/sample-data/sample # install Storefront wp-env run tests-cli wp theme install storefront --activate -if [ $HPOS = true ]; then - echo "Enabling HPOS..." - wp-env run tests-cli wp option set woocommerce_custom_orders_table_enabled 'yes' +if [ $ENABLE_HPOS == 1 ]; then + echo -e 'Enable High-Performance Order Tables\n' + wp-env run tests-cli wp plugin install https://gist.github.com/vedanshujain/564afec8f5e9235a1257994ed39b1449/archive/b031465052fc3e04b17624acbeeb2569ef4d5301.zip --activate fi -if [ $HPOS = false ]; then - echo "Disabling HPOS..." - wp-env run tests-cli wp option set woocommerce_custom_orders_table_enabled 'no' -fi - -# Print HPOS state -wp-env run tests-cli wp option get woocommerce_custom_orders_table_enabled - echo "Success! Your E2E Test Environment is now ready." diff --git a/plugins/woocommerce/tests/performance/config.js b/plugins/woocommerce/tests/performance/config.js index 0aa5bbb4d36..76abf6e546b 100644 --- a/plugins/woocommerce/tests/performance/config.js +++ b/plugins/woocommerce/tests/performance/config.js @@ -4,17 +4,17 @@ export const base_host = __ENV.HOST || 'localhost:8086'; export const admin_username = __ENV.A_USER || 'admin'; export const admin_password = __ENV.A_PW || 'password'; -export const admin_acc_login = __ENV.A_ACC_LOGIN === 'true'; +export const admin_acc_login = __ENV.A_ACC_LOGIN || false; export const customer_username = __ENV.C_USER || 'customer@woocommercecoree2etestsuite.com'; export const customer_password = __ENV.C_PW || 'password'; export const customer_user_id = __ENV.C_UID || '2'; -export const hpos_enabled = __ENV.HPOS !== 'false'; +export const cot_status = __ENV.COT || false; export const admin_orders_base_url = 'edit.php?post_type=shop_order'; -export const hpos_admin_orders_base_url = 'admin.php?page=wc-orders'; +export const cot_admin_orders_base_url = 'admin.php?page=wc-orders'; export const addresses_customer_billing_first_name = 'John'; export const addresses_customer_billing_last_name = 'Doe'; diff --git a/plugins/woocommerce/tests/performance/requests/merchant/add-order.js b/plugins/woocommerce/tests/performance/requests/merchant/add-order.js index 60d2a03930d..a7c303e4228 100644 --- a/plugins/woocommerce/tests/performance/requests/merchant/add-order.js +++ b/plugins/woocommerce/tests/performance/requests/merchant/add-order.js @@ -15,7 +15,7 @@ import { */ import { base_url, - hpos_enabled, + cot_status, addresses_guest_billing_first_name, addresses_guest_billing_last_name, addresses_guest_billing_company, @@ -43,8 +43,9 @@ import { commonNonStandardHeaders, } from '../../headers.js'; -// Change URL if HPOS is enabled and being used +// Change URL if COT is enabled and being used let admin_new_order_base; +let admin_new_order_assert; let admin_created_order_assert; let admin_open_order_base; let admin_open_order_assert; @@ -54,15 +55,17 @@ let admin_update_order_id; let admin_update_order_params; let admin_update_order_assert; -if ( hpos_enabled ) { +if ( cot_status === true ) { admin_new_order_base = 'admin.php?page=wc-orders&action=new'; admin_update_order_base = 'admin.php?page=wc-orders&action=edit'; + admin_new_order_assert = 'post_status" type="hidden" value="pending'; admin_open_order_assert = 'post_status" type="hidden" value="pending'; admin_created_order_assert = 'Order updated.'; admin_update_order_assert = 'changed from Pending payment to Completed'; } else { admin_new_order_base = 'post-new.php?post_type=shop_order'; admin_update_order_base = 'post.php'; + admin_new_order_assert = 'Add new order'; admin_open_order_assert = 'Edit order'; admin_created_order_assert = 'Order updated.'; admin_update_order_assert = 'Order updated.'; @@ -113,7 +116,7 @@ export function addOrder( includeTests = {} ) { check( response, { 'is status 200': ( r ) => r.status === 200, "body contains: 'Add new order' header": ( response ) => - response.body.includes( 'Add new order' ), + response.body.includes( `${ admin_new_order_assert }` ), } ); // Correlate nonce values for use in subsequent requests. @@ -332,7 +335,7 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - const hposOrderParams = new URLSearchParams( [ + const cotOrderParams = new URLSearchParams( [ [ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ], [ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ], [ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ], @@ -386,9 +389,9 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_update_order = `${ admin_update_order_base }&id=${ hpos_post_id }`; - admin_update_order_params = hposOrderParams.toString(); + admin_update_order_params = cotOrderParams.toString(); } else { admin_update_order = admin_update_order_base; admin_update_order_params = orderParams.toString(); @@ -424,7 +427,7 @@ export function addOrder( includeTests = {} ) { commonNonStandardHeaders ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_open_order_base = `${ admin_update_order_base }&id=${ hpos_post_id }`; } else { admin_open_order_base = `${ admin_update_order_base }?post=${ post_id }`; @@ -523,7 +526,7 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - const hposOrderParams = new URLSearchParams( [ + const cotOrderParams = new URLSearchParams( [ [ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ], [ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ], [ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ], @@ -577,9 +580,9 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_update_order_id = `${ admin_update_order_base }&id=${ hpos_post_id }`; - admin_update_order_params = hposOrderParams.toString(); + admin_update_order_params = cotOrderParams.toString(); } else { admin_update_order_params = orderParams.toString(); admin_update_order_id = `${ admin_open_order_base }`; @@ -682,7 +685,7 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - const hposOrderParams = new URLSearchParams( [ + const cotOrderParams = new URLSearchParams( [ [ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ], [ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ], [ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ], @@ -736,9 +739,9 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_update_order = `${ admin_update_order_base }&id=${ hpos_post_id }`; - admin_update_order_params = hposOrderParams.toString(); + admin_update_order_params = cotOrderParams.toString(); } else { admin_update_order = admin_update_order_base; admin_update_order_params = orderParams.toString(); @@ -772,7 +775,7 @@ export function addOrder( includeTests = {} ) { commonNonStandardHeaders ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_open_order_base = `${ admin_update_order_base }&id=${ hpos_post_id }`; } else { admin_open_order_base = `${ admin_update_order_base }?post=${ post_id }`; @@ -869,7 +872,7 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - const hposOrderParams = new URLSearchParams( [ + const cotOrderParams = new URLSearchParams( [ [ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ], [ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ], [ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ], @@ -923,9 +926,9 @@ export function addOrder( includeTests = {} ) { [ 'woocommerce_meta_nonce', `${ woocommerce_meta_nonce }` ], ] ); - if ( hpos_enabled ) { + if ( cot_status === true ) { admin_update_order_id = `${ admin_update_order_base }&id=${ hpos_post_id }`; - admin_update_order_params = hposOrderParams.toString(); + admin_update_order_params = cotOrderParams.toString(); } else { admin_update_order_params = orderParams.toString(); admin_update_order_id = `${ admin_open_order_base }`; diff --git a/plugins/woocommerce/tests/performance/requests/merchant/orders-filter.js b/plugins/woocommerce/tests/performance/requests/merchant/orders-filter.js index 2ee29082174..c381e906c99 100644 --- a/plugins/woocommerce/tests/performance/requests/merchant/orders-filter.js +++ b/plugins/woocommerce/tests/performance/requests/merchant/orders-filter.js @@ -12,9 +12,9 @@ import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js'; */ import { base_url, - hpos_enabled, + cot_status, admin_orders_base_url, - hpos_admin_orders_base_url, + cot_admin_orders_base_url, think_time_min, think_time_max, customer_user_id, @@ -31,11 +31,11 @@ const month = date.toJSON().slice( 5, 7 ); const year = date.toJSON().slice( 0, 4 ); const currentDate = `${ year }${ month }`; -// Change URL if HPOS is enabled and being used +// Change URL if COT is enabled and being used let admin_orders_base; let admin_filter_month_assert; -if ( hpos_enabled ) { - admin_orders_base = hpos_admin_orders_base_url; +if ( cot_status === true ) { + admin_orders_base = cot_admin_orders_base_url; admin_filter_month_assert = `selected='selected' value="${ currentDate }">`; } else { admin_orders_base = `${ admin_orders_base_url }&post_status=all`; diff --git a/plugins/woocommerce/tests/performance/requests/merchant/orders-heartbeat.js b/plugins/woocommerce/tests/performance/requests/merchant/orders-heartbeat.js index 8526c8f7c47..a2bc8339c29 100644 --- a/plugins/woocommerce/tests/performance/requests/merchant/orders-heartbeat.js +++ b/plugins/woocommerce/tests/performance/requests/merchant/orders-heartbeat.js @@ -14,9 +14,9 @@ import { */ import { base_url, - hpos_enabled, + cot_status, admin_orders_base_url, - hpos_admin_orders_base_url, + cot_admin_orders_base_url, think_time_min, think_time_max, } from '../../config.js'; @@ -34,10 +34,10 @@ import { let heartbeat_nonce; let jar; -// Change URL if HPOS is enabled and being used +// Change URL if COT is enabled and being used let admin_orders_base; -if ( hpos_enabled ) { - admin_orders_base = hpos_admin_orders_base_url; +if ( cot_status === true ) { + admin_orders_base = cot_admin_orders_base_url; } else { admin_orders_base = admin_orders_base_url; } diff --git a/plugins/woocommerce/tests/performance/requests/merchant/orders-search.js b/plugins/woocommerce/tests/performance/requests/merchant/orders-search.js index a2d4c09db8a..2e284a6e031 100644 --- a/plugins/woocommerce/tests/performance/requests/merchant/orders-search.js +++ b/plugins/woocommerce/tests/performance/requests/merchant/orders-search.js @@ -12,9 +12,9 @@ import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js'; */ import { base_url, - hpos_enabled, + cot_status, admin_orders_base_url, - hpos_admin_orders_base_url, + cot_admin_orders_base_url, think_time_min, think_time_max, product_search_term, @@ -28,11 +28,11 @@ import { commonNonStandardHeaders, } from '../../headers.js'; -// Change URL if HPOS is enabled and being used +// Change URL if COT is enabled and being used let admin_orders_base; let admin_search_assert; -if ( hpos_enabled ) { - admin_orders_base = hpos_admin_orders_base_url; +if ( cot_status === true ) { + admin_orders_base = cot_admin_orders_base_url; admin_search_assert = 'tbody id="the-list"'; } else { admin_orders_base = `${ admin_orders_base_url }&post_status=all`; diff --git a/plugins/woocommerce/tests/performance/requests/merchant/orders.js b/plugins/woocommerce/tests/performance/requests/merchant/orders.js index b6cedf8a65f..bf763ce9c6c 100644 --- a/plugins/woocommerce/tests/performance/requests/merchant/orders.js +++ b/plugins/woocommerce/tests/performance/requests/merchant/orders.js @@ -15,9 +15,9 @@ import { */ import { base_url, - hpos_enabled, + cot_status, admin_orders_base_url, - hpos_admin_orders_base_url, + cot_admin_orders_base_url, think_time_min, think_time_max, } from '../../config.js'; @@ -33,11 +33,11 @@ import { commonNonStandardHeaders, } from '../../headers.js'; -// Change URL if HPOS is enabled and being used +// Change URL if COT is enabled and being used let admin_orders_base; let admin_orders_completed; -if ( hpos_enabled ) { - admin_orders_base = hpos_admin_orders_base_url; +if ( cot_status === true ) { + admin_orders_base = cot_admin_orders_base_url; admin_orders_completed = 'status=wc-completed'; } else { admin_orders_base = admin_orders_base_url;