lands测试问题排查过程记录
线su测试问题描述:
新老日志不一致; 新的日志缺少必要的ip字段;
测试环境:10.168.10.x
老模块目录: /home/w/adp1/adf/lands/log
新目录: /home/w/adp1/brand_monilands/logs
测试工具目录:/home/w/adp1/test
测试指令:
./test -u="http://127.0.0.1:8004/adfront/lands?callback=callback&u=https%3A%2F%2Ftopic.m.xxxx.com.cn%2Fnew%2Fmarketing%2F2019%2F6%2Ftianyi_400%2F%3Flmnt%3D6e793ab9-712b-4aa6-9da4-9199eec5caca%26PvAreaId%3D2552101%26mz_ca%3D2124817%26mz_sp%3D7Pjrs%26mz_sb%3D1&r=&issalesleads=callback&pageurlid=10001042&slname=%E7%99%BD%E5%A5%B3%E5%A3%AB&slmobile=13314887235&slcity=150100&slprovince=150000&slcarseries=3989&slcarspec=31247&sldealer=6013%2C2091884&slchanid=2&actionpagereqid=&actionclickid=&_=1561517945229" -pvidlist="123456:250163:404538:222222:4" ./test -u="http://127.0.0.1:8104/adfront/lands?callback=callback&u=https%3A%2F%2Ftopic.m.xxx.com.cn%2Fnew%2Fmarketing%2F2019%2F6%2Ftianyi_400%2F%3Flmnt%3D6e793ab9-712b-4aa6-9da4-9199eec5caca%26PvAreaId%3D2552101%26mz_ca%3D2124817%26mz_sp%3D7Pjrs%26mz_sb%3D1&r=&issalesleads=callback&pageurlid=10001042&slname=%E7%99%BD%E5%A5%B3%E5%A3%AB&slmobile=13314887235&slcity=150100&slprovince=150000&slcarseries=3989&slcarspec=31247&sldealer=6013%2C2091884&slchanid=2&actionpagereqid=&actionclickid=&_=1561517945229" -pvidlist="123456:250163:404538:222222:4"
排查思路 :
对比新老日志不同的字段,编写ruby脚本,找到不一样的部分;
核对代码中对应写ip的部分,发现存在逻辑错误,使用新的方式获取ip,并处理后面的两个省市字段;
日志对比代码:
fname = ARGV[0] if fname == "" puts "file name is null " exit end File.open("#{fname}").each_with_index do | line,index| #puts "#{index}-------> #{line}" arr = line.split("\t") arr.each_with_index do |ele ,idx| puts "#{idx+1}------> #{ele}" end puts "---------------------------------------------------------->" end
对应的代码逻辑修复:
if kvLog[LANDSIP] == ""{ kvLog[LANDSIP] = GetRemoteIp(req) } if prov, city, _, err := store.GetAreaByIp( kvLog[LANDSIP]); err == nil || kvLog[LANDSIP] == ""{ kvLog[PROVINCE] = strconv.Itoa(int(prov)) kvLog[CITY] = strconv.Itoa(int(city)) } else { logrus.Errorf("|pvlog | search ip library not found, ip:", kvLog[LANDSIP]) } func GetRemoteIp(r *http.Request) string { ip := r.Header.Get("X-Real-IP") if ip == "" { ip = r.Header.Get("X-Forwarded-For") ips := strings.Split(ip, ",") if len(ips) >= 2 { ip = ips[0] } } if ip == ""{ ip = r.RemoteAddr logrus.Warnf("use RemoteAddr %s ", ip ) } return ip }
浙公网安备 33010602011771号