Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evg-tso committed Jan 14, 2024
1 parent 0ca0eb0 commit d3fc4ff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
14 changes: 13 additions & 1 deletion src/main/clojure/aerospike_clj/batch_policy.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
(ns aerospike-clj.batch-policy
(:require [aerospike-clj.policy :as policy])
(:import #_{:clj-kondo/ignore [:unused-import]}
(com.aerospike.client.policy BatchPolicy BatchWritePolicy ClientPolicy RecordExistsAction)))
(com.aerospike.client.policy BatchPolicy
BatchWritePolicy
ClientPolicy
CommitLevel
GenerationPolicy
RecordExistsAction)))

(defn map->batch-policy
"Create a `BatchPolicy` from a map.
Expand Down Expand Up @@ -35,3 +40,10 @@
[^ClientPolicy client-policy conf]
(set! (.batchParentPolicyWriteDefault client-policy) (get conf "batchParentPolicyWriteDefault" (map->batch-policy conf)))
(set! (.batchWritePolicyDefault client-policy) (get conf "batchWritePolicyDefault" (map->batch-write-policy conf))))

(defn create-client-policy
"This is a wrapper around [[policy/create-client-policy]] that adds the batch policies to the client policy."
^ClientPolicy [event-loops conf]
(let [client-policy (policy/create-client-policy event-loops conf)]
(add-batch-write-policy client-policy conf)
client-policy))
54 changes: 29 additions & 25 deletions test/aerospike_clj/integration/integration_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
:integration true}
aerospike-clj.integration.integration-test
(:require [aerospike-clj.batch-client]
[clojure.test :refer [deftest testing is use-fixtures]]
[cheshire.core :as json]
[aerospike-clj.integration.aerospike-setup :as as-setup]
[aerospike-clj.batch-policy :as batch-policy]
[aerospike-clj.client :as client]
[aerospike-clj.protocols :as pt]
[aerospike-clj.policy :as policy]
[aerospike-clj.integration.aerospike-setup :as as-setup]
[aerospike-clj.key :as as-key]
[aerospike-clj.policy :as policy]
[aerospike-clj.protocols :as pt]
[aerospike-clj.utils :as utils]
[cheshire.core :as json]
[clojure.test :refer [deftest is testing use-fixtures]]
[spy.core :as spy])
(:import (com.aerospike.client Value AerospikeClient BatchWrite Operation Bin)
(com.aerospike.client.cdt ListOperation ListPolicy ListOrder ListWriteFlags ListReturnType
MapOperation MapPolicy MapOrder MapWriteFlags MapReturnType CTX)
(com.aerospike.client.policy ReadModeSC ReadModeAP Replica GenerationPolicy RecordExistsAction
WritePolicy BatchPolicy Policy CommitLevel BatchWritePolicy)
(java.util HashMap ArrayList)
(java.util.concurrent ExecutionException)
(:import (aerospike_clj.client SimpleAerospikeClient)
(clojure.lang PersistentArrayMap)
(aerospike_clj.client SimpleAerospikeClient)
(com.aerospike.client.exp Exp)))
(com.aerospike.client AerospikeClient BatchWrite Bin Operation Value)
(com.aerospike.client.cdt CTX ListOperation ListOrder ListPolicy ListReturnType
ListWriteFlags MapOperation MapOrder MapPolicy MapReturnType MapWriteFlags)
(com.aerospike.client.exp Exp)
(com.aerospike.client.policy BatchPolicy BatchWritePolicy CommitLevel GenerationPolicy Policy
ReadModeAP ReadModeSC RecordExistsAction Replica WritePolicy)
(java.util ArrayList HashMap)
(java.util.concurrent ExecutionException)))

(def _set "set")
(def _set2 "set2")
Expand Down Expand Up @@ -650,18 +650,22 @@

(deftest configure-batch-write-policies
(let [expression (Exp/build (Exp/ge (Exp/intBin "a") (Exp/intBin "b")))
event-loops (client/create-event-loops {})
c (client/init-simple-aerospike-client
*as-hosts* as-namespace
{"batchWritePolicyDefault" (batch-policy/map->batch-write-policy {"CommitLevel" "COMMIT_MASTER"
"durableDelete" true
"expiration" 1000
"generation" 7
"GenerationPolicy" "EXPECT_GEN_GT"
"RecordExistsAction" "REPLACE_ONLY"
"filterExp" expression})
"batchParentPolicyWriteDefault" (policy/map->batch-policy {"allowInline" false
"maxConcurrentThreads" 2
"sendSetName" true})})
*as-hosts*
as-namespace
{:client-policy (batch-policy/create-client-policy
event-loops
{"batchWritePolicyDefault" (batch-policy/map->batch-write-policy {"CommitLevel" "COMMIT_MASTER"
"durableDelete" true
"expiration" 1000
"generation" 7
"GenerationPolicy" "EXPECT_GEN_GT"
"RecordExistsAction" "REPLACE_ONLY"
"filterExp" expression})
"batchParentPolicyWriteDefault" (policy/map->batch-policy {"allowInline" false
"maxConcurrentThreads" 2
"sendSetName" true})})})

batch-write-policy ^BatchWritePolicy (.getBatchWritePolicyDefault ^AerospikeClient (.-client ^SimpleAerospikeClient c))
batch-parent-write-policy ^BatchPolicy (.getBatchParentPolicyWriteDefault ^AerospikeClient (.-client ^SimpleAerospikeClient c))]
Expand Down

0 comments on commit d3fc4ff

Please sign in to comment.