<commit_before>(ns onyx.log.gc-test
  (:require [onyx.extensions :as extensions]
            [onyx.log.entry :refer [create-log-entry]]
            [onyx.system]
            [midje.sweet :refer :all]))

(def entry (create-log-entry :gc {:id :my-client-id}))

(def f (partial extensions/apply-log-entry entry))

(def rep-diff (partial extensions/replica-diff entry))

(def rep-reactions (partial extensions/reactions entry))

(def old-replica
  {:jobs [:j1 :j2 :j3]
   :tasks {:j1 [:t1 :t2]
           :j2 [:t3 :t4]
           :j3 [:t5 :t6]}
   :task-schedulers {:j1 :onyx.task-scheduler/greedy
                     :j2 :onyx.task-scheduler/greedy
                     :j3 :onyx.task-scheduler/greedy}
   :killed-jobs [:j1]
   :completions {:j3 [:t5 :t6]}
   :allocations {:j1 {:t2 []}
                 :j2 {:t3 [:p1]}}})

(let [new-replica (f old-replica)
      diff (rep-diff old-replica new-replica)
      reactions (rep-reactions old-replica new-replica diff {})]
  (fact new-replica =>
        {:jobs [:j2]
         :tasks {:j2 [:t3 :t4]}
         :task-schedulers {:j2 :onyx.task-scheduler/greedy}
         :killed-jobs []
         :completions {}
         :allocations {:j2 {:t3 [:p1]}}
         :percentages nil
         :saturation nil
         :task-percentages nil})
  (fact reactions => [])
  (fact diff => {:jobs #{:j1 :j3}
                 :killed-jobs #{:j1}
                 :completions {:j3 [:t5 :t6]}
                 :tasks {:j1 [:t1 :t2] :j3 [:t5 :t6]}
                 :allocations {:j1 {:t2 []}}}))

<commit_msg>Pass GC log test.<commit_after>(ns onyx.log.gc-test
  (:require [onyx.extensions :as extensions]
            [onyx.log.entry :refer [create-log-entry]]
            [onyx.system]
            [midje.sweet :refer :all]))

(def entry (create-log-entry :gc {:id :my-client-id}))

(def f (partial extensions/apply-log-entry entry))

(def rep-diff (partial extensions/replica-diff entry))

(def rep-reactions (partial extensions/reactions entry))

(def old-replica
  {:jobs [:j1 :j2 :j3]
   :tasks {:j1 [:t1 :t2]
           :j2 [:t3 :t4]
           :j3 [:t5 :t6]}
   :task-schedulers {:j1 :onyx.task-scheduler/greedy
                     :j2 :onyx.task-scheduler/greedy
                     :j3 :onyx.task-scheduler/greedy}
   :killed-jobs [:j1]
   :completions {:j3 [:t5 :t6]}
   :allocations {:j1 {:t2 []}
                 :j2 {:t3 [:p1]}}})

(let [new-replica (f old-replica)
      diff (rep-diff old-replica new-replica)
      reactions (rep-reactions old-replica new-replica diff {})]
  (fact new-replica =>
        {:jobs [:j2]
         :tasks {:j2 [:t3 :t4]}
         :task-schedulers {:j2 :onyx.task-scheduler/greedy}
         :killed-jobs []
         :completions {}
         :allocations {:j2 {:t3 [:p1]}}
         :percentages nil
         :saturation nil
         :task-percentages nil
         :input-tasks nil
         :output-tasks nil})
  (fact reactions => [])
  (fact diff => {:jobs #{:j1 :j3}
                 :killed-jobs #{:j1}
                 :completions {:j3 [:t5 :t6]}
                 :tasks {:j1 [:t1 :t2] :j3 [:t5 :t6]}
                 :allocations {:j1 {:t2 []}}}))


{'fraction_non_alphanumeric': 0.1712, 'fraction_numerical': 0.02944, 'mean_word_length': 2.0617042115572968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209018', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1178, 'n_words': 263}