JMeter-dagi groovy buyruq fayli samplerida "CSV ma'lumotlar majmui konfiguratsiyasi" ning <EOF> ni qanday aniqlash mumkin?

Men bilaman, groovy skriptda qanday munosabatda bo'lish mumkinligini bilish. Vaqt tekshirgichidan foydalanib, CSV ichidagi barcha qatorlar orqali yinelemek va haqiqiy testplanmadan oldin JMeter o'zgaruvchilari yaratish. Buni turli xil CSV fayllari uchun bir necha marta qilishim kerak, shuning uchun tekshirgich vaqtida ipni to'xtatishni xohlamayman.

Men shunday bir narsani tasavvur qildim:

if (${CSV_VALUE1} != "")
{
    def variableName = sprintf('%1$sVALUE',[${CSV_VALUE2}])
    vars.put(variableName,${CSV_VALUE1});
}

CSV_VALUE1 qiymati JMeter o'zgaruvchisi uchun va CSV_VALUE2 - o'zgaruvchining nomi.

Testplan

I also appreciate better solutions, which iterate through every row of the CSV file and generate JMeter variables according to my conventions of it. A constraint is, that it has to be done in only one single thread group (=> No stopping of threads on EOF)

0
Biznes: Men o'zimning muammoim aslida noto'g'ri formatlangan CSV fayli ekanligini bilib oldim. Shunday qilib, mening yondashuvim aslida to'g'ri va imkoni bor edi, shuning uchun ham o'zimning savolimga javob berdim.
qo'shib qo'ydi muallif VolJin, manba
Biznes: Men o'zimning muammoim aslida noto'g'ri formatlangan CSV fayli ekanligini bilib oldim. Shunday qilib, mening yondashuvim aslida to'g'ri va imkoni bor edi, shuning uchun ham o'zimning savolimga javob berdim.
qo'shib qo'ydi muallif VolJin, manba
Biznes: Men o'zimning muammoim aslida noto'g'ri formatlangan CSV fayli ekanligini bilib oldim. Shunday qilib, mening yondashuvim aslida to'g'ri va imkoni bor edi, shuning uchun ham o'zimning savolimga javob berdim.
qo'shib qo'ydi muallif VolJin, manba

7 javoblar

You can handle this case using If Controller and While Controller combination like:

  • While Controller: condition ${__javaScript("${CSV_VALUE1}" != "",)}
    • If Controller: condition "${CSV_VALUE1}" != ""
      • READ - Action Models
      • JSR223 Sampler
      • ...

Tafsilotlarni ko'rish uchun JMeter-da tekshirgichni ishlatish »maqolasiga qarang.

