Skip to content

Commit

Permalink
Update tests that failed due to the #1739 fix
Browse files Browse the repository at this point in the history
* fix for 1739

* fixed failing tests

* update failing test

* update failing test

* update failing test

* Update failing test

* Fix rubocop issue

* Fix rubocop issues

* update failing tests

* update failing test

* Update failing tests

* Fix rubocop issues

* Fix rubocop issues

* Fix create alignment test

* Fix change alignment tests

* Fix ci failure

* Fix rubocop failures

* Fix rubocop errors

* Fix rubocop errors

* Update to KB 0.24.11

* Fix for ci failures
  • Loading branch information
reshmabidikar authored Sep 9, 2024
1 parent bb75f21 commit 2c194a6
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 84 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
- name: Start stack
run: |
cd docker
docker-compose -p it -f ${{ matrix.docker-compose-file }} up --no-start
docker start it_db_1
docker compose -p it -f ${{ matrix.docker-compose-file }} up --no-start
docker start it-db-1
- name: Wait for MySQL
if: ${{ matrix.docker-compose-file == 'docker-compose.ci.mysql.yml' }}
run: |
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
run: |
# Start all remaining containers
cd docker
docker-compose -p it -f ${{ matrix.docker-compose-file }} up -d
docker compose -p it -f ${{ matrix.docker-compose-file }} up -d
count=0
until $(curl --connect-timeout 10 --max-time 30 --output /dev/null --silent --fail http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck); do
if [[ "$count" == "180" ]]; then
Expand Down Expand Up @@ -193,10 +193,14 @@ jobs:
./bin/retry bundle exec rake test:plugins:catalog-test TESTOPTS="--stop-on-failure"
echo "::endgroup::"
- name: Debugging after failure
if: failure()
run: |
echo "::group::killbill healthcheck"
curl --connect-timeout 10 --max-time 30 -v http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck || true
echo "::endgroup::"
echo "::group::killbill nodesinfo"
curl --connect-timeout 10 --max-time 30 -u admin:password -v http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo || true
echo "::endgroup::"
echo "::group::hostname"
hostname
echo "::endgroup::"
Expand All @@ -210,19 +214,20 @@ jobs:
docker ps -a
echo "::endgroup::"
echo "::group::killbill env"
docker exec it_killbill_1 env || true
docker exec it-killbill-1 env || true
echo "::endgroup::"
echo "::group::db env"
docker exec it_db_1 env || true
docker exec it-db-1 env || true
echo "::endgroup::"
echo "::group::killbill logs"
(docker logs -t --details it_killbill_1 || true) | tee /var/tmp/killbill.txt
(docker logs -t --details it-killbill-1 || true) | tee /var/tmp/killbill.txt
echo "::endgroup::"
echo "::group::db logs"
docker logs -t --details it_db_1 || true
docker logs -t --details it-db-1 || true
echo "::endgroup::"
- name: Upload logs
uses: actions/[email protected]
if: failure()
with:
name: killbill-${{ matrix.docker-compose-file }}.txt
path: /var/tmp/killbill.txt
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.ci.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.8'
services:
killbill:
network_mode: host
image: killbill/killbill:0.24.9
image: killbill/killbill:0.24.11
environment:
- KILLBILL_CATALOG_URI=SpyCarAdvanced.xml
- KILLBILL_DAO_URL=jdbc:mysql://127.0.0.1:3306/killbill
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.ci.postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.8'
services:
killbill:
network_mode: host
image: killbill/killbill:0.24.9
image: killbill/killbill:0.24.11
environment:
- KILLBILL_CATALOG_URI=SpyCarAdvanced.xml
- KILLBILL_DAO_URL=jdbc:postgresql://127.0.0.1:5432/killbill
Expand Down
61 changes: 31 additions & 30 deletions killbill-integration-tests/core/test_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'test_base'
require 'date'

# TODO_1739 - This test has major changes and needs to be reviewed carefully
module KillBillIntegrationTests
class TestCatalog < Base
def setup
Expand All @@ -21,7 +22,7 @@ def teardown
def test_price_increase
upload_catalog('Catalog-v1.xml', false, @user, @options)

