Fix test for _cat/nodeattrs
Adds a node attribute to all test runs and uses the attribute to test `_cat/nodeattrs`. Note that its quite possible create an impressively slow regex while doing this and you have to be careful. See comment in commit for more if curious. Closes #12558
This commit is contained in:
parent
3839d15ea0
commit
56c3471851
|
@ -155,6 +155,7 @@ public abstract class ESRestTestCase extends ESIntegTestCase {
|
||||||
return Settings.builder()
|
return Settings.builder()
|
||||||
.putArray(URLRepository.ALLOWED_URLS_SETTING, "http://snapshot.test*")
|
.putArray(URLRepository.ALLOWED_URLS_SETTING, "http://snapshot.test*")
|
||||||
.put(Node.HTTP_ENABLED, true)
|
.put(Node.HTTP_ENABLED, true)
|
||||||
|
.put("node.testattr", "test")
|
||||||
.put(super.nodeSettings(nodeOrdinal)).build();
|
.put(super.nodeSettings(nodeOrdinal)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,5 @@
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.elasticsearch.bootstrap.Elasticsearch"/>
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.elasticsearch.bootstrap.Elasticsearch"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="start"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="start"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="elasticsearch"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="elasticsearch"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/heapdump.hprof -Delasticsearch -Des.foreground=yes -ea -Des.path.home=target/eclipse_run -Des.security.manager.enabled=false"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/heapdump.hprof -Delasticsearch -Des.foreground=yes -ea -Des.path.home=target/eclipse_run -Des.security.manager.enabled=false -Des.node.attr=test"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|
|
@ -172,6 +172,8 @@
|
||||||
<arg value="-Des.path.shared_data=@{home}/../"/>
|
<arg value="-Des.path.shared_data=@{home}/../"/>
|
||||||
<arg value="-Des.script.inline=on"/>
|
<arg value="-Des.script.inline=on"/>
|
||||||
<arg value="-Des.script.indexed=on"/>
|
<arg value="-Des.script.indexed=on"/>
|
||||||
|
<!-- Define a node attribute so we can test that it exists -->
|
||||||
|
<arg value="-Des.node.testattr=test"/>
|
||||||
<arg value="-Des.repositories.url.allowed_urls=http://snapshot.test*"/>
|
<arg value="-Des.repositories.url.allowed_urls=http://snapshot.test*"/>
|
||||||
<additional-args/>
|
<additional-args/>
|
||||||
</nested>
|
</nested>
|
||||||
|
|
|
@ -1,30 +1,64 @@
|
||||||
---
|
---
|
||||||
"Test cat nodes attrs output":
|
"Help":
|
||||||
|
|
||||||
- skip:
|
|
||||||
version: "all"
|
|
||||||
reason: "Waiting for #12558"
|
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
cat.nodeattrs: {}
|
cat.nodeattrs:
|
||||||
|
help: true
|
||||||
|
|
||||||
- match:
|
- match:
|
||||||
$body: |
|
$body: |
|
||||||
/((\S+)\s+(\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+(\S+)\s+(\S+)\s*)+/
|
/^ node .+ \n
|
||||||
|
id .+ \n
|
||||||
|
pid .+ \n
|
||||||
|
host .+ \n
|
||||||
|
ip .+ \n
|
||||||
|
port .+ \n
|
||||||
|
attr .+ \n
|
||||||
|
value .+ \n
|
||||||
|
$/
|
||||||
|
|
||||||
|
---
|
||||||
|
"Test cat nodes attrs output":
|
||||||
|
- do:
|
||||||
|
cat.nodeattrs: {}
|
||||||
|
- match: # All attributes look good
|
||||||
|
$body: |
|
||||||
|
/^# node\s+ host\s+ ip\s+ attr\s+ value\s* \n
|
||||||
|
(((\S+\s?){1,10})\s+(\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+(\S+)\s+ (\S+)\s* \n)+
|
||||||
|
$/
|
||||||
|
- match: # A specific planted attribute is present and looks good
|
||||||
|
$body: |
|
||||||
|
/# node\s+ host\s+ ip\s+ attr\s+ value\s* \n
|
||||||
|
((\S+\s?){1,10})\s+ (\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+testattr\s+ test \s* \n
|
||||||
|
/
|
||||||
|
# Note for future editors: its quite possible to construct a regex with an
|
||||||
|
# intense amount of backtracking if you use something like (\S\s?)+ to match
|
||||||
|
# node name.
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
cat.nodeattrs:
|
cat.nodeattrs:
|
||||||
v: true
|
v: true
|
||||||
|
- match: # All attributes look good including the heading
|
||||||
- match:
|
|
||||||
$body: |
|
$body: |
|
||||||
/((\S+)\s+(\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+(\S+)\s+(\S+)\s*)+/
|
/^ node\s+ host\s+ ip\s+ attr\s+ value\s* \n
|
||||||
|
(((\S+\s?){1,10})\s+(\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+(\S+)\s+ (\S+)\s* \n)+
|
||||||
|
$/
|
||||||
|
- match: # A specific planted attribute is present and looks good
|
||||||
|
$body: |
|
||||||
|
/# node\s+ host\s+ ip\s+ attr\s+ value\s* \n
|
||||||
|
((\S+\s?){1,10})\s+ (\S+)\s+(\d{1,3}\.){3}\d{1,3}\s+testattr\s+ test \s* \n
|
||||||
|
/
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
cat.nodeattrs:
|
cat.nodeattrs:
|
||||||
h: attr,value
|
h: attr,value
|
||||||
v: true
|
v: true
|
||||||
|
- match: # All attributes look good
|
||||||
- match:
|
|
||||||
$body: |
|
$body: |
|
||||||
/((\S+)\s+(\S+)\s*)+/
|
/^ attr\s+ value\s*\n
|
||||||
|
((\S+)\s+ (\S+)\s*)+
|
||||||
|
$/
|
||||||
|
- match: # A specific planted attribute is present and looks good
|
||||||
|
$body: |
|
||||||
|
/# attr\s+ value\s*\n
|
||||||
|
testattr\s+ test\s*\n
|
||||||
|
/
|
||||||
|
|
Loading…
Reference in New Issue