Skip to content

Commit

Permalink
Set MRT tests to run on enterprise only except for backward_compatibl…
Browse files Browse the repository at this point in the history
…e test.
  • Loading branch information
DomPeliniAerospike committed Dec 19, 2024
1 parent 7d3e7dd commit 445d969
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/abort_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions ts-test/tests/mrt_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
100 changes: 100 additions & 0 deletions ts-test/tests/mrt_backward_compatible.ts
Original file line number Diff line number Diff line change
@@ -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)
})

})
3 changes: 3 additions & 0 deletions ts-test/tests/mrt_functionality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })()
Expand Down

0 comments on commit 445d969

Please sign in to comment.