0
qo'shib qo'ydi
Ha, men bundan oldin sinab ko'rdim, lekin hech qachon men uchun ishlamagan. Sampler yana bir marta bilan chaqirilgandir, shuning uchun logda xatolar borligini ko'rdim: jmeter.control.IfController: Agar tekshiruvchi: ishlov berishda xatolik ["e1e78ffd-f900-42fd-a8fa -f3ff9f2fc8e6 ""! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Menimcha, bu muammo "" mavjud id bilan muammo bo'lsa, boshqa tomondan, "EOF" bilan bog'liq muammo: jmeter.functions.JavaScript: Javascriptni qayta ishlash xato: [$ {ACTIONMODELID}! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Nihoyat men uni ish bilan bajardim! Mening CSV faylimdagi har bir qiymat uchun tirnoq bor! Bu muvaffaqiyatli bajarilishga yo'l qo'ymadi. CSV yaratilish usulini moslashtirish kerak.
qo'shib qo'ydi muallif VolJin, manba

You can handle this case using If Controller and While Controller combination like:

  • While Controller: condition ${__javaScript("${CSV_VALUE1}" != "",)}
    • If Controller: condition "${CSV_VALUE1}" != ""
      • READ - Action Models
      • JSR223 Sampler
      • ...

Tafsilotlarni ko'rish uchun JMeter-da tekshirgichni ishlatish »maqolasiga qarang.

0
qo'shib qo'ydi
Ha, men bundan oldin sinab ko'rdim, lekin hech qachon men uchun ishlamagan. Sampler yana bir marta bilan chaqirilgandir, shuning uchun logda xatolar borligini ko'rdim: jmeter.control.IfController: Agar tekshiruvchi: ishlov berishda xatolik ["e1e78ffd-f900-42fd-a8fa -f3ff9f2fc8e6 ""! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Menimcha, bu muammo "" mavjud id bilan muammo bo'lsa, boshqa tomondan, "EOF" bilan bog'liq muammo: jmeter.functions.JavaScript: Javascriptni qayta ishlash xato: [$ {ACTIONMODELID}! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Nihoyat men uni ish bilan bajardim! Mening CSV faylimdagi har bir qiymat uchun tirnoq bor! Bu muvaffaqiyatli bajarilishga yo'l qo'ymadi. CSV yaratilish usulini moslashtirish kerak.
qo'shib qo'ydi muallif VolJin, manba

You can handle this case using If Controller and While Controller combination like:

  • While Controller: condition ${__javaScript("${CSV_VALUE1}" != "",)}
    • If Controller: condition "${CSV_VALUE1}" != ""
      • READ - Action Models
      • JSR223 Sampler
      • ...

Tafsilotlarni ko'rish uchun JMeter-da tekshirgichni ishlatish »maqolasiga qarang.

0
qo'shib qo'ydi
Ha, men bundan oldin sinab ko'rdim, lekin hech qachon men uchun ishlamagan. Sampler yana bir marta bilan chaqirilgandir, shuning uchun logda xatolar borligini ko'rdim: jmeter.control.IfController: Agar tekshiruvchi: ishlov berishda xatolik ["e1e78ffd-f900-42fd-a8fa -f3ff9f2fc8e6 ""! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Menimcha, bu muammo "" mavjud id bilan muammo bo'lsa, boshqa tomondan, "EOF" bilan bog'liq muammo: jmeter.functions.JavaScript: Javascriptni qayta ishlash xato: [$ {ACTIONMODELID}! = ""] org.mozilla.javascript.EvaluatorException: yo'qolgan; oldin ( # 1) so'zidan foydalaning
qo'shib qo'ydi muallif VolJin, manba
Nihoyat men uni ish bilan bajardim! Mening CSV faylimdagi har bir qiymat uchun tirnoq bor! Bu muvaffaqiyatli bajarilishga yo'l qo'ymadi. CSV yaratilish usulini moslashtirish kerak.
qo'shib qo'ydi muallif VolJin, manba

Quyida "CSV fayli" ni o'qish uchun "BeanShell" dan foydalanishingiz mumkin, quyida ma'lumotlar mavjud bo'lgan namunadagi csv fayli mavjud

answer1,0
answer2,1
answer3,2
...
answerX,X-1

Ushbu faylni o'qish uchun "Beanshell" ssenariysi ostida foydalaning

import java.text.*;
import java.io.*;
import java.util.*;

String filename = "oprosnik_" + vars.get("fileNum") + ".csv";

ArrayList strList = new ArrayList();     

try {
    File file = new File(filename);

    if (!file.exists()) {
        throw new Exception ("ERROR: file " + filename + " not found");
    }

    BufferedReader bufRdr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
    String line = null;
    Integer i = 0;

    while((line = bufRdr.readLine()) != null) {
        strList.add(line);
        i++;
    }

    bufRdr.close();            
    counter = Integer.parseInt(vars.get("counter"));
    if (counter != i) {
        String[] variables = strList.get(counter).split(",");
        vars.put("answer",variables[0]);
        vars.put("answerNum",variables[1]);
        counter++;
        vars.put("counter",Integer.toString(counter));
    }
    else {
            vars.put("answer","");
            vars.put("eol","");
            vars.put("counter","0");
    }
}
catch (Exception ex) {
    IsSuccess = false; 
    log.error(ex.getMessage());
    System.err.println(ex.getMessage());
}
catch (Throwable thex) {
    System.err.println(thex.getMessage());
}

bog'lanish ni tekshirish uchun

0
qo'shib qo'ydi
Rahmat, bu ham mumkin, lekin aslida men uchun zarur emas.
qo'shib qo'ydi muallif VolJin, manba

Quyida "CSV fayli" ni o'qish uchun "BeanShell" dan foydalanishingiz mumkin, quyida ma'lumotlar mavjud bo'lgan namunadagi csv fayli mavjud

answer1,0
answer2,1
answer3,2
...
answerX,X-1

Ushbu faylni o'qish uchun "Beanshell" ssenariysi ostida foydalaning

import java.text.*;
import java.io.*;
import java.util.*;

String filename = "oprosnik_" + vars.get("fileNum") + ".csv";

ArrayList strList = new ArrayList();     

try {
    File file = new File(filename);

    if (!file.exists()) {
        throw new Exception ("ERROR: file " + filename + " not found");
    }

    BufferedReader bufRdr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
    String line = null;
    Integer i = 0;

    while((line = bufRdr.readLine()) != null) {
        strList.add(line);
        i++;
    }

    bufRdr.close();            
    counter = Integer.parseInt(vars.get("counter"));
    if (counter != i) {
        String[] variables = strList.get(counter).split(",");
        vars.put("answer",variables[0]);
        vars.put("answerNum",variables[1]);
        counter++;
        vars.put("counter",Integer.toString(counter));
    }
    else {
            vars.put("answer","");
            vars.put("eol","");
            vars.put("counter","0");
    }
}
catch (Exception ex) {
    IsSuccess = false; 
    log.error(ex.getMessage());
    System.err.println(ex.getMessage());
}
catch (Throwable thex) {
    System.err.println(thex.getMessage());
}

bog'lanish ni tekshirish uchun

0
qo'shib qo'ydi
Rahmat, bu ham mumkin, lekin aslida men uchun zarur emas.
qo'shib qo'ydi muallif VolJin, manba

Quyida "CSV fayli" ni o'qish uchun "BeanShell" dan foydalanishingiz mumkin, quyida ma'lumotlar mavjud bo'lgan namunadagi csv fayli mavjud

answer1,0
answer2,1
answer3,2
...
answerX,X-1

Ushbu faylni o'qish uchun "Beanshell" ssenariysi ostida foydalaning

import java.text.*;
import java.io.*;
import java.util.*;

String filename = "oprosnik_" + vars.get("fileNum") + ".csv";

ArrayList strList = new ArrayList();     

try {
    File file = new File(filename);

    if (!file.exists()) {
        throw new Exception ("ERROR: file " + filename + " not found");
    }

    BufferedReader bufRdr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
    String line = null;
    Integer i = 0;

    while((line = bufRdr.readLine()) != null) {
        strList.add(line);
        i++;
    }

    bufRdr.close();            
    counter = Integer.parseInt(vars.get("counter"));
    if (counter != i) {
        String[] variables = strList.get(counter).split(",");
        vars.put("answer",variables[0]);
        vars.put("answerNum",variables[1]);
        counter++;
        vars.put("counter",Integer.toString(counter));
    }
    else {
            vars.put("answer","");
            vars.put("eol","");
            vars.put("counter","0");
    }
}
catch (Exception ex) {
    IsSuccess = false; 
    log.error(ex.getMessage());
    System.err.println(ex.getMessage());
}
catch (Throwable thex) {
    System.err.println(thex.getMessage());
}

bog'lanish ni tekshirish uchun

0
qo'shib qo'ydi
Rahmat, bu ham mumkin, lekin aslida men uchun zarur emas.
qo'shib qo'ydi muallif VolJin, manba

CSV ma'lumotlar to'plami uchun faylning oxiri bajarilgan blok uchun tirnoqli oddiy if-shartlar yordamida aniqlash mumkin:

if ("${CSV_VALUE1}" != "")
{
    //Code to execute if the condition is satisfied
}
0
qo'shib qo'ydi