SDAP-107 Ningester container does not report exit code correctly
authorfgreg <fgreguska+github@gmail.com>
Thu, 14 Jun 2018 16:35:01 +0000 (09:35 -0700)
committerGitHub <noreply@github.com>
Thu, 14 Jun 2018 16:35:01 +0000 (09:35 -0700)
Now using `set -o pipefail` in entrypoint script.

docker/entrypoint.sh
src/test/java/org/apache/sdap/ningester/processors/AddDayOfYearAttributeTest.java

index ae80a4c..1f12ef4 100755 (executable)
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
+# Exit immediately if a simple command returns non-zero exit code
+# Cause the status of terminated background jobs to be reported immediately.
 set -eb
+# With pipefail, the return status of a pipeline is "the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully"
+set -o pipefail
 
 NINGESTER_JAR=`find ningester/build/libs -name ningester*.jar`
 CONFIG_FILES=`find /config -name "*.yml" | awk -vORS=, '{ print $1 }'`
index a6aef61..60c8092 100644 (file)
@@ -75,6 +75,28 @@ public class AddDayOfYearAttributeTest {
         processor.setDayOfYearFromGranuleName(nexusTile);
     }
 
+    @Test
+    public void testSuccessfulMatchSmap() {
+        String regex = "^sss_smap_L3m_clim_doy(\\d{3}).*";
+        String granuleName = "file:/some/path/sss_smap_L3m_clim_doy227_month08_nepochs1_pixelMean.nc";
+        NexusTile nexusTile = NexusTile.newBuilder().setSummary(
+                TileSummary.newBuilder()
+                        .setGranule(granuleName)
+                        .build()
+        ).build();
+
+        AddDayOfYearAttribute processor = new AddDayOfYearAttribute(regex);
+
+        NexusTile result = processor.setDayOfYearFromGranuleName(nexusTile);
+
+        assertThat(result.getSummary().getGlobalAttributesList(), contains(
+                hasProperty("name", is("day_of_year_i"))
+        ));
+
+        String actualDayOfYear = result.getSummary().getGlobalAttributes(0).getValues(0);
+        assertThat(actualDayOfYear, is("227"));
+    }
+
     @Test()
     public void testUnsuccessfulGroupMatch() {