Currently, the amplify console supports E2E tests with Cypress and can show the report and artifacts in a friendly format within the test section of each build. Unfortunately, there is no way in their doc to show unit test results. so, what is the correct way to write amplify.yml to use Unit Test for the backend phase?
I'm using python and
My tree path of mine if needed is:
C:.
├───api
│ └───apiExample
│ └───build
├───auth
│ └───authExample
│ └───build
├───awscloudformation
│ └───build
│ ├───api
│ │ └───apiExample
│ │ └───build
│ │
│ │
│ │
│ │
│ ├───auth
│ │ └───**
│ │ └───build
│ │
│ │
│ │
│ │
│ ├───awscloudformation
│ │ └───build
│ └───function
│ └───exampleHandler
│
├───function
│ └───exampleHandler
│ ├───src
│ │ ├───src.egg-info
│ │ └───__pycache__
│ └───test
│ ├───.pytest_cache
│ │ └───v
│ │ └───cache
│ └───__pycache__
├───hosting
│ └───amplifyhosting
└───types
and my current config is:
version: 1
backend:
phases:
preBuild:
commands:
- export BASE_PATH=$(pwd)
- yum install -y gcc openssl-devel bzip2-devel libffi-devel python3.8-pip
- cd /opt && wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
- cd /opt && tar xzf Python-3.8.2.tgz
- cd /opt/Python-3.8.2 && ./configure --enable-optimizations
- cd /opt/Python-3.8.2 && make altinstall
- pip3.8 install --user pipenv
- ln -fs /usr/local/bin/python3.8 /usr/bin/python3
- ln -fs /usr/local/bin/pip3.8 /usr/bin/pip3
- cd $BASE_PATH
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Related
I'm trying to get my head around CMake and have been testing it out in Visual Studio Code on Windows 10 with a simple project that has a couple of header files and compiles with no issues when done manually. I've run cmake .. successfully from the build folder, but upon running cmake --build . I get the above error in reference to my weight_converter.vcxproj file.
I've done a load of searching online but can't find anything that answers what is going on.
From other results I've seen some suggestions in Visual Studio to add <file>.lib to Project Options -> Linker -> Input -> Additional Dependencies on visual studio, but I'm on visual studio code and can't find a corresponding setting. I've found the .vcxproj file in my project, and although I don't really know what's going on in it, src.lib is written next to the <Link>/<AdditionalDependencies> headings.
This is my main CMakeLists.txt file contents for reference:
# set minimum CMake version, project name, and C++ standard
cmake_minimum_required(VERSION 3.19.4)
project("weight_converter")
add_subdirectory(src)
add_executable(weight_converter weight_converter.cpp )
target_include_directories("${PROJECT_NAME}" PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/src")
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin )
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
target_link_libraries("${PROJECT_NAME}" PUBLIC src)
And this is the CMakeLists.txt file in my src folder:
add_library(imperial_to_metric imperial_to_metric.cpp)
add_library(metric_to_imperial metric_to_imperial.cpp)
This is my project structure if it matters:
├───.vscode
├───bin
│ └───Debug
├───build
│ ├───.cmake
│ │ └───api
│ │ └───v1
│ │ ├───query
│ │ │ └───client-vscode
│ │ └───reply
│ ├───CMakeFiles
│ │ ├───3.19.4
│ │ │ ├───CompilerIdC
│ │ │ │ ├───Debug
│ │ │ │ │ └───CompilerIdC.tlog
│ │ │ │ └───tmp
│ │ │ ├───CompilerIdCXX
│ │ │ │ ├───Debug
│ │ │ │ │ └───CompilerIdCXX.tlog
│ │ │ │ └───tmp
│ │ │ └───x64
│ │ │ └───Debug
│ │ │ └───VCTargetsPath.tlog
│ │ ├───CMakeTmp
│ │ └───fa0880fffde885133f10c0b2cfeb0cbc
│ ├───Debug
│ ├───src
│ │ ├───CMakeFiles
│ │ ├───Debug
│ │ ├───imperial_to_metric.dir
│ │ │ └───Debug
│ │ │ └───imperial.31E5CD06.tlog
│ │ └───metric_to_imperial.dir
│ │ └───Debug
│ │ └───metric_t.0BAA5631.tlog
│ ├───weight_converter.dir
│ │ └───Debug
│ │ └───weight_converter.tlog
│ └───x64
│ └───Debug
│ └───ZERO_CHECK
│ └───ZERO_CHECK.tlog
├───lib
├───src
│ └───CMakeLists.txt
│ └───imperial_to_metric.cpp
│ └───metric_to_imperial.cpp
│ └───imperial_to_metric.h
│ └───metric_to_imperial.h
│
├───CMakeLists.txt
└───weight_converter.cpp
The underlying problem is this:
target_link_libraries("${PROJECT_NAME}" PUBLIC src)
This tells CMake to link to a library named src. However in the src/CMakeLists.txt the libraries are called. imperial_to_metric and metric_to_imperial
add_library(imperial_to_metric imperial_to_metric.cpp)
add_library(metric_to_imperial metric_to_imperial.cpp)
So what one probably wants is
target_link_libraries("${PROJECT_NAME}" PUBLIC imperial_to_metric metric_to_imperial)
A minor nit, but it is often better practice to have the library targets specify the build requirements. So instead of:
target_include_directories("${PROJECT_NAME}" PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/src")
one would have the following in src/CMakeLists.txt
target_include_directories(metric_to_imperial PUBLIC ".")
target_include_directories(imperial_to_metric PUBLIC ".")
This way any consumer of imperial_to_metric gets the needed include directories simply by the target_link_libraries command.
I have a file in the same directory as the test.
Since I'm using Bazel as the build system (in Linux) I don't have to create the main and initialize the tests (In fact I don't know where the main function resides when using Bazel).
#include <string>
#include <fstream>
//Other include files
#include "gtest/gtest.h"
TEST(read_file_test, read_file) {
std::string input_file("file_path");
graph gr;
graph_loader loader;
ASSERT_TRUE(loader.load(gr, input_file));
}
The BUILD file for the tests:
cc_test(
name = "loaderLib_test",
srcs = ["loaderLib_test.cpp"],
deps = [
"//src/lib/loader:loaderLib",
"#com_google_googletest//:gtest_main",
],
data = glob(["resources/tests/input_graphs/graph_topology/**"]),
)
The WORKSPACE file:
load("#bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "com_google_googletest",
remote = "https://github.com/google/googletest",
tag = "release-1.8.1",
)
The directory structure:
.
├── README.md
├── WORKSPACE
├── bazel-bin -> /home/mmaghous/.cache/bazel/_bazel_mmaghous/35542ec7cbabc2e6f7475e3870a798d1/execroot/__main__/bazel-out/k8-fastbuild/bin
├── bazel-graph_processor -> /home/mmaghous/.cache/bazel/_bazel_mmaghous/35542ec7cbabc2e6f7475e3870a798d1/execroot/__main__
├── bazel-out -> /home/mmaghous/.cache/bazel/_bazel_mmaghous/35542ec7cbabc2e6f7475e3870a798d1/execroot/__main__/bazel-out
├── bazel-testlogs -> /home/mmaghous/.cache/bazel/_bazel_mmaghous/35542ec7cbabc2e6f7475e3870a798d1/execroot/__main__/bazel-out/k8-fastbuild/testlogs
├── resources
│ └── tests
│ └── input_graphs
│ ├── graph_data
│ │ └── G1_data.txt
│ └── graph_topology
│ ├── G1_notFully_notWeakly.txt
│ ├── G2_notFully_Weakly.txt
│ ├── G3_fully_weakly.txt
│ ├── G4_fully_weakly.txt
│ ├── G5_notFully_weakly.txt
│ ├── G6_notFully_weakly.txt
│ └── G7_notFully_notWeakly.txt
├── src
│ ├── lib
│ │ ├── algorithms
│ │ │ ├── BUILD
│ │ │ └── graph_algorithms.hpp
│ │ ├── graph
│ │ │ ├── BUILD
│ │ │ └── graph.hpp
│ │ └── loader
│ │ ├── BUILD
│ │ └── graph_loader.hpp
│ └── main
│ ├── BUILD
│ └── main.cpp
├── tests
│ ├── BUILD
│ ├── algorithmsLib_test.cpp
│ ├── graphLib_test.cpp
│ └── loaderLib_test.cpp
└── todo.md
So how should I reference the file if it's in the same folder as the test or any other folder?
BTW: Using the full path from the root of my file systems works fine.
The problem is that the glob is relative to the BUILD file like when you refer a file in srcs. The glob is expanding to an empty list because no file is matching. The easiest way to see it is putting the full path explicitly instead of the glob and Bazel will complain.
You have two options, or you move the resources folder inside the tests folder or you create a BUILD file in the resources folders where you create a filegroup exposing the txt files and then in the test target you reference the filegroup target.
https://docs.bazel.build/versions/master/be/general.html#filegroup
In resources/BUILD
filegroup(
name = "resources",
srcs = glob(["tests/input_graphs/graph_topology/**"]),
visibility = ["//visibility:public"],
)
In tests/BUILD
cc_test(
name = "loaderLib_test",
srcs = ["loaderLib_test.cpp"],
deps = [
"//src/lib/loader:loaderLib",
"#com_google_googletest//:gtest_main",
],
data = ["//resources"],
)
For quite some time I have been investigating with limited success reproducible build issue I have with a software I am packaging for Debian.
Reproducibility is affected when build path changes, and result is the below differences (reported using diffoscope).
The code itself is C++, build infrastructure is based upon CMake. It consists of a static library and an executable.
Thanks in advance for any hint that could help address this.
CMakeList file for the static library:
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
find_package(BZip2 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0>=1.0.16)
pkg_check_modules(LIBZIP REQUIRED libzip)
find_package(Threads)
if (STATIC)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(UUUSSL "-DUUUSSL")
set(UUUOPENSLL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
endif()
include_directories(${LIBUSB_INCLUDE_DIRS} ${UUUOPENSLL_INCLUDE_DIR} include)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Wall -Wstrict-aliasing -Wextra ${UUUSSL}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${UUUSSL}")
set(SOURCES
error.cpp
buffer.cpp
cmd.cpp
config.cpp
notify.cpp
sdps.cpp
trans.cpp
usbhotplug.cpp
version.cpp
sdp.cpp
gitversion.h
fastboot.cpp
zip.cpp
fat.cpp
tar.cpp
rominfo.cpp
http.cpp
hidreport.cpp
sparse.cpp
)
set(generated_files_dir "${CMAKE_BINARY_DIR}/libuuu/gen")
set(gitversion_h "${generated_files_dir}/gitversion.h")
add_custom_command(
OUTPUT gitversion.h
PRE_BUILD
COMMAND mkdir -p ${generated_files_dir}
COMMAND sh -c 'cd ${CMAKE_CURRENT_SOURCE_DIR} && rm -f ${gitversion_h} && ./gen_ver.sh "${gitversion_h}.tmp" && mv -f "${gitversion_h}.tmp" "${gitversion_h}"'
)
include_directories(${generated_files_dir})
add_library( uuc_s STATIC ${SOURCES} )
CMakeList file for the executable:
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0>=1.0.16)
pkg_check_modules(LIBZIP REQUIRED libzip)
pkg_check_modules(LIBZ REQUIRED zlib)
find_package(Threads)
if (STATIC)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
find_package(OpenSSL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O2 -Wl,--build-id=none")
if (STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
endif()
set(LSTS
uuu.lst
emmc_burn_loader.lst
emmc_burn_all.lst
fat_write.lst
qspi_burn_loader.lst
sd_burn_loader.lst
spl_boot.lst
sd_burn_all.lst
nand_burn_loader.lst
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libuuu ${LIBUSB_LIBRARY_DIRS} ${LIBZIP_LIBRARY_DIRS} ${LIBZ_LIBRARY_DIRS})
set(CLIST_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/gen_txt_include.sh)
set(generated_files_dir "${CMAKE_BINARY_DIR}/uuu/gen")
function(preprocess_clst out_var)
set(result)
foreach(in_f ${ARGN})
set(out_f "${generated_files_dir}/${in_f}")
string(REPLACE ".lst" ".clst" out_f ${out_f})
add_custom_command(OUTPUT ${out_f}
PRE_BUILD
COMMAND mkdir -p ${generated_files_dir}
COMMAND ${CLIST_EXECUTABLE} ${in_f} ${out_f}
DEPENDS ${in_f}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Creating preprocessed clst file ${out_f}"
VERBATIM
)
list(APPEND result ${out_f})
endforeach()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
preprocess_clst(CLSTS ${LSTS})
include_directories(${generated_files_dir})
set(SOURCES
uuu.cpp
buildincmd.cpp
autocomplete.cpp
${CLSTS}
)
add_executable(uuu ${SOURCES})
target_link_libraries(uuu uuc_s ${OPENSSL_LIBRARIES} ${LIBUSB_LIBRARIES} ${LIBZIP_LIBRARIES} ${LIBZ_LIBRARIES} dl bz2 pthread)
install(TARGETS uuu DESTINATION bin)
Note also that debian/rules set a flag that will trigger the use of -ffile-prefix-map=OLD=NEW
Differences (diffoscope output):
│ │ │ │ ├── ./usr/bin/uuu
│ │ │ │ │ ├── readelf --wide --program-header {}
│ │ │ │ │ │ ## -4,15 +4,15 ##
│ │ │ │ │ │ There are 11 program headers, starting at offset 64
│ │ │ │ │ │
│ │ │ │ │ │ Program Headers:
│ │ │ │ │ │ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
│ │ │ │ │ │ PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x000268 0x000268 R 0x8
│ │ │ │ │ │ INTERP 0x0002a8 0x00000000000002a8 0x00000000000002a8 0x00001c 0x00001c R 0x1
│ │ │ │ │ │ [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
│ │ │ │ │ │ - LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0097e8 0x0097e8 R 0x1000
│ │ │ │ │ │ + LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0097f0 0x0097f0 R 0x1000
│ │ │ │ │ │ LOAD 0x00a000 0x000000000000a000 0x000000000000a000 0x04500d 0x04500d R E 0x1000
│ │ │ │ │ │ LOAD 0x050000 0x0000000000050000 0x0000000000050000 0x01253a 0x01253a R 0x1000
│ │ │ │ │ │ LOAD 0x0627c0 0x00000000000637c0 0x00000000000637c0 0x00383c 0x004020 RW 0x1000
│ │ │ │ │ │ DYNAMIC 0x064780 0x0000000000065780 0x0000000000065780 0x000270 0x000270 RW 0x8
│ │ │ │ │ │ NOTE 0x0002c4 0x00000000000002c4 0x00000000000002c4 0x000020 0x000020 R 0x4
│ │ │ │ │ │ GNU_EH_FRAME 0x054b70 0x0000000000054b70 0x0000000000054b70 0x001944 0x001944 R 0x4
│ │ │ │ │ │ GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
│ │ │ │ │ ├── readelf --wide --sections {}
│ │ │ │ │ │ ## -3,19 +3,19 ##
│ │ │ │ │ │ Section Headers:
│ │ │ │ │ │ [Nr] Name Type Address Off Size ES Flg Lk Inf Al
│ │ │ │ │ │ [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
│ │ │ │ │ │ [ 1] .interp PROGBITS 00000000000002a8 0002a8 00001c 00 A 0 0 1
│ │ │ │ │ │ [ 2] .note.ABI-tag NOTE 00000000000002c4 0002c4 000020 00 A 0 0 4
│ │ │ │ │ │ [ 3] .gnu.hash GNU_HASH 00000000000002e8 0002e8 000068 00 A 4 0 8
│ │ │ │ │ │ [ 4] .dynsym DYNSYM 0000000000000350 000350 0013c8 18 A 5 1 8
│ │ │ │ │ │ - [ 5] .dynstr STRTAB 0000000000001718 001718 001891 00 A 0 0 1
│ │ │ │ │ │ - [ 6] .gnu.version VERSYM 0000000000002faa 002faa 0001a6 02 A 4 0 2
│ │ │ │ │ │ - [ 7] .gnu.version_r VERNEED 0000000000003150 003150 0001a0 00 A 5 6 8
│ │ │ │ │ │ - [ 8] .rela.dyn RELA 00000000000032f0 0032f0 005460 18 A 4 0 8
│ │ │ │ │ │ - [ 9] .rela.plt RELA 0000000000008750 008750 001098 18 AI 4 23 8
│ │ │ │ │ │ + [ 5] .dynstr STRTAB 0000000000001718 001718 001895 00 A 0 0 1
│ │ │ │ │ │ + [ 6] .gnu.version VERSYM 0000000000002fae 002fae 0001a6 02 A 4 0 2
│ │ │ │ │ │ + [ 7] .gnu.version_r VERNEED 0000000000003158 003158 0001a0 00 A 5 6 8
│ │ │ │ │ │ + [ 8] .rela.dyn RELA 00000000000032f8 0032f8 005460 18 A 4 0 8
│ │ │ │ │ │ + [ 9] .rela.plt RELA 0000000000008758 008758 001098 18 AI 4 23 8
│ │ │ │ │ │ [10] .init PROGBITS 000000000000a000 00a000 000017 00 AX 0 0 4
│ │ │ │ │ │ [11] .plt PROGBITS 000000000000a020 00a020 000b20 10 AX 0 0 16
│ │ │ │ │ │ [12] .plt.got PROGBITS 000000000000ab40 00ab40 000010 08 AX 0 0 8
│ │ │ │ │ │ [13] .text PROGBITS 000000000000ab50 00ab50 0444b1 00 AX 0 0 16
│ │ │ │ │ │ [14] .fini PROGBITS 000000000004f004 04f004 000009 00 AX 0 0 4
│ │ │ │ │ │ [15] .rodata PROGBITS 0000000000050000 050000 004b70 00 A 0 0 32
│ │ │ │ │ │ [16] .eh_frame_hdr PROGBITS 0000000000054b70 054b70 001944 00 A 0 0 4
│ │ │ │ │ ├── readelf --wide --relocs {}
│ │ │ │ │ │ ## -1,9 +1,9 ##
│ │ │ │ │ │
│ │ │ │ │ │ -Relocation section '.rela.dyn' at offset 0x32f0 contains 900 entries:
│ │ │ │ │ │ +Relocation section '.rela.dyn' at offset 0x32f8 contains 900 entries:
│ │ │ │ │ │ Offset Info Type Symbol's Value Symbol's Name + Addend
│ │ │ │ │ │ 00000000000637c0 0000000000000008 R_X86_64_RELATIVE f030
│ │ │ │ │ │ 00000000000637c8 0000000000000008 R_X86_64_RELATIVE e8d0
│ │ │ │ │ │ 00000000000637d0 0000000000000008 R_X86_64_RELATIVE e990
│ │ │ │ │ │ 00000000000637d8 0000000000000008 R_X86_64_RELATIVE e9d0
│ │ │ │ │ │ 00000000000637e0 0000000000000008 R_X86_64_RELATIVE ea00
│ │ │ │ │ │ 00000000000637e8 0000000000000008 R_X86_64_RELATIVE ea40
│ │ │ │ │ │ ## -898,15 +898,15 ##
│ │ │ │ │ │ 0000000000064620 000000d100000005 R_X86_64_COPY 0000000000064620 _ZTISt12bad_weak_ptr#GLIBCXX_3.4.15 + 0
│ │ │ │ │ │ 0000000000064638 000000d200000005 R_X86_64_COPY 0000000000064638 _ZTVSt12bad_weak_ptr#GLIBCXX_3.4.15 + 0
│ │ │ │ │ │ 0000000000067000 000000d000000005 R_X86_64_COPY 0000000000067000 _ZSt4cout#GLIBCXX_3.4 + 0
│ │ │ │ │ │ 0000000000067120 000000cc00000005 R_X86_64_COPY 0000000000067120 stderr#GLIBC_2.2.5 + 0
│ │ │ │ │ │ 0000000000067140 000000c800000005 R_X86_64_COPY 0000000000067140 _ZSt3cin#GLIBCXX_3.4 + 0
│ │ │ │ │ │ 0000000000067260 000000c900000005 R_X86_64_COPY 0000000000067260 _ZSt4cerr#GLIBCXX_3.4 + 0
│ │ │ │ │ │
│ │ │ │ │ │ -Relocation section '.rela.plt' at offset 0x8750 contains 177 entries:
│ │ │ │ │ │ +Relocation section '.rela.plt' at offset 0x8758 contains 177 entries:
│ │ │ │ │ │ Offset Info Type Symbol's Value Symbol's Name + Addend
│ │ │ │ │ │ 0000000000065a08 0000000100000007 R_X86_64_JUMP_SLOT 0000000000000000 libusb_free_config_descriptor + 0
│ │ │ │ │ │ 0000000000065a10 0000000200000007 R_X86_64_JUMP_SLOT 0000000000000000 __printf_chk#GLIBC_2.3.4 + 0
│ │ │ │ │ │ 0000000000065a18 0000000300000007 R_X86_64_JUMP_SLOT 0000000000000000 _ZNSo3putEc#GLIBCXX_3.4 + 0
│ │ │ │ │ │ 0000000000065a20 0000000400000007 R_X86_64_JUMP_SLOT 0000000000000000 __errno_location#GLIBC_2.2.5 + 0
│ │ │ │ │ │ 0000000000065a28 0000000500000007 R_X86_64_JUMP_SLOT 0000000000000000 BZ2_bzDecompress + 0
│ │ │ │ │ │ 0000000000065a30 0000000700000007 R_X86_64_JUMP_SLOT 0000000000000000 _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_#GLIBCXX_3.4 + 0
│ │ │ │ │ ├── readelf --wide --dynamic {}
│ │ │ │ │ │ ## -14,24 +14,24 ##
│ │ │ │ │ │ 0x0000000000000019 (INIT_ARRAY) 0x637c0
│ │ │ │ │ │ 0x000000000000001b (INIT_ARRAYSZ) 120 (bytes)
│ │ │ │ │ │ 0x000000000000001a (FINI_ARRAY) 0x63838
│ │ │ │ │ │ 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
│ │ │ │ │ │ 0x000000006ffffef5 (GNU_HASH) 0x2e8
│ │ │ │ │ │ 0x0000000000000005 (STRTAB) 0x1718
│ │ │ │ │ │ 0x0000000000000006 (SYMTAB) 0x350
│ │ │ │ │ │ - 0x000000000000000a (STRSZ) 6289 (bytes)
│ │ │ │ │ │ + 0x000000000000000a (STRSZ) 6293 (bytes)
│ │ │ │ │ │ 0x000000000000000b (SYMENT) 24 (bytes)
│ │ │ │ │ │ 0x0000000000000015 (DEBUG) 0x0
│ │ │ │ │ │ 0x0000000000000003 (PLTGOT) 0x659f0
│ │ │ │ │ │ 0x0000000000000002 (PLTRELSZ) 4248 (bytes)
│ │ │ │ │ │ 0x0000000000000014 (PLTREL) RELA
│ │ │ │ │ │ - 0x0000000000000017 (JMPREL) 0x8750
│ │ │ │ │ │ - 0x0000000000000007 (RELA) 0x32f0
│ │ │ │ │ │ + 0x0000000000000017 (JMPREL) 0x8758
│ │ │ │ │ │ + 0x0000000000000007 (RELA) 0x32f8
│ │ │ │ │ │ 0x0000000000000008 (RELASZ) 21600 (bytes)
│ │ │ │ │ │ 0x0000000000000009 (RELAENT) 24 (bytes)
│ │ │ │ │ │ 0x000000000000001e (FLAGS) BIND_NOW
│ │ │ │ │ │ 0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
│ │ │ │ │ │ - 0x000000006ffffffe (VERNEED) 0x3150
│ │ │ │ │ │ + 0x000000006ffffffe (VERNEED) 0x3158
│ │ │ │ │ │ 0x000000006fffffff (VERNEEDNUM) 6
│ │ │ │ │ │ - 0x000000006ffffff0 (VERSYM) 0x2faa
│ │ │ │ │ │ + 0x000000006ffffff0 (VERSYM) 0x2fae
│ │ │ │ │ │ 0x000000006ffffff9 (RELACOUNT) 766
│ │ │ │ │ │ 0x0000000000000000 (NULL) 0x0
│ │ │ │ │ ├── readelf --wide --version-info {}
│ │ │ │ │ │ ## -1,10 +1,10 ##
│ │ │ │ │ │
│ │ │ │ │ │ Version symbols section '.gnu.version' contains 211 entries:
│ │ │ │ │ │ - Addr: 0x0000000000002faa Offset: 0x002faa Link: 4 (.dynsym)
│ │ │ │ │ │ + Addr: 0x0000000000002fae Offset: 0x002fae Link: 4 (.dynsym)
│ │ │ │ │ │ 000: 0 (*local*) 0 (*local*) 2 (GLIBC_2.3.4) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 004: 4 (GLIBC_2.2.5) 0 (*local*) 5 (GLIBCXX_3.4.22) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 008: 7 (OPENSSL_1_1_0) 8 (CXXABI_1.3.5) 0 (*local*) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 00c: 6 (GLIBC_2.2.5) 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4) 9 (GLIBCXX_3.4.21)
│ │ │ │ │ │ 010: 3 (GLIBCXX_3.4) 6 (GLIBC_2.2.5) 9 (GLIBCXX_3.4.21) 6 (GLIBC_2.2.5)
│ │ │ │ │ │ 014: 9 (GLIBCXX_3.4.21) 6 (GLIBC_2.2.5) 4 (GLIBC_2.2.5) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 018: 0 (*local*) 3 (GLIBCXX_3.4) 0 (*local*) 7 (OPENSSL_1_1_0)
│ │ │ │ │ │ ## -52,15 +52,15 ##
│ │ │ │ │ │ 0c0: 9 (GLIBCXX_3.4.21) 7 (OPENSSL_1_1_0) 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 0c4: 6 (GLIBC_2.2.5) 6 (GLIBC_2.2.5) 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4)
│ │ │ │ │ │ 0c8: 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4) 1 (*global*)
│ │ │ │ │ │ 0cc: 6 (GLIBC_2.2.5) 3 (GLIBCXX_3.4) 3 (GLIBCXX_3.4) 1 (*global*)
│ │ │ │ │ │ 0d0: 3 (GLIBCXX_3.4) 14 (GLIBCXX_3.4.15) 14 (GLIBCXX_3.4.15)
│ │ │ │ │ │
│ │ │ │ │ │ Version needs section '.gnu.version_r' contains 6 entries:
│ │ │ │ │ │ - Addr: 0x0000000000003150 Offset: 0x003150 Link: 5 (.dynstr)
│ │ │ │ │ │ + Addr: 0x0000000000003158 Offset: 0x003158 Link: 5 (.dynstr)
│ │ │ │ │ │ 000000: Version: 1 File: libgcc_s.so.1 Cnt: 1
│ │ │ │ │ │ 0x0010: Name: GCC_3.0 Flags: none Version: 21
│ │ │ │ │ │ 0x0020: Version: 1 File: libz.so.1 Cnt: 1
│ │ │ │ │ │ 0x0030: Name: ZLIB_1.2.3.5 Flags: none Version: 11
│ │ │ │ │ │ 0x0040: Version: 1 File: libssl.so.1.1 Cnt: 1
│ │ │ │ │ │ 0x0050: Name: OPENSSL_1_1_0 Flags: none Version: 7
│ │ │ │ │ │ 0x0060: Version: 1 File: libpthread.so.0 Cnt: 1
│ │ │ │ │ ├── readelf --wide --decompress --hex-dump=.dynstr {}
│ │ │ │ │ │ ## -389,9 +389,9 ##
│ │ │ │ │ │ 0x00002f38 474c4942 4358585f 332e3400 474c4942 GLIBCXX_3.4.GLIB
│ │ │ │ │ │ 0x00002f48 435f322e 3400474c 4942435f 322e3134 C_2.4.GLIBC_2.14
│ │ │ │ │ │ 0x00002f58 00474c49 42435f32 2e332e34 00000000 .GLIBC_2.3.4....
│ │ │ │ │ │ 0x00002f68 00000000 00000000 00000000 00000000 ................
│ │ │ │ │ │ 0x00002f78 00000000 00000000 00000000 00000000 ................
│ │ │ │ │ │ 0x00002f88 00000000 00000000 00000000 00000000 ................
│ │ │ │ │ │ 0x00002f98 00000000 00000000 00000000 00000000 ................
│ │ │ │ │ │ - 0x00002fa8 00 .
│ │ │ │ │ │ + 0x00002fa8 00000000 00 .....
section_end:1597588268:step_script
It's very strange.
I use gcloud pubsub subscriptions pull message-blocking-SUB --limit 10 try to pull messages from message-blocking-SUB subscription.
Here is the results:
☁ nodejs-gcp [master] ⚡ gcloud pubsub subscriptions pull message-blocking-SUB --limit 10
┌──────────────────────────────────────────┬─────────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ ACK_ID │
├──────────────────────────────────────────┼─────────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ {"data":"Hello, world! - 1543554888273"} │ 283307349579869 │ │ QV5AEkw2B0RJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNCEGgzXHUHUQ0YdHpndmoLFAJTFFl-VVsJPGh-Y3cPUg4ZdX5lfG9dGgkETHvi4M-dxOksZhg9XBJLLD5-PTJF │
└──────────────────────────────────────────┴─────────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
☁ nodejs-gcp [master] ⚡ gcloud pubsub subscriptions pull message-blocking-SUB --limit 10
┌──────────────────────────────────────────┬─────────────────┬────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ ACK_ID │
├──────────────────────────────────────────┼─────────────────┼────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ {"data":"Hello, world! - 1543555283170"} │ 283307447044599 │ │ XkASTDYHRElTK0MLKlgRTgQhIT4wPkVTRFAGFixdRkhRNxkIaFEOT14jPzUgKEUQC1MTUVx1E0wQaV0zdQdRDRlze2ZzaVsTBlNBVXRfURsfWVx-SgVZDhpyemVxbVoXBQdMWlbD5I-Lod0sZhs9XBJLLD5-PTJFQQ │
│ {"data":"Hello, world! - 1543555288172"} │ 283307327268587 │ │ XkASTDYHRElTK0MLKlgRTgQhIT4wPkVTRFAGFixdRkhRNxkIaFEOT14jPzUgKEUQC1MTUVx1E0wQaV0zdQdRDRlze2ZzaVsTBlNBVXReURsfWVx-SgVZDhpyemJ3bVgVCQdNVFbD5I-Lod0sZhs9XBJLLD5-PTJFQQ │
│ {"data":"Hello, world! - 1543555293176"} │ 283307486528068 │ │ XkASTDYHRElTK0MLKlgRTgQhIT4wPkVTRFAGFixdRkhRNxkIaFEOT14jPzUgKEUQC1MTUVx1E0wQaV0zdQdRDRlze2ZzaVsTBlNBVXRdURsfWVx-SgVZDhpyemV9bF8RCQJDW1bD5I-Lod0sZhs9XBJLLD5-PTJFQQ │
└──────────────────────────────────────────┴─────────────────┴────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
☁ nodejs-gcp [master] ⚡ gcloud pubsub subscriptions pull message-blocking-SUB --limit 10
┌───────────────────────────────┬─────────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ ACK_ID │
├───────────────────────────────┼─────────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Hello, world! - 1543547000557 │ 283191392654279 │ │ QV5AEkw2B0RJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNMEG4zXHUHUQ0YdHpnd2NYEgkCTFl-VVsJPGh-Y3cPUgwQc35od2xfFwMFTHvi4M-dxOksZhg9XBJLLD5-PTJF │
│ Hello, world! - 1543547015562 │ 283191378142602 │ │ QV5AEkw2B0RJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNMEG4zXHUHUQ0YdHpnd2NYEgkCTFl_VVsJPGh-Y3cPUgwQc35mfWteEQcCR3vi4M-dxOksZhg9XBJLLD5-PTJF │
│ Hello, world! - 1543547020563 │ 283191323745952 │ │ QV5AEkw2B0RJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNMEG4zXHUHUQ0YdHpnd2NYEgkCTFl8VVsJPGh-Y3cPUgwQc35jdm1eFggHR3vi4M-dxOksZhg9XBJLLD5-PTJF │
└───────────────────────────────┴─────────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
☁ nodejs-gcp [master] ⚡ gcloud pubsub subscriptions pull message-blocking-SUB --limit 10
┌──────────────────────────────────────────┬─────────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DATA │ MESSAGE_ID │ ATTRIBUTES │ ACK_ID │
├──────────────────────────────────────────┼─────────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ {"data":"Hello, world! - 1543554888273"} │ 283307349579869 │ │ QV5AEkw2B0RJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNCEGgzXHUHUQ0YdHpndmoLFAJTFFl-VVsJPGh-Y3cPUg4ZdX5lfG9dGgkETHvi4M-dxOksZhg9XBJLLD5-PTJF │
└──────────────────────────────────────────┴─────────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
☁ nodejs-gcp [master] ⚡
My message queue has three messages.
I run this command four times. It seems that the result is different for each time.
I expect the results should be always three messages.
I don't understand.
Are you sure your subscription only has 3 messages? Your 'data' values shows otherwise.
{"data":"Hello, world! - 1543555283170"} │ 283307447044599
{"data":"Hello, world! - 1543555288172"} │ 283307327268587
{"data":"Hello, world! - 1543555293176"} │ 283307486528068
{"data":"Hello, world! - 1543554888273"} │ 283307349579869
Hello, world! - 1543547000557 │ 283191392654279
Hello, world! - 1543547015562 │ 283191378142602
Hello, world! - 1543547020563 │ 283191323745952
I suspect some of your confusion is that when you pull the messages without acking them they're not available for some period of time, I believe the default is 10s or so. Pubsub is assuming whatever pulled the messages is still doing work and may ack the message soon. Until that window of time passes you'll only see new messages, or ones whose delivery window has expired.
I am looking for a regexp that could match a specific response code (error code) in apache or nginx webserver logs.
10.80.248.64 - - [02/Nov/2012:15:04:40 +0000] "GET //browse/OS HTTP/1.1" 404 497 "-" "-"
10.220.64.11 - - [02/Nov/2012:15:04:54 +0000] "GET / HTTP/1.0" 200 491 "-" "Wget/1.12 (linux-gnu)"
10.80.16.66 - - [29/Oct/2012:11:09:11 +0000] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
The reg exp should be able to match lines with a specific error code like 404, 200 or 302.
Use regex pattern
^[^"]*"[^"]*\sHTTP\/[\d.]+"\s+(?:200|302|404)\s.*$
└─┬─┘│└─┬─┘└┤└────┬─────┘│└┬┘└──────┬──────┘└┤└┤
│ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ └─ anything (including nothing)
│ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ └─ one space (white-space character)
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ └─ 200 or 302 or 404
│ │ │ │ │ │ │
│ │ │ │ │ │ └─ one or more spaces (white-space characters)
│ │ │ │ │ │
│ │ │ │ │ └─ one double-quote character
│ │ │ │ │
│ │ │ │ └─ HTTP/ followed by a combination of digit(s) and/or dot(s)
│ │ │ │
│ │ │ └─ one space (white-space character)
│ │ │
│ │ └─ anything (including nothing) but double-quote character(s)
│ │
│ └─ one double-quote character
│
└─ anything (including nothing) but double-quote character(s)