YONGFEIUALL

izheyi.com


  • Home

  • Archives

  • Categories

  • Tags

  • About

  • Search

MongoDB: Replica Sets + Sharding

Posted on 2015-11-04 | In MongoDB |

想学习一下集群的思想和思路,我在一台Windows机器下搭建了一个 Replica Sets + Sharding 测试集群环境。

概念说明

Replica Set
副本集。简单的说集群中包含了多份数据,保证主节点挂掉了,备用节点继续提供数据服务。使用Replica Set来实现读写分离,通过在连接时指定或者在主库指定slaveOk,由Secondary来分担读的压力,Primary只承担写操作。
副本集使其组内的每个成员(member)在不同的mongod实例中具有相同的数据备份,这样可以将来自应用服务器的请求访问(request visit)得以均匀的分布在Replica Set的每一个成员所在的mongod实例上,用以减缓单台mongod服务器在请求负载上的压力。在一定时限内Replica Set能完成其组内成员数据的最终一致,这种备份机制是自动且对用户透明的。
详细请参考:Replication Introduction

Read more »

秋游长城

Posted on 2015-11-03 | In 随想 |

N年前来过两次,每次都是在暑假的时候陪别人来的,回去都晒掉一层皮,说好的打死也不来了,本家弟弟过来,还是一块去了。

Read more »

Convert DataTable to Html format

Posted on 2015-11-02 | In Automation Testing |

Need to generate summary report:

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
public string GenerateSummarylHtmlReport(DataTable table)
{

int rowCount = table.Rows.Count;
int colCount = table.Columns.Count;
string summaryReport = " <html>";
summaryReport += "<h1 style='text-align:center'> Test Report</h1>";
summaryReport += "<body>";
summaryReport += "<table border = '1' cellspacing='0' cellpadding='2' width='100%'>";
summaryReport += "<tr style='background-color:#cccccc'><th>Select</th><th>Page Name</th><th>Repository</th><th>Status</th>" +
"<th>Detail</th><th>Start Time</th><th>End Time</th></tr>";
for (int i = 0; i < rowCount; i++)
{
summaryReport += "<tr>";
for (int j = 0; j < colCount; j++)
{
if (table.Rows[i][j].ToString() == "Failed")
{
summaryReport += "<td style='background-color:red'>" + table.Rows[i][j] + "</td>";
}
else if (table.Rows[i][j].ToString().IndexOf("Passed:") != -1)
{
string pageName = table.Rows[i][1].ToString();
string reportTime = table.Rows[i][5].ToString();
string startDate = reportTime.Split('-')[0].Trim();
string startTime = reportTime.Split('-')[1].Trim();
string formatStartDate = startDate.Split('/')[2] + startDate.Split('/')[0] + startDate.Split('/')[1];
string formatStartTime = startTime.Split(':')[0] + startTime.Split(':')[1] + startTime.Split(':')[2];
summaryReport += "<td><a href='" + formatStartDate + "/" + pageName + formatStartTime + ".html'>" + table.Rows[i][j] + "</td>";
}
else
{
summaryReport += "<td>" + table.Rows[i][j] + "</td>";
}
}
summaryReport += "</tr>";
}
summaryReport += "</table>";
summaryReport += "</body>";
summaryReport += "</html>";
return summaryReport;
}

Convert csv to Html format

Posted on 2015-11-02 | In Automation Testing |

When design selenium object management tool, need to generate html report from csv file, implement as below:

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
private static string ConvertCsvToHtml(string csvText)
{
//split the CSV, assume no commas or line breaks in text
List<List<string>> splitString = new List<List<string>>();
List<string> lineSplit = csvText.Split('\n').ToList();
foreach (string line in lineSplit)
{
splitString.Add(line.Split(',').ToList());
}

//encode text safely, and create table
string htmlReport = "<html>";
htmlReport += "<h1 style='text-align:center'> Test Report</h1>";
htmlReport += "<body>";
htmlReport += "<table border = '1' cellspacing='0' cellpadding='2' width='100%'>";
foreach(List<string> splitLine in splitString)
{
htmlReport += "<tr>";
foreach(string splitText in splitLine)
{
htmlReport += "<td>" + WebUtility.HtmlEncode(splitText) + "</td>";
}
htmlReport += "</tr>";
}
htmlReport += "</table>";
htmlReport += "</body>";
htmlReport += "</html>";
return htmlReport;
}

