From 445d96977fd10be49ce1e9ccd34b462b178bc96b Mon Sep 17 00:00:00 2001 From: Dominic Pelini Date: Thu, 19 Dec 2024 05:58:02 -0700 Subject: [PATCH] Set MRT tests to run on enterprise only except for backward_compatible test. --- lib/abort_status.js | 2 +- ts-test/tests/mrt_api.ts | 3 + ts-test/tests/mrt_backward_compatible.ts | 100 +++++++++++++++++++++++ ts-test/tests/mrt_functionality.ts | 3 + 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 ts-test/tests/mrt_backward_compatible.ts diff --git a/lib/abort_status.js b/lib/abort_status.js index 65222988..a647ef1e 100644 --- a/lib/abort_status.js +++ b/lib/abort_status.js @@ -23,6 +23,6 @@ module.exports = { OK: abortStatus.OK, ALREADY_COMMITTED: abortStatus.ALREADY_COMMITTED, ALREADY_ABORTED: abortStatus.ALREADY_ABORTED, - ROLL_BACK_ABANDONED: abortStatus.MARK_ROLL_FORWARD_ABANDONED, + ROLL_BACK_ABANDONED: abortStatus.ROLL_BACK_ABANDONED, CLOSE_ABANDONED: abortStatus.CLOSE_ABANDONED } diff --git a/ts-test/tests/mrt_api.ts b/ts-test/tests/mrt_api.ts index 4833d220..b3205e10 100644 --- a/ts-test/tests/mrt_api.ts +++ b/ts-test/tests/mrt_api.ts @@ -31,6 +31,9 @@ const recgen: any = helper.recgen const status: typeof statusModule = Aerospike.status describe('MRT API Tests', function () { + helper.skipUnlessVersion('>= 8.0.0', this) + helper.skipUnlessEnterprise(this) + const client: Cli = helper.client it('should initialize a transaction', async function () { diff --git a/ts-test/tests/mrt_backward_compatible.ts b/ts-test/tests/mrt_backward_compatible.ts new file mode 100644 index 00000000..5e975761 --- /dev/null +++ b/ts-test/tests/mrt_backward_compatible.ts @@ -0,0 +1,100 @@ +// ***************************************************************************** +// Copyright 2013-2023 Aerospike, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ***************************************************************************** + +'use strict' + +/* eslint-env mocha */ +/* global expect */ + +import Aerospike, { Key as K, RecordMetadata, status as statusModule, AerospikeRecord, Client as Cli, WritePolicyOptions, ReadPolicyOptions, AerospikeError } from 'aerospike'; + +import { expect, assert } from 'chai'; +import * as helper from './test_helper'; + +const keygen: any = helper.keygen +const metagen: any = helper.metagen +const recgen: any = helper.recgen + +const status: typeof statusModule = Aerospike.status + +describe('MRT functionality tests', function () { + + helper.skipUnlessVersion('< 8.0.0', this) + const client: Cli = helper.client + + const key1: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/1' })() + const key2: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/2' })() + const key3: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/3' })() + const key4: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/4' })() + const key5: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/5' })() + const key6: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/6' })() + const key7: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/7' })() + + const meta: RecordMetadata = metagen.constant({ ttl: 1000 })() + + const record1: AerospikeRecord = recgen.constant({ i: 123, s: 'abc' })() + const record2: AerospikeRecord = recgen.constant({ i: 456, s: 'def' })() + const record3: AerospikeRecord = recgen.constant({ i: 789, s: 'ghi' })() + + + + before(async function () { + await client.put(key1, record1, meta) + + await client.put(key2, record1, meta) + await client.put(key3, record1, meta) + await client.put(key4, record1, meta) + + }) + + it('Should execute a simple multi-record transaction', async function () { + + let mrt: any = new Aerospike.Transaction() + + let policy: any = { + txn: mrt + }; + + await client.put(key1, record2, meta, policy) + + let get_result: AerospikeRecord = await client.get(key1, policy) + expect(get_result.bins).to.eql(record2) + + let result: number = await client.commit(mrt) + expect(result).to.eql(Aerospike.commitStatus.ROLL_FORWARD_ABANDONED) + + }) + + it('Should execute a simple multi-record transaction abort', async function () { + + let mrt: any = new Aerospike.Transaction() + + let policy: any = { + txn: mrt + }; + + await client.put(key2, record2, meta, policy) + //await client.put(key3, record2, meta, policy) + //await client.put(key4, record2, meta, policy) + + let get_result: AerospikeRecord = await client.get(key1, policy) + expect(get_result.bins).to.eql(record2) + + let result: number = await client.abort(mrt) + expect(result).to.eql(Aerospike.abortStatus.ROLL_BACK_ABANDONED) + }) + +}) \ No newline at end of file diff --git a/ts-test/tests/mrt_functionality.ts b/ts-test/tests/mrt_functionality.ts index 10a261b3..8fd4c6af 100644 --- a/ts-test/tests/mrt_functionality.ts +++ b/ts-test/tests/mrt_functionality.ts @@ -31,6 +31,9 @@ const recgen: any = helper.recgen const status: typeof statusModule = Aerospike.status describe('MRT functionality tests', function () { + helper.skipUnlessVersion('>= 8.0.0', this) + helper.skipUnlessEnterprise(this) + const client: Cli = helper.client const key1: K = keygen.string(helper.namespace, helper.set, { prefix: 'test/mrt/1' })()