(b *testing.B, minerCount uint16)
| 799 | } |
| 800 | |
| 801 | func benchMiner(b *testing.B, minerCount uint16) { |
| 802 | log.Warnf("benchmark for %d Miners, BypassSignature: %v", minerCount, benchBypassSignature) |
| 803 | asymmetric.BypassSignature = benchBypassSignature |
| 804 | if minerCount > 0 { |
| 805 | startNodesProfile(benchBypassSignature) |
| 806 | utils.WaitToConnect(context.Background(), "127.0.0.1", []int{ |
| 807 | 2144, |
| 808 | 2145, |
| 809 | 2146, |
| 810 | 3122, |
| 811 | 3121, |
| 812 | 3120, |
| 813 | }, 2*time.Second) |
| 814 | time.Sleep(time.Second) |
| 815 | } |
| 816 | |
| 817 | // Create temp directory |
| 818 | testDataDir, err := ioutil.TempDir(testWorkingDir, "covenantsql") |
| 819 | if err != nil { |
| 820 | panic(err) |
| 821 | } |
| 822 | defer os.RemoveAll(testDataDir) |
| 823 | clientConf := FJ(testWorkingDir, "./integration/node_c/config.yaml") |
| 824 | tempConf := FJ(testDataDir, "config.yaml") |
| 825 | clientKey := FJ(testWorkingDir, "./integration/node_c/private.key") |
| 826 | tempKey := FJ(testDataDir, "private.key") |
| 827 | utils.CopyFile(clientConf, tempConf) |
| 828 | utils.CopyFile(clientKey, tempKey) |
| 829 | |
| 830 | err = client.Init(tempConf, []byte("")) |
| 831 | So(err, ShouldBeNil) |
| 832 | |
| 833 | dsnFile := FJ(baseDir, "./cmd/cql-minerd/.dsn") |
| 834 | var dsn string |
| 835 | if minerCount > 0 { |
| 836 | // create |
| 837 | meta := client.ResourceMeta{ |
| 838 | Node: minerCount, |
| 839 | UseEventualConsistency: benchEventualConsistency, |
| 840 | IsolationLevel: int(sql.LevelReadUncommitted), |
| 841 | } |
| 842 | // wait for chain service |
| 843 | var ctx1, cancel1 = context.WithTimeout(context.Background(), 1*time.Minute) |
| 844 | defer cancel1() |
| 845 | err = test.WaitBPChainService(ctx1, 3*time.Second) |
| 846 | if err != nil { |
| 847 | b.Fatalf("wait for chain service failed: %v", err) |
| 848 | } |
| 849 | |
| 850 | _, dsn, err = client.Create(meta) |
| 851 | So(err, ShouldBeNil) |
| 852 | log.Infof("the created database dsn is %v", dsn) |
| 853 | err = ioutil.WriteFile(dsnFile, []byte(dsn), 0666) |
| 854 | if err != nil { |
| 855 | log.Errorf("write .dsn failed: %v", err) |
| 856 | } |
| 857 | defer os.Remove(dsnFile) |
| 858 | } else { |
no test coverage detected