c#操作Excel: get_range异常

Posted on 2015-10-29 | In Excel |

The script is as below:

1
range = worksheet.get_Range(excelAPP.Cells[1, 1], excelAPP.Cells[1, colIndex]);

When i design this on VS 2010, it’s work fine, but i run on VS 2015, have an error:
Additional information: ‘object’ does not contain a definition for ‘get_Range’

Solution:

1
range = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[1, colIndex]];

Selenium Webdriver Object Repository(2)

Posted on 2015-10-22 | In Selenium Webdriver |

In the previous blog, we introduced this article [Selenium Object Repository], or the detail info, please see Selenium Webdriver Object Repository and Object Recognition

We implement this tool with winform + c#, the below information just fyi, maybe not detail enough, include:

Read more »

IEDriverServer Log配置和解析

Posted on 2015-10-20 | In Selenium Webdriver |

获得Log

对于Internet Explorer Driver,有一些很重要的System Properties,例如:

1
2
3
* webdriver.ie.driver - the location of the IE driver.
* webdriver.ie.driver.loglevel - the level at which loging messages are output.
* webdriver.ie.driver.logfile - full path and file name of the log file.

Read more »

QTP 11 supports running tests on on Minimized RDP(Remote Desktop) Session Windows

Posted on 2015-10-20 | In QTP |

Just in case your’re looking for that feature - now it’s available :

If you want to run QuickTest in a minimized RDP (remote desktop protocol) session, and you are using an RDP 6.0 or later client, you can enable it by setting a registry value on the local computer:

  1. Close all remote computer
  2. If it does not exist, create the RemoteDesktop_SuppressWhenMinimized registry value (DWORD type) in one of the following registry paths on the remote computer:
    HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
    or
    HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
  3. Set data value To 2

再谈QTP数据驱动

Posted on 2015-10-19 | In QTP |

QTP本身有就有很好的DataTable功能,所以我们可以利用以下方式来实现数据驱动:

利用脚本从excel导入Data Table

1
2
3
4
5
6
7
8
xls_Sheet_Index = 1
DataTable_Sheet_Index = 1
Set qtapp=CreateObject("quicktest.application")
qtapp.Launch
qtapp.Visible=True
qtapp.Open "d:\iquicktest"
qtapp.Test.DataTable.ImportSheet "d:\1.xls",1,1
Set qtapp=Nothing

这里有一个问题就是QTP11及之前的版本不能支持Excel2007及发后的版本,如果我们用QTP11来做自动化,本身现在大家都是用的Excel2010,或者之后的版本,就会很麻烦。

Read more »

vbs把数组导到Excel中

Posted on 2015-10-13 | In VBS |

最近做框架的时候,遇到一个问题,要把Array中的数据导出到Excel中去。

Implementation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
dim arr(10,5)  
for i=0 to 10
for j = 0 to 5
arr(i,j)=i*j
next
next

set excel = CreateObject("Excel.Application")
excel.Visible = true
set oWB = excel.Workbooks.Add
set oSheet = oWB.ActiveSheet
set xlsheet = oWB.Worksheets(1)
for i=oWB.Worksheets.count to 2 step -1
oWB.Worksheets(i).Delete()
next
oSheet.Range("a1").resize(10,5)=arr
set excel=nothing

Result

Execute Result

1…303132…40
唐胡璐

唐胡璐

i just wanna live while i am alive

393 posts
42 categories
74 tags
RSS
LinkedIn Weibo GitHub E-Mail
Creative Commons
© 2022 唐胡璐
Powered by Hexo
|
Theme — NexT.Pisces v5.1.4