Changes In Branch v1.65-inode-check
Excluding Merge-Ins
This is equivalent to a diff from
2cf2b7b144
to f66fad5ea7
Added archive_util/Makefile version [e25a4a3c5e].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# Copyright 2006-2017, Matthew Welland.
#
# This file is part of Megatest.
#
# Megatest is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Megatest is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Megatest. If not, see <http://www.gnu.org/licenses/>.
# make install CSCOPTS='-accumulate-profile -profile-name $(PWD)/profile-ww$(shell date +%V.%u)'
# rm <files>.o ; make install CSCOPTS='-profile' ; ... ; chicken-profile | less
SHELL=/bin/bash
PREFIX=$(PWD)
CSCOPTS=
INSTALL=install
all: archive.scm
csc -static -L -static -L -lsqlite3 -L -lm -L -ldl -L -lpthread archive.scm
|
| | | | | | | | | | | | | | | | | | | | | | | | |
Added archive_util/archive.scm version [6072980f65].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(import
big-chicken
regex
sqlite3
)
(define (copy-database workweek)
(print "Copy megatest.db to mt_archive/" workweek "/megatest.db")
(if (file-exists? (conc "mt_archive/" workweek "/megatest.db"))
(begin (print "Archive already exists. Exiting") (quit))
)
(if (not (file-exists? (conc "mt_archive/" workweek)))
(begin
(print "Create archive dir")
(create-directory (conc "mt_archive/" workweek) #t)
)
(print "Archive dir already exists")
)
(copy-file "megatest.db" (conc "mt_archive/" workweek "/megatest.db"))
(with-output-to-file (conc "mt_archive/" workweek "/megatest.config")
(lambda() (print "[include ../../megatest.config]"))
)
;;(create-symbolic-link "megatest.config" (conc "mt_archive/" workweek "/megatest.config"))
;;(create-symbolic-link "configs" (conc "mt_archive/" workweek "/configs"))
;;(create-symbolic-link "runconfigs.config" (conc "mt_archive/" workweek "/runconfigs.config"))
)
(define (delete-orphan-tests db)
(execute db (conc "DELETE FROM tests where run_id NOT IN (select distinct id from runs)"))
)
(define (delete-orphan-steps db)
(execute db (conc "DELETE FROM test_steps where test_id NOT IN (select distinct id from tests)"))
)
(define (vacuum-db db)
(execute db (conc "VACUUM;"))
)
(define (trim-runs file operand timestamp)
(print "Trim Runs from " file " where timestamp is " operand " " timestamp)
(let* ((db (open-database file))
(cmd (conc "DELETE FROM runs WHERE event_time " operand " " timestamp)))
(print (database? db))
(print "CMD: " cmd)
(with-transaction db
(lambda ()
(execute db cmd)
(delete-orphan-tests db)
(delete-orphan-steps db)
)
)
(vacuum-db db)
)
)
(let* ((workweek (string-chomp (call-with-input-pipe "date +%yww%V" (lambda (port) (read-string #f port)) ) ))
(fortyfive-days-ago (- (current-seconds) (* 60 60 24 45)) )
;;(user (get-environment-variable "USER"))
(area "libanatmpltsqa")
(user (current-user-name))
(path (string-translate (current-directory) "/" ".")))
(print "Path: " path)
(print "User: " user)
(print "Megatest.db: " (conc "/tmp/" user "/megatest_localdb/" area "/" path "/megatest.db") )
(print "Megatest_ref.db: " (conc "/tmp/" user "/megatest_localdb/" area "/" path "/megatest_ref.db") )
;;(quit)
(copy-database workweek)
(trim-runs "megatest.db" "<" fortyfive-days-ago)
(trim-runs (conc "/tmp/" user "/megatest_localdb/" area "/" path "/megatest.db") "<" fortyfive-days-ago)
(trim-runs (conc "/tmp/" user "/megatest_localdb/" area "/" path "/megatest_ref.db") "<" fortyfive-days-ago)
(trim-runs (conc "mt_archive/" workweek "/megatest.db") ">=" fortyfive-days-ago)
)
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Modified common.scm
from [424526ac90]
to [6567c70358].
︙ | | |
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
|
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
(conc (configf:lookup *configdat* "setup" "free-space-script") " " path)
(lambda ()
(let ((res (read-line)))
(if (string? res)
(string->number res)))))
(get-unix-df path)))
(define (get-free-inodes path)
(if (configf:lookup *configdat* "setup" "free-inodes-script")
(with-input-from-pipe
(conc (configf:lookup *configdat* "setup" "free-inodes-script") " " path)
(lambda ()
(let ((res (read-line)))
(if (string? res)
(string->number res)))))
(get-unix-inodes path)))
(define (get-unix-df path)
(let* ((df-results (process:cmd-run->list (conc "df " path)))
(space-rx (regexp "([0-9]+)\\s+([0-9]+)%"))
(freespc #f))
;; (write df-results)
(for-each (lambda (l)
(let ((match (string-search space-rx l)))
(if match
(let ((newval (string->number (cadr match))))
(if (number? newval)
(set! freespc newval))))))
(car df-results))
freespc))
(define (get-unix-inodes path)
(let* ((df-results (process:cmd-run->list (conc "df -i " path)))
(space-rx (regexp "([0-9]+)\\s+([0-9]+)%"))
(freenodex #f))
;; (write df-results)
(for-each (lambda (l)
(let ((match (string-search space-rx l)))
(if match
(let ((newval (string->number (cadr match))))
(if (number? newval)
(set! freenodes newval))))))
(car df-results))
freenodes))
(define (common:check-space-in-dir dirpath required)
(let* ((dbspace (if (directory? dirpath)
(get-df dirpath)
0)))
(list (> dbspace required)
dbspace
|
︙ | | |
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
|
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
|
-
+
+
-
-
+
+
+
-
+
+
+
|
(debug:print-error 0 *default-log-port* "Insufficient space in " dbdir ", require " required ", have " dbspace ", exiting now.")
(exit 1)))))
;; paths is list of lists ((name path) ... )
;;
(define (common:get-disk-with-most-free-space disks minsize)
(let ((best #f)
(bestsize 0))
(bestsize 0)
(min-inodes (or (string->number (if (configf:lookup *configdat* "setup" "min_inodes") (configf:lookup *configdat* "setup" "min_inodes") "0")) 0)))
(for-each
(lambda (disk-num)
(let* ((dirpath (cadr (assoc disk-num disks)))
(freespc (cond
((not (directory? dirpath))
(if (common:low-noise-print 300 "disks not a dir " disk-num)
(debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not a directory - ignoring it."))
-1)
((not (file-write-access? dirpath))
(if (common:low-noise-print 300 "disks not writeable " disk-num)
(debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not writeable - ignoring it."))
-1)
((not (eq? (string-ref dirpath 0) #\/))
(if (common:low-noise-print 300 "disks not a proper path " disk-num)
(debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not a fully qualified path - ignoring it."))
-1)
(else
(get-df dirpath)))))
(if (> freespc bestsize)
(get-df dirpath))))
(free-inodes (get-free-inodes dirpath)))
(if (and (> freespc bestsize)(> free-inodes min-inodes ))
(begin
(set! best (cons disk-num dirpath))
(set! bestsize freespc)))))
(set! bestsize freespc)))
;;(print "Processing: " disk-num " bestsize: " bestsize " best: " best " freespc: " freespc " min-inodes: " min-inodes " free-inodes: " free-inodes)
))
(map car disks))
(if (and best (> bestsize minsize))
best
#f))) ;; #f means no disk candidate found
;; convert a spec string to a list of vectors #( rx action rx-string )
(define (common:spec-string->list-of-specs spec-string actions)
|
︙ | | |
Modified megatest-version.scm
from [b25584fe0f]
to [ebab2f4c71].
︙ | | |
16
17
18
19
20
21
22
23
|
16
17
18
19
20
21
22
23
|
-
+
|
;; along with Megatest. If not, see <http://www.gnu.org/licenses/>.
;; Always use two or four digit decimal
;; 1.01, 1.02...1.10,1.11,1.1101 ... 1.99,2.00..
(declare (unit megatest-version))
(define megatest-version 1.6530)
(define megatest-version 1.6531)
|