linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	"qi.fuli@jp.fujitsu.com" <qi.fuli@jp.fujitsu.com>,
	"msys.mizuma@gmail.com" <msys.mizuma@gmail.com>
Subject: Re: [ndctl PATCH v11 5/5] ndctl, test: add a new unit test for monitor
Date: Thu, 12 Jul 2018 20:01:59 +0000	[thread overview]
Message-ID: <1531425717.7574.63.camel@intel.com> (raw)
In-Reply-To: <a7036e1d-6ea1-9a4f-8a9d-82d88279dc81@gmail.com>


On Thu, 2018-07-12 at 15:51 -0400, Masayoshi Mizuma wrote:
> Hi Qi,
> 
> Nice work! Let me ask some comments.
> 
> On 07/10/2018 11:00 PM, QI Fuli wrote:
> [...]
> > diff --git a/test/monitor.sh b/test/monitor.sh
> > new file mode 100755
> > index 0000000..43cb11f
> > --- /dev/null
> > +++ b/test/monitor.sh
> > @@ -0,0 +1,177 @@
> > +#!/bin/bash -Ex
> > +
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright(c) 2018, FUJITSU LIMITED. All rights reserved.
> > +
> > +rc=77
> > +logfile=""
> > +conf_file=""
> > +monitor_dimms=""
> > +monitor_regions=""
> > +monitor_namespace=""
> > +monitor_pid=65536
> > +
> > +. ./common
> > +
> > +trap 'err $LINENO' ERR
> > +
> > +check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
> > +
> > +init()
> > +{
> > +	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
> > +	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
> > +	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
> > +}
> > +
> > +start_monitor()
> > +{
> > +	logfile=$(mktemp)
> > +	$NDCTL monitor -l $logfile $1 &
> > +	monitor_pid=$!
> > +	truncate --size 0 $logfile #remove startup log
> > +	sync; sleep 3
> 
> Should this sync be moved to before the truncate?
> 
> > +}
> > +
> > +get_monitor_dimm()
> > +{
> > +	jlist=$(./list-smart-dimm -b $smart_supported_bus $1)
> > +	monitor_dimms=$(jq '.[]."dev"?, ."dev"?' <<<$jlist | sort | uniq | xargs)
> > +}
> > +
> > +call_notify()
> > +{
> > +	./smart-notify $smart_supported_bus
> > +	sync; sleep 3
> > +}
> > +
> > +inject_smart()
> > +{
> > +	$NDCTL inject-smart $monitor_dimms $1
> > +	sync; sleep 3
> > +}
> > +
> > +check_result()
> > +{
> > +	jlog=$(cat $logfile)
> > +	notify_dimms=$(jq ."dimm"."dev" <<<$jlog | sort | uniq | xargs)
> > +	[[ $monitor_dimms == $notify_dimms ]]
> > +}
> > +
> > +stop_monitor()
> > +{
> > +	kill $monitor_pid
> > +	rm $logfile
> > +}
> > +
> > +create_conf_file()
> > +{
> > +	conf_file=$(mktemp)
> > +	echo "dimm = $1" > $conf_file
> > +}
> > +
> > +test_filter_dimm()
> > +{
> > +	smart_supported_bus=$NFIT_TEST_BUS0
> > +	monitor_dimms=$(./list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev)
> > +	if [ -z $monitor_dimms ]; then
> > +		smart_supported_bus=$NFIT_TEST_BUS1
> > +		monitor_dimms=$(./list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev)
> > +	fi
> > +	start_monitor "-d $monitor_dimms"
> > +	call_notify
> > +	check_result
> > +	stop_monitor
> > +}
> 
> I think the global variable "smart_supported_bus" configuration
> should be separated from this function.
> Like as:
> 
> set_smart_supported_bus()
> {
>         smart_supported_bus=$NFIT_TEST_BUS0
>         monitor_dimms=$(./list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev)
>         if [ -z $monitor_dimms ]; then
>                 smart_supported_bus=$NFIT_TEST_BUS1
>         fi
> }
> 
> > +
> > +test_filter_bus()
> > +{
> > +	monitor_dimms=""
> > +	get_monitor_dimm
> > +	start_monitor "-b $smart_supported_bus"
> > +	call_notify
> > +	check_result
> > +	stop_monitor
> > +}
> > +
> > +test_filter_region()
> > +{
> > +	monitor_dimms=""
> > +	monitor_region=""
> > +	count=$($NDCTL list -R -b $smart_supported_bus | jq -r .[].dev | wc -l)
> > +	i=0
> > +	while [ $i -lt $count ]; do
> > +		monitor_region=$($NDCTL list -R -b $smart_supported_bus | jq -r .[$i].dev)
> > +		get_monitor_dimm "-r $monitor_region"
> > +		[ ! -z $monitor_dimms ] && break
> > +		i=$[$i+1]
> 
> i=$(( $i + 1 )) is better. $[...] is not described in the man page of bash...

.. and within the $(( )), you can forego the '$' for variables. So it
becomes: i=$((i + 1))

> 
> > +	done
> > +	start_monitor "-r $monitor_region"
> > +	call_notify
> > +	check_result
> > +	stop_monitor
> > +}
> > +
> > +test_filter_namespace()
> > +{
> > +	monitor_dimms=""
> > +	init
> > +	monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev)
> > +	get_monitor_dimm "-n $monitor_namespace"
> > +	start_monitor "-n $monitor_namespace"
> > +	call_notify
> > +	check_result
> > +	stop_monitor
> > +	$NDCTL destroy-namespace $monitor_namespace -f
> > +}
> > +
> > +test_conf_file()
> > +{
> > +	create_conf_file  "$monitor_dimms"
> > +	start_monitor "-c $conf_file"
> > +	call_notify
> > +	check_result
> > +	stop_monitor
> > +	rm $conf_file
> > +}
> > +
> > +test_filter_dimmevent()
> > +{
> > +	monitor_dimms="$(echo $monitor_dimms | awk '{print $1}')"
> > +
> > +	start_monitor "-d $monitor_dimms -D dimm-unclean-shutdown"
> > +	inject_smart "-U"
> > +	check_result
> > +	stop_monitor
> > +
> > +	inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r ."health"."spares_threshold")
> > +	inject_value=$[$inject_value-1]
> 
> Same as above.
> 
> > +	start_monitor "-d $monitor_dimms -D dimm-spares-remaining"
> > +	inject_smart "-s $inject_value"
> > +	check_result
> > +	stop_monitor
> > +
> > +	inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r ."health"."temperature_threshold")
> > +	inject_value=$[$inject_value+1]
> 
> Same as above.
> 
> Thanks,
> Masa
> 
> > +	start_monitor "-d $monitor_dimms -D dimm-media-temperature"
> > +	inject_smart "-s $inject_value"
> > +	check_result
> > +	stop_monitor
> > +}
> > +
> > +do_tests()
> > +{
> > +	test_filter_dimm
> > +	test_filter_bus
> > +	test_filter_region
> > +	test_filter_namespace
> > +	test_conf_file
> > +	test_filter_dimmevent
> > +}
> > +
> > +modprobe nfit_test
> > +rc=1
> > +init
> > +do_tests
> > +_cleanup
> > +exit 0
> > 
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-07-12 20:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11  3:00 [ndctl PATCH v11 0/5] ndctl, monitor: add ndctl monitor daemon QI Fuli
2018-07-11  3:00 ` [ndctl PATCH v11 1/5] ndctl, monitor: add a new command - monitor QI Fuli
2018-07-13  2:46   ` Verma, Vishal L
2018-07-11  3:00 ` [ndctl PATCH v11 2/5] ndctl, monitor: add main ndctl monitor configuration file QI Fuli
2018-07-11  3:00 ` [ndctl PATCH v11 3/5] ndctl, monitor: add the unit file of systemd for ndctl-monitor service QI Fuli
2018-07-13  2:46   ` Verma, Vishal L
2018-07-13 12:57     ` Qi, Fuli
2018-07-13 14:51       ` Masayoshi Mizuma
2018-07-11  3:00 ` [ndctl PATCH v11 4/5] ndctl, documentation: add manpage for monitor QI Fuli
2018-07-13  2:47   ` Verma, Vishal L
2018-07-11  3:00 ` [ndctl PATCH v11 5/5] ndctl, test: add a new unit test " QI Fuli
2018-07-12 19:51   ` Masayoshi Mizuma
2018-07-12 20:01     ` Verma, Vishal L [this message]
2018-07-13  1:44       ` Qi, Fuli
2018-07-13  2:46 ` [ndctl PATCH v11 0/5] ndctl, monitor: add ndctl monitor daemon Verma, Vishal L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531425717.7574.63.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=msys.mizuma@gmail.com \
    --cc=qi.fuli@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).