create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0)
create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0, 'RECURRING')

# Effective date of the second catalog is 2013-09-01
upload_catalog('Catalog-v2.xml', false, @user, @options)
Expand All @@ -30,7 +31,7 @@ def test_price_increase
add_days_and_check_invoice_item(31, 2, 'basic-monthly', '2013-09-01', '2013-10-01', 1000.0)

# Create a new subscription and check the new price is effective
create_basic_entitlement(3, 'MONTHLY', '2013-09-01', '2013-10-01', 1200.0)
create_basic_entitlement(3, 'MONTHLY', '2013-09-01', '2013-10-01', 1200.0, 'RECURRING')

add_days_and_check_invoice_balance(30, 4, '2013-10-01', 2200.0)
end
Expand All @@ -40,7 +41,7 @@ def test_add_plan
upload_catalog('Catalog-v1.xml', false, @user, @options)

# basic-monthly has no trial period
bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0)
bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0, 'RECURRING')

# Move clock to 2013-09-01
add_days_and_check_invoice_item(31, 2, 'basic-monthly', '2013-09-01', '2013-10-01', 1000.0)
Expand All @@ -53,7 +54,7 @@ def test_add_plan
add_days_and_check_invoice_item(30, 3, 'basic-monthly', '2013-10-01', '2013-11-01', 1000.0)

# The annual plan is only present in the v3 catalog
create_basic_entitlement(4, 'ANNUAL', '2013-10-01', nil, 0)
create_basic_entitlement(4, 'ANNUAL', '2013-10-01', '2013-10-31', 0)

# Move clock to 2013-10-31 (BCD = 1)
add_days_and_check_invoice_item(30, 5, 'basic-annual', '2013-10-31', '2014-10-01', 12_849.32)
Expand All @@ -63,15 +64,15 @@ def test_add_plan
add_days_and_check_invoice_item(1, 6, 'basic-monthly', '2013-11-01', '2013-12-01', 1000.0)

