软件测试一般分为四个步骤:(1)单元测试(也称模块测试):针对软件设计的基本单元——程序模块,进行正确性检验的测试工作。目的在于发现各个模块内部可能存在的各种差错。单元测试需要从程序内部结构出发设计测试用例,多个模块可以平行、独立地进行测试;(2)集成测试(也称组装测试,联合测试):在单元测试的基础上,将所有模块按设计要求集成在一起进行测试,以检验总体设计中各模块间的接口设计问题、模块之间的相互影响、上层模块存在的各种差错及全局数据结构对系统的影响等方面。(3)确认测试(也称验收测试,有效性测试):主要检验软件的功能和性能是否与需求说明书中的规定一致。(4)系统测试:将软件系统作为一个元素,放入整个实际的计算机系统中,与计算机硬件、其他软件、使用人员等系统元素结合在一起,在实际使用环境下进行综合全面的测试。
Category: Life
-
今天学习ruby sinatra slim
ruby语言支持
sinatra是web支持
sinatra是通过Application.run!来启动服务器的
slim是模板支持
slim引入外部css和js == stylesheet_link_tag “xxx”
开发还是在vps上搞,方便
http://kxh.github.com/Bootstrap_doc_in_chinese/scaffolding.html#layouts
确定官方的文档有70%以上会了再去其他地方弄,弄来弄去还要去查官方的文档
一个小入口上要付出很多努力,10次以上的试验
http://blogs.ejb.cc/archives/2690/first-met-sinatra
-
npm-nodejs包管理器
npm — node package manager
全局安装nodejs包
npm -g install net-ping
查看已经安装的nodejs应用
npm ls -g installed
创建项目过程,首先创建一个目录 mvc-express ,进入后输入
npm init
回答一些问题创建项目
This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sane defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install
--save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (mvc-express) version: (0.0.0) 0.0.1 description: my try of express entry point: (app.js) test command: npm test git repository: keywords: author: jpuyy license: (ISC) About to write to /private/var/forge/node/mvc-express/package.json: { "name": "mvc-express", "version": "0.0.1", "description": "my try of express", "main": "app.js", "scripts": { "test": "npm test" }, "author": "jpuyy", "license": "ISC" } Is this ok? (yes) yes 接下来我要安装一些包时,使用 npm install
–save ,会自动加入到 package.json 中 npm install express --save
清理缓存
npm cache clean检查
npm audit fix -
mysql参数配置
[root@mail ~]# cat /etc/my.cnf
[mysql]
prompt = “(\u@\h)[\d]> ”
no_auto_rehash
default_character_set = utf8 #指定客户端连接字符集,等同set names utf8. <character_set_client, character_set_connection, character_set_results>。[mysqld]
socket = /tmp/mysql.sock #mysql sock文件存放目录(该目录可以改动,但必需可以让mysql有写权限)
user = mysql #启动mysql数据库的用户
port = 3306 #mysql守护进程启动时监听的端口
skip_external_locking #避免mysql外部锁定,减少出错机率增强稳定性(mysql5.5配置)
skip_name_resolve #启动时和运行时跳过域名查询(mysql5.5不能用)
query_cache_type = 1 #0或OFF(禁止使用缓存);1或ON(充许使用缓存,SELECT SQL_NO_CACHE查询语句除外);2或DEMAND(仅对SELECT SQL_CACH查询语句启动缓存)
query_cache_limit = 8M #最大缓存结果大小
query_cache_min_res_unit = 4k
query_cache_size = 512M #查询缓存大小
read_buffer_size = 2M #select时所能使用的缓冲区大小,每连接独享。
read_rnd_buffer_size = 16M #order by | group by所使用的排序缓存大小,每连接独享。
open_files_limit = 102400 #MySQL文件描述符限制
sort_buffer_size = 4M #order by | group by,每连接独享。
join_buffer_size = 2M #外链缓冲大小,每连接独享。
key_buffer = 1G
key_buffer_size = 1G
table_cache = 2048 #为所有线程打开表的数量,同时须修改文件描述符默认大小。增加些值可有效避免频繁打开表产生的开销。
max_connections = 2048 #最大允许多少个tcp进程连接
back_log = 1000 #指定可能的连接数,当MySQL主线程在很短的时间内接收到非常多的请求时,该参数生效。达到该参数阀值会短暂停止响应新的请求(推置值 connection x 2)。
max_connect_errors = 102400 #mysql实例在大量发时,而mysql本身处理不过来,就会产生最大连接错误,当达到设定值后会死锁实例,新的连接将无法进来,而老的连接正常。mysql有相应的自动timeout机制来控制将最大连接错误回滚成0。
wait_timeout = 3600 #断开空闲时间超过此值的连接
interactive_timeout = 3600 #服务器在关闭之前在一个交互连接上等待的秒数(一个交互的客户端被定义为对mysql_real_connect()使用CLIENT_INTERACTIVE选项的客户),默认为28800
tmp_table_size = 512M #临时表大小
slow_query_log = True #记录慢查询,对SQL优化很有帮助
slow_launch_time = 1 #设置执行时间多长的查询为慢查询, 默认单位为秒(s)
server_id = 61 #服务器id 主从时必需设置
binlog_ignore_db = mysql,test
log_bin = /data0/db-binlog/hupu.com/default/mysql-bin #打开binlog日志
log_bin_index = /data0/db-binlog/hupu.com/default/mysql-bin.index #binlog 索引文件
binlog_format = MIXED #binlog格式[STATEMENT(基于语句)|ROW(基于行)|MIXED(混合模式)]
binlog_cache_size = 4M #binlog 缓存大小,调节该值大小可避免使用文件
max_binlog_cache_size = 8M #默认4GB,限制缓存多语句事务的缓冲区总大小,当某个事务大于该值,将会失败并回滚
max_binlog_size = 512M #指定binlog文件最大容量,超过些值会自动回滚binlog
expire_logs_days = 60 #binlog保存最近7天的文件
bulk_insert_buffer_size = 64M #insert … select … ,insert …(..),(..),(..) ,load data infile 有较大的加速效果, 针对每线程
myisam_sort_buffer_size = 512M #myisam引擎排序缓冲大小,即MyISAM表发生变化时重新排序所需的缓冲区大小
myisam_max_sort_file_size = 1G #myisam引擎最大允许排序文件大小
myisam_repair_threads = 1 #mysql修复线程数
myisam_recover #启动MySQL时自动修复损坏索引的表
myisam_sort_buffer_size = 512M #表恢复时使用的缓冲区大小
max_heap_table_size = 200M
max_allowed_packet = 2G #导入时指定单表最大文件
thread_concurrency = 8 #最大的并发连接线程数,取CPU的核心数x2,超线程CPU再x2
thread_cache_size = 1024 #每个thread cache 池可以最多缓存多少个线程
thread_stack = 192K #每个线程被创建时分配的内存空间大小innodb_support_xa = False #开启或关闭Innodb分布式事务. 如未使用分布式事务, 强列建议关闭. 减少磁盘刷新次数.
innodb_additional_mem_pool_size = 8M #存储数据目录信息和其它内部数据结构的内存池大小, 表越多需要的内存也越多.默认为1MB
innodb_buffer_pool_size = 2G #Innodb 表缓存池大小
innodb_file_io_threads = 4 #innodb io线程数,默认为4个. 在unix类系统中设置大于4的值是没有意义的.windows则不同.
innodb_thread_concurrency = 0 #innodb 并发线程数.设置值大于0时,innodb每次接MySQL线程调用时都将进一次并发性检测,看是否大于些值.如果show innodb status 中发现大量”waiting in InnoDB queue ” 则可将值设成0.让系统自已控制
innodb_flush_log_at_trx_commit = 2 #innodb日志写入磁盘设置,0 : 每秒一次 ,1:每个事务完成时提交, 2:每次提交但不对日志写回磁盘操作,刷到磁盘上还是每秒一次.不受事务结束引响. 当设置为0时任何导至mysqld进程的崩溃都会删除前一秒的事务日志,当设为2时,只有操作系统崩溃或掉电才会删除最后一秒的事务.(当然磁盘回写也会导至事务的丢失,而这是磁盘的默认选项). 该选项默认值为 1.
innodb_log_buffer_size = 8M #innodb log缓存大小,默认为1MB. 频繁写入时才修改此值到8MB或以上,因每秒(跟据innodb_flush_log_at_trx_commit值决定刷新缓存到磁盘的时间间隙)会被刷一次到磁盘. 不建议加很大
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 60 #Innodb引擎表死锁时等待的时间, 超出此时间事务还未执行成功, 此事务将回滚. 跟据需要设置些参数
innodb_file_per_table = 1 #为每个innodb 表单独创建文件存放. 默认所有innodb表全部存放在ibdata1
innodb_open_files = 1024 #Innodb 一次最多可以打开多少表,默认为300,最少值为10. 些选项跟innodb_file_per_table是多表还是单表存放innodb文件相关
innodb_read_io_threads = 8 #Innodb 读取磁盘io线程数,默认为4. 如果磁盘性能OK, 可以加大些值来提高性能。
innodb_write_io_threads = 4 #Innodb 写入磁盘io线程数,默认为4. 如果磁盘性能OK, 可以加大些值来提高性能。
innodb_io_capacity = 200 #Innodb 刷新脏页到磁盘,指每秒刷新200个脏页,此值为默认。写密集型DB需加大此值。
innodb_max_dirty_pages_pct = 80 #加快innodb脏页刷新频率减少恢得利 时间,也可保证磁盘的IP负载。值为百分比,默认90%
innodb_adaptive_flushing = True #自适应刷新脏页,
big_tables = True #MySQL 大表支持[mysqldump]
quick
max_allowed_packet = 2G #导出时指定单表最大文件 -
mongodb操作
mongodb端口为27017
http://127.0.0.1:27017
It looks like you are trying to access MongoDB over HTTP on the native driver port.
mongodb的结构为database, collection,
创建database,
> use blog switched to db blog
查看已经存在的db 及其占用空间
> show dbs admin (empty) blog 0.078GB example 0.078GB local 0.078GB
接下来在collection里添加json格式的内容
> db.posts.insert({'title':'learn mongo','tag':'db'}) WriteResult({ "nInserted" : 1 }) > db.posts.insert({'title':'learn mysql','tag':'db'}) WriteResult({ "nInserted" : 1 })查看名为posts的collection的所有内容
> db.posts.find() { "_id" : ObjectId("53d1b11aecbaca2dd97bc8d8"), "title" : "learn mongo", "tag" : "db" } { "_id" : ObjectId("53d1b124ecbaca2dd97bc8d9"), "title" : "learn mysql", "tag" : "db" }查看已经有的collections
> show collections posts system.indexes
清空collection
> db.posts.remove() 2014-07-25T09:30:33.139+0800 remove needs a query at src/mongo/shell/collection.js:299
删除collection
> db.posts.drop() true
删除当前数据库
> db.dropDatabase()
五,更多命令
db.AddUser(username,password) 添加用户db.auth(usrename,password) 设置数据库连接验证
db.cloneDataBase(fromhost) 从目标服务器克隆一个数据库
db.commandHelp(name) returns the help for the command
db.copyDatabase(fromdb,todb,fromhost) 复制数据库fromdb—源数据库名称,todb—目标数据库名称,fromhost—源数据库服务器地址
db.createCollection(name,{size:3333,capped:333,max:88888}) 创建一个数据集,相当于一个表
db.currentOp() 取消当前库的当前操作
db.dropDataBase() 删除当前数据库
db.eval(func,args) run code server-side
db.getCollection(cname) 取得一个数据集合,同用法:db[‘cname’] or
db.getCollenctionNames() 取得所有数据集合的名称列表
db.getLastError() 返回最后一个错误的提示消息
db.getLastErrorObj() 返回最后一个错误的对象
db.getMongo() 取得当前服务器的连接对象get the server
db.getMondo().setSlaveOk() allow this connection to read from then nonmaster membr of a replica pair
db.getName() 返回当操作数据库的名称
db.getPrevError() 返回上一个错误对象
db.getProfilingLevel()
db.getReplicationInfo() 获得重复的数据
db.getSisterDB(name) get the db at the same server as this onew
db.killOp() 停止(杀死)在当前库的当前操作
db.printCollectionStats() 返回当前库的数据集状态
db.printReplicationInfo()
db.printSlaveReplicationInfo()
db.printShardingStatus() 返回当前数据库是否为共享数据库
db.removeUser(username) 删除用户
db.repairDatabase() 修复当前数据库
db.resetError()
db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj:1}
db.setProfilingLevel(level) 0=off,1=slow,2=all
db.shutdownServer() 关闭当前服务程序db.version() 返回当前MongoDB版本信息
> db.version() 2.6.0
db.test.find({id:10}) 返回test数据集ID=10的数据集
db.test.find({id:10}).count() 返回test数据集ID=10的数据总数
db.test.find({id:10}).limit(2) 返回test数据集ID=10的数据集从第二条开始的数据集
db.test.find({id:10}).skip(8) 返回test数据集ID=10的数据集从0到第八条的数据集
db.test.find({id:10}).limit(2).skip(8) 返回test数据集ID=1=的数据集从第二条到第八条的数据
db.test.find({id:10}).sort() 返回test数据集ID=10的排序数据集
db.test.findOne([query]) 返回符合条件的一条数据
db.test.getDB() 返回此数据集所属的数据库名称
db.test.getIndexes() 返回些数据集的索引信息
db.test.group({key:…,initial:…,reduce:…[,cond:…]})
db.test.mapReduce(mayFunction,reduceFunction,)
db.test.remove(query) 在数据集中删除一条数据
db.test.renameCollection(newName) 重命名些数据集名称
db.test.save(obj) 往数据集中插入一条数据
db.test.stats() 返回此数据集的状态
db.test.storageSize() 返回此数据集的存储大小
db.test.totalIndexSize() 返回此数据集的索引文件大小
db.test.totalSize() 返回些数据集的总大小
db.test.update(query,object[,upsert_bool]) 在此数据集中更新一条数据
db.test.validate() 验证此数据集
db.test.getShardVersion() 返回数据集共享版本号六,MongoDB语法与现有关系型数据库SQL语法比较
MongoDB语法 MySql语法
db.test.find({‘name’:’foobar’}) <==> select * from test where name=’foobar’
db.test.find() <==> select * from test
db.test.find({‘ID’:10}).count() <==> select count(*) from test where ID=10
db.test.find().skip(10).limit(20) <==> select * from test limit 10,20
db.test.find({‘ID’:{$in:[25,35,45]}}) <==> select * from test where ID in (25,35,45)
db.test.find().sort({‘ID’:-1}) <==> select * from test order by ID desc
db.test.distinct(‘name’,{‘ID’:{$lt:20}}) <==> select distinct(name) from test where ID<20
db.test.group({key:{‘name’:true},cond:{‘name’:’foo’},reduce:function(obj,prev){prev.msum+=obj.marks;},initial:{msum:0}}) <==> select name,sum(marks) from test group by name
db.test.find(‘this.ID<20’,{name:1}) <==> select name from test where ID<20
db.test.insert({‘name’:’foobar’,’age’:25})<==>insert into test (‘name’,’age’) values(‘foobar’,25)
db.test.remove({}) <==> delete * from test
db.test.remove({‘age’:20}) <==> delete test where age=20
db.test.remove({‘age’:{$lt:20}}) <==> elete test where age<20
db.test.remove({‘age’:{$lte:20}}) <==> delete test where age<=20
db.test.remove({‘age’:{$gt:20}}) <==> delete test where age>20
db.test.remove({‘age’:{$gte:20}}) <==> delete test where age>=20
db.test.remove({‘age’:{$ne:20}}) <==> delete test where age!=20
db.test.update({‘name’:’foobar’},{$set:{‘age’:36}}) <==> update test set age=36 where name=’foobar’
db.test.update({‘name’:’foobar’},{$inc:{‘age’:3}}) <==> update test set age=age+3 where name=’foobar’注意以上命令大小写敏感
-
virtualbox命令行启动
VBoxManage startvm winxp -type vrdp
Waiting for VM “winxp” to power on…
VM “winxp” has been successfully started.