Changeset 15846 in project


Ignore:
Timestamp:
09/13/09 11:45:05 (10 years ago)
Author:
sjamaan
Message:

Normalize exported names a bit

Location:
release/4/estraier-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/estraier-client/estraier-client.scm

    r15842 r15846  
    3636
    3737;; TODO: Perhaps split URIs into "base uri" and "node name".
    38 ;; Master can be derived.  This way we can also get rid of the
    39 ;; master-/node- prefix.  It would just be "clear-node" and "list-documents"
    4038
    4139(module estraier-client
    42   (node-info node-cache-usage node-optimize node-sync document-uri->id
     40  (get-node-info node-cache-usage optimize-node sync-node document-uri->id
    4341   list-documents put-document delete-document get-document
    4442   update-attributes document-attribute document-keywords find-documents
     
    4846   read-attributes read-draft write-attributes write-draft
    4947
    50    master-shutdown master-sync master-backup master-rotate-log
    51    master-nodes master-add-node master-delete-node master-clear-node
    52    master-users master-add-user master-delete-user)
     48   shutdown-master sync-master backup-master rotate-log
     49   list-nodes add-node delete-node clear-node list-users add-user delete-user)
    5350
    5451(import chicken scheme)
     
    9491    (update-uri uri path: (append (uri-path uri) (list action)))))
    9592
    96 (define (node-info node)
     93(define (get-node-info node)
    9794  (exec
    9895   (node-uri node "inform")
     
    116113  (string->number (exec (node-uri node "cacheusage") #f read-line)))
    117114
    118 (define (node-optimize node)
     115(define (optimize-node node)
    119116  (exec (node-uri node "optimize") #f discard-output))
    120117
    121 (define (node-sync node)
     118(define (sync-node node)
    122119  (exec (node-uri node "sync") #f discard-output))
    123120
     
    299296;;;; Master API
    300297
    301 ;; TODO: Maybe change the name so this is not all prefixed "master-"?
    302 ;; The node procedures are not prefixed "node-" either.
    303298(define (master-uri master action . args)
    304299  (let ((uri (if (uri-reference? master)
     
    307302    (update-uri uri query: (alist-update! 'action action (uri-query uri)))))
    308303
    309 (define (master-shutdown master)
     304(define (shutdown-master master)
    310305  (exec (master-uri master "shutdown") #f discard-output))
    311306
    312 (define (master-sync master)
     307(define (sync-master master)
    313308  (exec (master-uri master "sync") #f discard-output))
    314309
    315 (define (master-backup master)
     310(define (backup-master master)
    316311  (exec (master-uri master "backup") #f discard-output))
    317312
    318 (define (master-rotate-log master)
     313(define (rotate-log master)
    319314  (exec (master-uri master "logrtt") #f discard-output))
    320315
    321 (define (master-nodes master)
     316(define (list-nodes master)
    322317  (map (lambda (line)
    323318         (string-split line "\t" #t))
    324319       (exec (master-uri master "nodelist") #f read-lines)))
    325320
    326 (define (master-add-node master node-name #!optional node-label)
     321(define (add-node master node-name #!optional node-label)
    327322  (exec (master-uri master "nodeadd"
    328323                    query: `((name . ,node-name) (label . ,node-label)))
    329324        #f discard-output))
    330325
    331 (define (master-delete-node master node-name)
     326(define (delete-node master node-name)
    332327  (exec (master-uri master "nodedel" query: `((name . ,node-name)))
    333328        #f discard-output))
    334329
    335 (define (master-clear-node master node-name)
     330(define (clear-node master node-name)
    336331  (exec (master-uri master "nodeclr" query: `((name . ,node-name)))
    337332        #f discard-output))
    338333
    339 (define (master-users master)
     334(define (list-users master)
    340335  (exec (master-uri master "userlist")
    341336        #f
     
    348343                      (cons (string-split line "\t" #t) lines)))))))
    349344
    350 (define (master-add-user master username password
     345(define (add-user master username password
    351346                         #!key flags fullname description)
    352347  (exec (make-request uri: (master-uri master "useradd")
     
    356351        discard-output))
    357352
    358 (define (master-delete-user master username)
     353(define (delete-user master username)
    359354  (exec (master-uri master "userdel" query: `((name . ,username)))
    360355        #f discard-output))
  • release/4/estraier-client/tests/run.scm

    r15839 r15846  
    1616
    1717(test-group "node master API"
    18   (test "Empty node list on init" '() (master-nodes master-uri))
     18  (test "Empty node list on init" '() (list-nodes master-uri))
    1919  (test-error "Cannot connect with invalid credentials"
    20               (master-nodes "http://admin:invalid@localhost:1978/master"))
    21   (let ((nodes (begin (master-add-node master-uri "testnode")
    22                       (master-add-node master-uri "testnode2" "testlabel")
    23                       (master-nodes master-uri))))
     20              (list-nodes "http://admin:invalid@localhost:1978/master"))
     21  (let ((nodes (begin (add-node master-uri "testnode")
     22                      (add-node master-uri "testnode2" "testlabel")
     23                      (list-nodes master-uri))))
    2424    (test "After adding two nodes, they show up"
    2525          '("testnode" "testnode2")
     
    3030  (test "After deleting a node, it is gone"
    3131        '("testnode")
    32         (begin (master-delete-node master-uri "testnode2")
    33                (map car (master-nodes master-uri))))
    34   (let ((users (begin (master-add-user master-uri "testuser" "password"
    35                                        fullname: "Joe testuser"
    36                                        description: "This is just a test")
    37                       (master-users master-uri))))
     32        (begin (delete-node master-uri "testnode2")
     33               (map car (list-nodes master-uri))))
     34  (let ((users (begin (add-user master-uri "testuser" "password"
     35                                fullname: "Joe testuser"
     36                                description: "This is just a test")
     37                      (list-users master-uri))))
    3838    (test "After adding a user, it shows up"
    3939          '("admin" "testuser")
     
    4141  (test "After deleting a user, it is gone"
    4242        '("admin")
    43         (begin (master-delete-user master-uri "testuser")
    44                (map car (master-users master-uri)))))
     43        (begin (delete-user master-uri "testuser")
     44               (map car (list-users master-uri)))))
    4545
    4646;; TODO: more in-depth tests of master result values
    4747
    4848(test-group "node API"
    49   (let ((info (node-info node-uri)))
    50     (test "Node-info reports zero documents at first"
     49  (let ((info (get-node-info node-uri)))
     50    (test "Get-node-info reports zero documents at first"
    5151          0 (alist-ref 'document-count info))
    52     (test "Node-info reports zero words at first"
     52    (test "Get-node-info reports zero words at first"
    5353          0 (alist-ref 'word-count info))
    54     (test "Node-info reports no guests at first"
     54    (test "Get-node-info reports no guests at first"
    5555          '() (alist-ref 'guest-users info))
    56     (test "Node-info reports no admins at first"
     56    (test "Get-node-info reports no admins at first"
    5757          '() (alist-ref 'admin-users info)))
    5858  (test "Cache usage starts out empty"
     
    6969               (register-admin-user node-uri "admin2")
    7070               (register-admin-user node-uri "both")
    71                (let ((info (node-info node-uri)))
     71               (let ((info (get-node-info node-uri)))
    7272                 (list (alist-ref 'guest-users info)
    7373                       (alist-ref 'admin-users info)))))
     
    7777               (unregister-user node-uri "admin1")
    7878               (unregister-user node-uri "both")
    79                (let ((info (node-info node-uri)))
     79               (let ((info (get-node-info node-uri)))
    8080                 (list (alist-ref 'guest-users info)
    8181                       (alist-ref 'admin-users info)))))
     
    9191                 #t))
    9292  ;; If we don't sync, the newly added docs don't (always?) show up...
    93   (test-assert "Synchronize works" (begin (node-sync node-uri) #t))
    94   (let ((info (node-info node-uri)))
    95     (test "Node-info reports the new documents"
     93  (test-assert "Synchronize works" (begin (sync-node node-uri) #t))
     94  (let ((info (get-node-info node-uri)))
     95    (test "Get-node-info reports the new documents"
    9696          2 (alist-ref 'document-count info))
    97     (test "Node-info reports the total number of words"
     97    (test "Get-node-info reports the total number of words"
    9898          6 (alist-ref 'word-count info))  ;; "test for estraier" is in both
    9999    ;; Why does this still report zero?
     
    137137                                   '("Simply a test for estraier")
    138138                                   meta)
    139                      (node-sync node-uri)
     139                     (sync-node node-uri)
    140140                    #t))
    141141      (receive (doc meta)
     
    187187  (test "Clearing node results in empty document list"
    188188        '()
    189         (begin (master-clear-node master-uri "testnode")
     189        (begin (clear-node master-uri "testnode")
    190190               (list-documents node-uri))))
    191191
     
    193193
    194194(test-group "cleanup"
    195  (test-assert "Clean shutdown" (begin (master-shutdown master-uri) #t))
    196  (test-error "After shutdown, server is unreachable" (master-nodes master-uri)))
     195 (test-assert "Clean shutdown" (begin (shutdown-master master-uri) #t))
     196 (test-error "After shutdown, server is unreachable" (list-nodes master-uri)))
    197197(system "rm -rf masterdir")
Note: See TracChangeset for help on using the changeset viewer.