# Verify we can change to the new plan
change_base_entitlement(bp, 7, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-01', '2014-11-01', 14_000, 13_000)
change_base_entitlement(bp, 7, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-01', '2014-11-01', 14_000, 13_000, 'RECURRING')
end

# Change alignment in a subsequent catalog
def test_change_plan_with_latest_policy
upload_catalog('Catalog-v1.xml', false, @user, @options)

# basic-bimestrial has a trial period
bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', nil, 0)
bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', '2013-08-31', 0)

# Move clock to 2013-08-31
add_days_and_check_invoice_item(30, 2, 'basic-bimestrial', '2013-08-31', '2013-10-31', 1000.0)
Expand All @@ -98,14 +99,14 @@ def test_change_plan_with_latest_policy
# Verify new CHANGE_OF_PLAN change alignment
# Because the basic-annual has a 30 days trial, and because of the policy (CHANGE_PLAN) we invoice for a $0 trial
# and therefore create a pro-ration credit for the part 2013-11-02 -> 2013-12-31
change_base_entitlement(bp, 4, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-02', nil, 0, -967.21)
change_base_entitlement(bp, 4, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-02', '2013-12-02', 0, -967.21)
end

def test_change_alignment_no_grandfathering
upload_catalog('Catalog-v1.xml', false, @user, @options)

# basic-bimestrial has a trial period
bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', nil, 0)
bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', '2013-08-31', 0)

# Move clock to 2013-08-31
add_days_and_check_invoice_item(30, 2, 'basic-bimestrial', '2013-08-31', '2013-10-31', 1000.0)
Expand Down Expand Up @@ -134,24 +135,24 @@ def test_change_alignment_no_grandfathering
add_days(1)

# Verify START_OF_BUNDLE change alignment is NOT grandfathered: we are back in trial
change_base_entitlement(bp, 5, 'Basic', 'ANNUAL', '2013-08-01', '2014-01-01', nil, 0, -983.05)
change_base_entitlement(bp, 5, 'Basic', 'ANNUAL', '2013-08-01', '2014-01-01', '2014-01-31', 0, -983.05)
end

def test_create_alignment
upload_catalog('Catalog-CreateAlignment.xml', false, @user, @options)

bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', nil, 0.0)
bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-08-31', 0.0)

# Move the clock to 2013-08-15
add_days(14)

# Add a first add-on with a START_OF_BUNDLE creation alignment. The subscription is aligned
# with the bundle creation date (2013-08-01) meaning the trial will be from 2013-08-15 to 2013-08-31
create_ao_entitlement(bp, 2, 'BasicAOStartOfBundle', 'MONTHLY', '2013-08-15', 0)
create_ao_entitlement(bp, 2, 'BasicAOStartOfBundle', 'MONTHLY', '2013-08-15', '2013-08-31', 0)

# Add a second add-on with a START_OF_SUBSCRIPTION creation alignment. The subscription is aligned
# with the add-on subscription creation date (2013-08-15) meaning the trial will be from 2013-08-15 to 2013-09-14
create_ao_entitlement(bp, 3, 'BasicAOStartOfSubscription', 'MONTHLY', '2013-08-15', 0)
create_ao_entitlement(bp, 3, 'BasicAOStartOfSubscription', 'MONTHLY', '2013-08-15', '2013-09-14', 0)

# Move the clock to 2013-08-31 (30 days trial)
add_days(16)
Expand Down Expand Up @@ -181,7 +182,7 @@ def test_change_alignment_start_of_bundle
bp, ao = setup_change_alignment_test

# Change plan with a start of bundle change alignment: the trial will still end on 2013-08-31
change_ao_entitlement(ao, 3, 'BasicAOStartOfBundle', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
change_ao_entitlement(ao, 3, 'BasicAOStartOfBundle', 'MONTHLY', '2013-08-05', '2013-08-31', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
Expand All @@ -205,7 +206,7 @@ def test_change_alignment_start_of_subscription
bp, ao = setup_change_alignment_test

# Change plan with a start of subscription change alignment: the trial will now end on 2013-09-04
change_ao_entitlement(ao, 3, 'BasicAOStartOfSubscription', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
change_ao_entitlement(ao, 3, 'BasicAOStartOfSubscription', 'MONTHLY', '2013-08-05', '2013-09-04', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
Expand Down Expand Up @@ -241,7 +242,7 @@ def test_change_alignment_change_of_plan
bp, ao = setup_change_alignment_test

# Change plan with a start of change of plan change alignment: the trial will now end on 2013-09-14
change_ao_entitlement(ao, 3, 'BasicAOChangeOfPlan', 'MONTHLY', '2013-08-05', 0.0, '2013-08-15')
change_ao_entitlement(ao, 3, 'BasicAOChangeOfPlan', 'MONTHLY', '2013-08-05', '2013-09-14', 0.0, '2013-08-15')
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
Expand Down Expand Up @@ -317,12 +318,12 @@ def test_get_list_of_catalog_versions
def setup_change_alignment_test
upload_catalog('Catalog-ChangeAlignment.xml', false, @user, @options)

bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', nil, 0.0)
bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-08-31', 0.0)

# Move the clock to 2013-08-05
add_days(4)

ao = create_ao_entitlement(bp, 2, 'BasicAO', 'MONTHLY', '2013-08-05', 0.0)
ao = create_ao_entitlement(bp, 2, 'BasicAO', 'MONTHLY', '2013-08-05', '2013-08-31', 0.0)
check_subscription_events(bp,
ao,
[{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
Expand All @@ -338,39 +339,39 @@ def setup_change_alignment_test
[bp, ao]
end

def create_basic_entitlement(invoice_nb = 1, billing_period = 'MONTHLY', start_date = '2013-08-01', end_date = '2013-09-01', amount = 1000.0)
def create_basic_entitlement(invoice_nb = 1, billing_period = 'MONTHLY', start_date = '2013-08-01', end_date = '2013-08-31', amount = 1000.0, type = 'FIXED')
bp = create_entitlement_base(@account.account_id, 'Basic', billing_period, 'DEFAULT', @user, @options)
check_entitlement(bp, 'Basic', 'BASE', billing_period, 'DEFAULT', start_date, nil)
if end_date.nil?
check_fixed_item(invoice_nb, 'basic-' + billing_period.downcase, start_date, amount, amount)
if type == 'FIXED'
check_fixed_item(invoice_nb, 'basic-' + billing_period.downcase, start_date, amount, amount, start_date, end_date)
else
check_evergreen_item(invoice_nb, 'basic-' + billing_period.downcase, start_date, end_date, amount, amount)
end
bp
end

def change_base_entitlement(bp, invoice_nb = 1, product = 'Basic', billing_period = 'MONTHLY', start_date = '2013-08-01', inv_start_date = '2013-08-01', inv_end_date = '2013-09-01', amount = 1000.0, balance = 1000.0)
def change_base_entitlement(bp, invoice_nb = 1, product = 'Basic', billing_period = 'MONTHLY', start_date = '2013-08-01', inv_start_date = '2013-08-01', inv_end_date = '2013-09-01', amount = 1000.0, balance = 1000.0, type = 'FIXED')
bp = bp.change_plan({ productName: product, billingPeriod: billing_period, priceList: 'DEFAULT' }, @user, nil, nil, nil, 'IMMEDIATE', nil, false, @options)
check_entitlement(bp, 'Basic', 'BASE', billing_period, 'DEFAULT', start_date, nil)
if inv_end_date.nil?
check_fixed_item(invoice_nb, 'basic-' + billing_period.downcase, inv_start_date, amount, balance)
if type == 'FIXED'
check_fixed_item(invoice_nb, 'basic-' + billing_period.downcase, inv_start_date, amount, balance, inv_start_date, inv_end_date)
else
check_evergreen_item(invoice_nb, 'basic-' + billing_period.downcase, inv_start_date, inv_end_date, amount, balance)
end
bp
end

def create_ao_entitlement(bp, invoice_nb, product, billing_period = 'MONTHLY', start_date = '2013-08-01', amount = 1000.0, invoice_date = start_date)
def create_ao_entitlement(bp, invoice_nb, product, billing_period = 'MONTHLY', start_date = '2013-08-01', end_date = '2013-08-31', amount = 1000.0, invoice_date = start_date)
ao = create_entitlement_ao(@account.account_id, bp.bundle_id, product, billing_period, 'DEFAULT', @user, @options)
check_subscription(ao, product, 'ADD_ON', billing_period, 'DEFAULT', start_date, nil, start_date, nil)
check_fixed_item(invoice_nb, product + '-' + billing_period.downcase, invoice_date, amount, amount, start_date)
check_fixed_item(invoice_nb, product + '-' + billing_period.downcase, invoice_date, amount, amount, start_date, end_date)
ao
end

def change_ao_entitlement(ao, invoice_nb, product, billing_period = 'MONTHLY', ao_start_date = '2013-08-01', amount = 0.0, invoice_date = start_date)
ao = ao.change_plan({ productName: product, billingPeriod: billing_period, priceList: 'DEFAULT' }, @user, nil, nil, nil, nil, nil, false, @options)
def change_ao_entitlement(ao, invoice_nb, product, billing_period = 'MONTHLY', ao_start_date = '2013-08-01', ao_end_date = '2013-08-31', amount = 0.0, invoice_date = start_date)
ao = ao.change_plan({ productName: product, billingPeriod: billing_period, priceList: 'DEFAULT' }, @user, nil, nil, nil, 'IMMEDIATE', nil, false, @options)
check_subscription(ao, product, 'ADD_ON', billing_period, 'DEFAULT', ao_start_date, nil, ao_start_date, nil)
check_fixed_item(invoice_nb, product + '-' + billing_period.downcase, invoice_date, amount, amount)
check_fixed_item(invoice_nb, product + '-' + billing_period.downcase, invoice_date, amount, amount, invoice_date, ao_end_date)
end

def check_subscription_events(bp, ao, bp_events, ao_events)
Expand Down Expand Up @@ -408,9 +409,9 @@ def add_days_and_check_invoice_item(days, invoice_nb, plan, start_date, end_date
check_evergreen_item(invoice_nb, plan, invoice_date, end_date, amount, amount, start_date)
end

def check_fixed_item(invoice_nb, plan, invoice_date, amount, balance, start_date = invoice_date)
def check_fixed_item(invoice_nb, plan, invoice_date, amount, balance, start_date = invoice_date, end_date = invoice_date)
new_invoice = check_invoice_balance(invoice_nb, invoice_date, balance)
check_invoice_item(new_invoice.items.find { |ii| ii.item_type == 'FIXED' }, new_invoice.invoice_id, amount, 'USD', 'FIXED', plan, plan + '-trial', start_date, nil)
check_invoice_item(new_invoice.items.find { |ii| ii.item_type == 'FIXED' }, new_invoice.invoice_id, amount, 'USD', 'FIXED', plan, plan + '-trial', start_date, end_date)
end

def check_evergreen_item(invoice_nb, plan, invoice_date, end_date, amount, balance, start_date = invoice_date)
Expand Down
10 changes: 5 additions & 5 deletions killbill-integration-tests/core/test_entitlement_add_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ def test_cancel_bp_default_policy_in_trial
bps = subscriptions.reject { |s| s.product_category == 'ADD_ON' }
assert_not_nil(bps)
assert_equal(1, bps.size)
check_subscription(bps[0], 'Sports', 'BASE', 'MONTHLY', 'DEFAULT', DEFAULT_KB_INIT_DATE, '2013-08-21', DEFAULT_KB_INIT_DATE, '2013-08-21')
check_subscription(bps[0], 'Sports', 'BASE', 'MONTHLY', 'DEFAULT', DEFAULT_KB_INIT_DATE, '2013-08-21', DEFAULT_KB_INIT_DATE, '2013-08-31')
check_events([{ type: 'START_ENTITLEMENT', date: '2013-08-01' },
{ type: 'START_BILLING', date: '2013-08-01' },
{ type: 'STOP_ENTITLEMENT', date: '2013-08-21' },
{ type: 'STOP_BILLING', date: '2013-08-21' }], bps[0].events)
{ type: 'STOP_BILLING', date: '2013-08-31' }], bps[0].events)

aos = subscriptions.reject { |s| s.product_category == 'BASE' }
assert_not_nil(aos)
assert_equal(1, aos.size)
assert_equal(ao_entitlement.subscription_id, aos[0].subscription_id)
check_subscription(aos[0], 'OilSlick', 'ADD_ON', 'MONTHLY', 'DEFAULT', '2013-08-16', '2013-08-21', '2013-08-16', '2013-08-21')
check_subscription(aos[0], 'OilSlick', 'ADD_ON', 'MONTHLY', 'DEFAULT', '2013-08-16', '2013-08-21', '2013-08-16', '2013-08-31')
check_events([{ type: 'START_ENTITLEMENT', date: '2013-08-16' },
{ type: 'START_BILLING', date: '2013-08-16' },
{ type: 'STOP_ENTITLEMENT', date: '2013-08-21' },
{ type: 'STOP_BILLING', date: '2013-08-21' }], aos[0].events)
{ type: 'STOP_BILLING', date: '2013-08-31' }], aos[0].events)
end

def test_cancel_bp_default_policy_after_trial
Expand Down Expand Up @@ -1095,7 +1095,7 @@ def test_complex_ao
all_invoices = check_next_invoice_amount(1, 0, '2013-08-01', @account, @options, &@proc_account_invoices_nb)
first_invoice = all_invoices[0]
assert_equal(1, first_invoice.items.size, "Invalid number of invoice items: #{first_invoice.items.size}")
check_invoice_item(first_invoice.items[0], first_invoice.invoice_id, 0, 'USD', 'FIXED', 'sports-monthly', 'sports-monthly-trial', '2013-08-01', nil)
check_invoice_item(first_invoice.items[0], first_invoice.invoice_id, 0, 'USD', 'FIXED', 'sports-monthly', 'sports-monthly-trial', '2013-08-01', '2013-08-31')

# Move clock and create Add-on 1 (BP still in trial)
kb_clock_add_days(4, nil, @options) # 05/08/2013
Expand Down
Loading

0 comments on commit 2c194a6

Please sign in to comment.